Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/libcst/_nodes/op.py: 84%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2#
3# This source code is licensed under the MIT license found in the
4# LICENSE file in the root directory of this source tree.
6from abc import ABC, abstractmethod
7from dataclasses import dataclass
8from typing import Tuple
10from libcst._add_slots import add_slots
11from libcst._nodes.base import BaseLeaf, CSTNode, CSTValidationError
12from libcst._nodes.internal import CodegenState, visit_required
13from libcst._nodes.whitespace import BaseParenthesizableWhitespace, SimpleWhitespace
14from libcst._visitors import CSTVisitorT
17class _BaseOneTokenOp(CSTNode, ABC):
18 """
19 Any node that has a static value and needs to own whitespace on both sides.
20 """
22 __slots__ = ()
24 whitespace_before: BaseParenthesizableWhitespace
26 whitespace_after: BaseParenthesizableWhitespace
28 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "_BaseOneTokenOp":
29 # pyre-ignore Pyre thinks that self.__class__ is CSTNode, not _BaseOneTokenOp
30 return self.__class__(
31 whitespace_before=visit_required(
32 self, "whitespace_before", self.whitespace_before, visitor
33 ),
34 whitespace_after=visit_required(
35 self, "whitespace_after", self.whitespace_after, visitor
36 ),
37 )
39 def _codegen_impl(self, state: CodegenState) -> None:
40 self.whitespace_before._codegen(state)
41 with state.record_syntactic_position(self):
42 state.add_token(self._get_token())
43 self.whitespace_after._codegen(state)
45 @abstractmethod
46 def _get_token(self) -> str: ...
49class _BaseTwoTokenOp(CSTNode, ABC):
50 """
51 Any node that ends up as two tokens, so we must preserve the whitespace
52 in beteween them.
53 """
55 __slots__ = ()
57 whitespace_before: BaseParenthesizableWhitespace
59 whitespace_between: BaseParenthesizableWhitespace
61 whitespace_after: BaseParenthesizableWhitespace
63 def _validate(self) -> None:
64 if self.whitespace_between.empty:
65 raise CSTValidationError("Must have at least one space between not and in.")
67 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "_BaseTwoTokenOp":
68 # pyre-ignore Pyre thinks that self.__class__ is CSTNode, not _BaseTwoTokenOp
69 return self.__class__(
70 whitespace_before=visit_required(
71 self, "whitespace_before", self.whitespace_before, visitor
72 ),
73 whitespace_between=visit_required(
74 self, "whitespace_between", self.whitespace_between, visitor
75 ),
76 whitespace_after=visit_required(
77 self, "whitespace_after", self.whitespace_after, visitor
78 ),
79 )
81 def _codegen_impl(self, state: CodegenState) -> None:
82 self.whitespace_before._codegen(state)
83 with state.record_syntactic_position(self):
84 state.add_token(self._get_tokens()[0])
85 self.whitespace_between._codegen(state)
86 state.add_token(self._get_tokens()[1])
87 self.whitespace_after._codegen(state)
89 @abstractmethod
90 def _get_tokens(self) -> Tuple[str, str]: ...
93class BaseUnaryOp(CSTNode, ABC):
94 """
95 Any node that has a static value used in a :class:`UnaryOperation` expression.
96 """
98 __slots__ = ()
100 #: Any space that appears directly after this operator.
101 whitespace_after: BaseParenthesizableWhitespace
103 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "BaseUnaryOp":
104 # pyre-ignore Pyre thinks that self.__class__ is CSTNode, not BaseUnaryOp
105 return self.__class__(
106 whitespace_after=visit_required(
107 self, "whitespace_after", self.whitespace_after, visitor
108 )
109 )
111 def _codegen_impl(self, state: CodegenState) -> None:
112 state.add_token(self._get_token())
113 self.whitespace_after._codegen(state)
115 @abstractmethod
116 def _get_token(self) -> str: ...
119class BaseBooleanOp(_BaseOneTokenOp, ABC):
120 """
121 Any node that has a static value used in a :class:`BooleanOperation` expression.
122 This node is purely for typing.
123 """
125 __slots__ = ()
128class BaseBinaryOp(CSTNode, ABC):
129 """
130 Any node that has a static value used in a :class:`BinaryOperation` expression.
131 This node is purely for typing.
132 """
134 __slots__ = ()
137class BaseCompOp(CSTNode, ABC):
138 """
139 Any node that has a static value used in a :class:`Comparison` expression.
140 This node is purely for typing.
141 """
143 __slots__ = ()
146class BaseAugOp(CSTNode, ABC):
147 """
148 Any node that has a static value used in an :class:`AugAssign` assignment.
149 This node is purely for typing.
150 """
152 __slots__ = ()
155@add_slots
156@dataclass(frozen=True)
157class Semicolon(_BaseOneTokenOp):
158 """
159 Used by any small statement (any subclass of :class:`BaseSmallStatement`
160 such as :class:`Pass`) as a separator between subsequent nodes contained
161 within a :class:`SimpleStatementLine` or :class:`SimpleStatementSuite`.
162 """
164 #: Any space that appears directly before this semicolon.
165 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
167 #: Any space that appears directly after this semicolon.
168 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
170 def _get_token(self) -> str:
171 return ";"
174@add_slots
175@dataclass(frozen=True)
176class Colon(_BaseOneTokenOp):
177 """
178 Used by :class:`Slice` as a separator between subsequent expressions,
179 and in :class:`Lambda` to separate arguments and body.
180 """
182 #: Any space that appears directly before this colon.
183 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
185 #: Any space that appears directly after this colon.
186 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
188 def _get_token(self) -> str:
189 return ":"
192@add_slots
193@dataclass(frozen=True)
194class Comma(_BaseOneTokenOp):
195 """
196 Syntactic trivia used as a separator between subsequent items in various
197 parts of the grammar.
199 Some use-cases are:
201 * :class:`Import` or :class:`ImportFrom`.
202 * :class:`FunctionDef` arguments.
203 * :class:`Tuple`/:class:`List`/:class:`Set`/:class:`Dict` elements.
204 """
206 #: Any space that appears directly before this comma.
207 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
209 #: Any space that appears directly after this comma.
210 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
212 def _get_token(self) -> str:
213 return ","
216@add_slots
217@dataclass(frozen=True)
218class Dot(_BaseOneTokenOp):
219 """
220 Used by :class:`Attribute` as a separator between subsequent :class:`Name` nodes.
221 """
223 #: Any space that appears directly before this dot.
224 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
226 #: Any space that appears directly after this dot.
227 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
229 def _get_token(self) -> str:
230 return "."
233@add_slots
234@dataclass(frozen=True)
235class ImportStar(BaseLeaf):
236 """
237 Used by :class:`ImportFrom` to denote a star import instead of a list
238 of importable objects.
239 """
241 def _codegen_impl(self, state: CodegenState) -> None:
242 state.add_token("*")
245@add_slots
246@dataclass(frozen=True)
247class AssignEqual(_BaseOneTokenOp):
248 """
249 Used by :class:`AnnAssign` to denote a single equal character when doing an
250 assignment on top of a type annotation. Also used by :class:`Param` and
251 :class:`Arg` to denote assignment of a default value, and by
252 :class:`FormattedStringExpression` to denote usage of self-documenting
253 expressions.
254 """
256 #: Any space that appears directly before this equal sign.
257 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
259 #: Any space that appears directly after this equal sign.
260 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
262 def _get_token(self) -> str:
263 return "="
266@add_slots
267@dataclass(frozen=True)
268class Plus(BaseUnaryOp):
269 """
270 A unary operator that can be used in a :class:`UnaryOperation`
271 expression.
272 """
274 #: Any space that appears directly after this operator.
275 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
277 def _get_token(self) -> str:
278 return "+"
281@add_slots
282@dataclass(frozen=True)
283class Minus(BaseUnaryOp):
284 """
285 A unary operator that can be used in a :class:`UnaryOperation`
286 expression.
287 """
289 #: Any space that appears directly after this operator.
290 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
292 def _get_token(self) -> str:
293 return "-"
296@add_slots
297@dataclass(frozen=True)
298class BitInvert(BaseUnaryOp):
299 """
300 A unary operator that can be used in a :class:`UnaryOperation`
301 expression.
302 """
304 #: Any space that appears directly after this operator.
305 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
307 def _get_token(self) -> str:
308 return "~"
311@add_slots
312@dataclass(frozen=True)
313class Not(BaseUnaryOp):
314 """
315 A unary operator that can be used in a :class:`UnaryOperation`
316 expression.
317 """
319 #: Any space that appears directly after this operator.
320 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
322 def _get_token(self) -> str:
323 return "not"
326@add_slots
327@dataclass(frozen=True)
328class And(BaseBooleanOp):
329 """
330 A boolean operator that can be used in a :class:`BooleanOperation`
331 expression.
332 """
334 #: Any space that appears directly before this operator.
335 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
337 #: Any space that appears directly after this operator.
338 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
340 def _get_token(self) -> str:
341 return "and"
344@add_slots
345@dataclass(frozen=True)
346class Or(BaseBooleanOp):
347 """
348 A boolean operator that can be used in a :class:`BooleanOperation`
349 expression.
350 """
352 #: Any space that appears directly before this operator.
353 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
355 #: Any space that appears directly after this operator.
356 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
358 def _get_token(self) -> str:
359 return "or"
362@add_slots
363@dataclass(frozen=True)
364class Add(BaseBinaryOp, _BaseOneTokenOp):
365 """
366 A binary operator that can be used in a :class:`BinaryOperation`
367 expression.
368 """
370 #: Any space that appears directly before this operator.
371 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
373 #: Any space that appears directly after this operator.
374 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
376 def _get_token(self) -> str:
377 return "+"
380@add_slots
381@dataclass(frozen=True)
382class Subtract(BaseBinaryOp, _BaseOneTokenOp):
383 """
384 A binary operator that can be used in a :class:`BinaryOperation`
385 expression.
386 """
388 #: Any space that appears directly before this operator.
389 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
391 #: Any space that appears directly after this operator.
392 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
394 def _get_token(self) -> str:
395 return "-"
398@add_slots
399@dataclass(frozen=True)
400class Multiply(BaseBinaryOp, _BaseOneTokenOp):
401 """
402 A binary operator that can be used in a :class:`BinaryOperation`
403 expression.
404 """
406 #: Any space that appears directly before this operator.
407 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
409 #: Any space that appears directly after this operator.
410 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
412 def _get_token(self) -> str:
413 return "*"
416@add_slots
417@dataclass(frozen=True)
418class Divide(BaseBinaryOp, _BaseOneTokenOp):
419 """
420 A binary operator that can be used in a :class:`BinaryOperation`
421 expression.
422 """
424 #: Any space that appears directly before this operator.
425 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
427 #: Any space that appears directly after this operator.
428 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
430 def _get_token(self) -> str:
431 return "/"
434@add_slots
435@dataclass(frozen=True)
436class FloorDivide(BaseBinaryOp, _BaseOneTokenOp):
437 """
438 A binary operator that can be used in a :class:`BinaryOperation`
439 expression.
440 """
442 #: Any space that appears directly before this operator.
443 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
445 #: Any space that appears directly after this operator.
446 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
448 def _get_token(self) -> str:
449 return "//"
452@add_slots
453@dataclass(frozen=True)
454class Modulo(BaseBinaryOp, _BaseOneTokenOp):
455 """
456 A binary operator that can be used in a :class:`BinaryOperation`
457 expression.
458 """
460 #: Any space that appears directly before this operator.
461 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
463 #: Any space that appears directly after this operator.
464 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
466 def _get_token(self) -> str:
467 return "%"
470@add_slots
471@dataclass(frozen=True)
472class Power(BaseBinaryOp, _BaseOneTokenOp):
473 """
474 A binary operator that can be used in a :class:`BinaryOperation`
475 expression.
476 """
478 #: Any space that appears directly before this operator.
479 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
481 #: Any space that appears directly after this operator.
482 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
484 def _get_token(self) -> str:
485 return "**"
488@add_slots
489@dataclass(frozen=True)
490class LeftShift(BaseBinaryOp, _BaseOneTokenOp):
491 """
492 A binary operator that can be used in a :class:`BinaryOperation`
493 expression.
494 """
496 #: Any space that appears directly before this operator.
497 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
499 #: Any space that appears directly after this operator.
500 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
502 def _get_token(self) -> str:
503 return "<<"
506@add_slots
507@dataclass(frozen=True)
508class RightShift(BaseBinaryOp, _BaseOneTokenOp):
509 """
510 A binary operator that can be used in a :class:`BinaryOperation`
511 expression.
512 """
514 #: Any space that appears directly before this operator.
515 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
517 #: Any space that appears directly after this operator.
518 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
520 def _get_token(self) -> str:
521 return ">>"
524@add_slots
525@dataclass(frozen=True)
526class BitOr(BaseBinaryOp, _BaseOneTokenOp):
527 """
528 A binary operator that can be used in a :class:`BinaryOperation`
529 expression.
530 """
532 #: Any space that appears directly before this operator.
533 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
535 #: Any space that appears directly after this operator.
536 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
538 def _get_token(self) -> str:
539 return "|"
542@add_slots
543@dataclass(frozen=True)
544class BitAnd(BaseBinaryOp, _BaseOneTokenOp):
545 """
546 A binary operator that can be used in a :class:`BinaryOperation`
547 expression.
548 """
550 #: Any space that appears directly before this operator.
551 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
553 #: Any space that appears directly after this operator.
554 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
556 def _get_token(self) -> str:
557 return "&"
560@add_slots
561@dataclass(frozen=True)
562class BitXor(BaseBinaryOp, _BaseOneTokenOp):
563 """
564 A binary operator that can be used in a :class:`BinaryOperation`
565 expression.
566 """
568 #: Any space that appears directly before this operator.
569 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
571 #: Any space that appears directly after this operator.
572 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
574 def _get_token(self) -> str:
575 return "^"
578@add_slots
579@dataclass(frozen=True)
580class MatrixMultiply(BaseBinaryOp, _BaseOneTokenOp):
581 """
582 A binary operator that can be used in a :class:`BinaryOperation`
583 expression.
584 """
586 #: Any space that appears directly before this operator.
587 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
589 #: Any space that appears directly after this operator.
590 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
592 def _get_token(self) -> str:
593 return "@"
596@add_slots
597@dataclass(frozen=True)
598class LessThan(BaseCompOp, _BaseOneTokenOp):
599 """
600 A comparision operator that can be used in a :class:`Comparison` expression.
601 """
603 #: Any space that appears directly before this operator.
604 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
606 #: Any space that appears directly after this operator.
607 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
609 def _get_token(self) -> str:
610 return "<"
613@add_slots
614@dataclass(frozen=True)
615class GreaterThan(BaseCompOp, _BaseOneTokenOp):
616 """
617 A comparision operator that can be used in a :class:`Comparison` expression.
618 """
620 #: Any space that appears directly before this operator.
621 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
623 #: Any space that appears directly after this operator.
624 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
626 def _get_token(self) -> str:
627 return ">"
630@add_slots
631@dataclass(frozen=True)
632class Equal(BaseCompOp, _BaseOneTokenOp):
633 """
634 A comparision operator that can be used in a :class:`Comparison` expression.
635 """
637 #: Any space that appears directly before this operator.
638 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
640 #: Any space that appears directly after this operator.
641 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
643 def _get_token(self) -> str:
644 return "=="
647@add_slots
648@dataclass(frozen=True)
649class LessThanEqual(BaseCompOp, _BaseOneTokenOp):
650 """
651 A comparision operator that can be used in a :class:`Comparison` expression.
652 """
654 #: Any space that appears directly before this operator.
655 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
657 #: Any space that appears directly after this operator.
658 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
660 def _get_token(self) -> str:
661 return "<="
664@add_slots
665@dataclass(frozen=True)
666class GreaterThanEqual(BaseCompOp, _BaseOneTokenOp):
667 """
668 A comparision operator that can be used in a :class:`Comparison` expression.
669 """
671 #: Any space that appears directly before this operator.
672 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
674 #: Any space that appears directly after this operator.
675 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
677 def _get_token(self) -> str:
678 return ">="
681@add_slots
682@dataclass(frozen=True)
683class NotEqual(BaseCompOp, _BaseOneTokenOp):
684 """
685 A comparison operator that can be used in a :class:`Comparison` expression.
687 This node defines a static value for convenience, but in reality due to
688 PEP 401 it can be one of two values, both of which should be a
689 :class:`NotEqual` :class:`Comparison` operator.
690 """
692 #: The actual text value of this operator. Can be either ``!=`` or ``<>``.
693 value: str = "!="
695 #: Any space that appears directly before this operator.
696 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
698 #: Any space that appears directly after this operator.
699 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
701 def _validate(self) -> None:
702 if self.value not in ["!=", "<>"]:
703 raise CSTValidationError("Invalid value for NotEqual node.")
705 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "NotEqual":
706 return self.__class__(
707 whitespace_before=visit_required(
708 self, "whitespace_before", self.whitespace_before, visitor
709 ),
710 value=self.value,
711 whitespace_after=visit_required(
712 self, "whitespace_after", self.whitespace_after, visitor
713 ),
714 )
716 def _get_token(self) -> str:
717 return self.value
720@add_slots
721@dataclass(frozen=True)
722class In(BaseCompOp, _BaseOneTokenOp):
723 """
724 A comparision operator that can be used in a :class:`Comparison` expression.
725 """
727 #: Any space that appears directly before this operator.
728 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
730 #: Any space that appears directly after this operator.
731 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
733 def _get_token(self) -> str:
734 return "in"
737@add_slots
738@dataclass(frozen=True)
739class NotIn(BaseCompOp, _BaseTwoTokenOp):
740 """
741 A comparision operator that can be used in a :class:`Comparison` expression.
743 This operator spans two tokens that must be separated by at least one space,
744 so there is a third whitespace attribute to represent this.
745 """
747 #: Any space that appears directly before this operator.
748 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
750 #: Any space that appears between the ``not`` and ``in`` tokens.
751 whitespace_between: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
753 #: Any space that appears directly after this operator.
754 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
756 def _get_tokens(self) -> Tuple[str, str]:
757 return ("not", "in")
760@add_slots
761@dataclass(frozen=True)
762class Is(BaseCompOp, _BaseOneTokenOp):
763 """
764 A comparision operator that can be used in a :class:`Comparison` expression.
765 """
767 #: Any space that appears directly before this operator.
768 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
770 #: Any space that appears directly after this operator.
771 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
773 def _get_token(self) -> str:
774 return "is"
777@add_slots
778@dataclass(frozen=True)
779class IsNot(BaseCompOp, _BaseTwoTokenOp):
780 """
781 A comparision operator that can be used in a :class:`Comparison` expression.
783 This operator spans two tokens that must be separated by at least one space,
784 so there is a third whitespace attribute to represent this.
785 """
787 #: Any space that appears directly before this operator.
788 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
790 #: Any space that appears between the ``is`` and ``not`` tokens.
791 whitespace_between: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
793 #: Any space that appears directly after this operator.
794 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
796 def _get_tokens(self) -> Tuple[str, str]:
797 return ("is", "not")
800@add_slots
801@dataclass(frozen=True)
802class AddAssign(BaseAugOp, _BaseOneTokenOp):
803 """
804 An augmented assignment operator that can be used in a :class:`AugAssign`
805 statement.
806 """
808 #: Any space that appears directly before this operator.
809 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
811 #: Any space that appears directly after this operator.
812 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
814 def _get_token(self) -> str:
815 return "+="
818@add_slots
819@dataclass(frozen=True)
820class SubtractAssign(BaseAugOp, _BaseOneTokenOp):
821 """
822 An augmented assignment operator that can be used in a :class:`AugAssign`
823 statement.
824 """
826 #: Any space that appears directly before this operator.
827 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
829 #: Any space that appears directly after this operator.
830 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
832 def _get_token(self) -> str:
833 return "-="
836@add_slots
837@dataclass(frozen=True)
838class MultiplyAssign(BaseAugOp, _BaseOneTokenOp):
839 """
840 An augmented assignment operator that can be used in a :class:`AugAssign`
841 statement.
842 """
844 #: Any space that appears directly before this operator.
845 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
847 #: Any space that appears directly after this operator.
848 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
850 def _get_token(self) -> str:
851 return "*="
854@add_slots
855@dataclass(frozen=True)
856class MatrixMultiplyAssign(BaseAugOp, _BaseOneTokenOp):
857 """
858 An augmented assignment operator that can be used in a :class:`AugAssign`
859 statement.
860 """
862 #: Any space that appears directly before this operator.
863 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
865 #: Any space that appears directly after this operator.
866 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
868 def _get_token(self) -> str:
869 return "@="
872@add_slots
873@dataclass(frozen=True)
874class DivideAssign(BaseAugOp, _BaseOneTokenOp):
875 """
876 An augmented assignment operator that can be used in a :class:`AugAssign`
877 statement.
878 """
880 #: Any space that appears directly before this operator.
881 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
883 #: Any space that appears directly after this operator.
884 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
886 def _get_token(self) -> str:
887 return "/="
890@add_slots
891@dataclass(frozen=True)
892class ModuloAssign(BaseAugOp, _BaseOneTokenOp):
893 """
894 An augmented assignment operator that can be used in a :class:`AugAssign`
895 statement.
896 """
898 #: Any space that appears directly before this operator.
899 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
901 #: Any space that appears directly after this operator.
902 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
904 def _get_token(self) -> str:
905 return "%="
908@add_slots
909@dataclass(frozen=True)
910class BitAndAssign(BaseAugOp, _BaseOneTokenOp):
911 """
912 An augmented assignment operator that can be used in a :class:`AugAssign`
913 statement.
914 """
916 #: Any space that appears directly before this operator.
917 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
919 #: Any space that appears directly after this operator.
920 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
922 def _get_token(self) -> str:
923 return "&="
926@add_slots
927@dataclass(frozen=True)
928class BitOrAssign(BaseAugOp, _BaseOneTokenOp):
929 """
930 An augmented assignment operator that can be used in a :class:`AugAssign`
931 statement.
932 """
934 #: Any space that appears directly before this operator.
935 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
937 #: Any space that appears directly after this operator.
938 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
940 def _get_token(self) -> str:
941 return "|="
944@add_slots
945@dataclass(frozen=True)
946class BitXorAssign(BaseAugOp, _BaseOneTokenOp):
947 """
948 An augmented assignment operator that can be used in a :class:`AugAssign`
949 statement.
950 """
952 #: Any space that appears directly before this operator.
953 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
955 #: Any space that appears directly after this operator.
956 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
958 def _get_token(self) -> str:
959 return "^="
962@add_slots
963@dataclass(frozen=True)
964class LeftShiftAssign(BaseAugOp, _BaseOneTokenOp):
965 """
966 An augmented assignment operator that can be used in a :class:`AugAssign`
967 statement.
968 """
970 #: Any space that appears directly before this operator.
971 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
973 #: Any space that appears directly after this operator.
974 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
976 def _get_token(self) -> str:
977 return "<<="
980@add_slots
981@dataclass(frozen=True)
982class RightShiftAssign(BaseAugOp, _BaseOneTokenOp):
983 """
984 An augmented assignment operator that can be used in a :class:`AugAssign`
985 statement.
986 """
988 #: Any space that appears directly before this operator.
989 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
991 #: Any space that appears directly after this operator.
992 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
994 def _get_token(self) -> str:
995 return ">>="
998@add_slots
999@dataclass(frozen=True)
1000class PowerAssign(BaseAugOp, _BaseOneTokenOp):
1001 """
1002 An augmented assignment operator that can be used in a :class:`AugAssign`
1003 statement.
1004 """
1006 #: Any space that appears directly before this operator.
1007 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1009 #: Any space that appears directly after this operator.
1010 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1012 def _get_token(self) -> str:
1013 return "**="
1016@add_slots
1017@dataclass(frozen=True)
1018class FloorDivideAssign(BaseAugOp, _BaseOneTokenOp):
1019 """
1020 An augmented assignment operator that can be used in a :class:`AugAssign`
1021 statement.
1022 """
1024 #: Any space that appears directly before this operator.
1025 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1027 #: Any space that appears directly after this operator.
1028 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1030 def _get_token(self) -> str:
1031 return "//="