Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/libcst/_nodes/op.py: 84%
399 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
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:
47 ...
50class _BaseTwoTokenOp(CSTNode, ABC):
51 """
52 Any node that ends up as two tokens, so we must preserve the whitespace
53 in beteween them.
54 """
56 __slots__ = ()
58 whitespace_before: BaseParenthesizableWhitespace
60 whitespace_between: BaseParenthesizableWhitespace
62 whitespace_after: BaseParenthesizableWhitespace
64 def _validate(self) -> None:
65 if self.whitespace_between.empty:
66 raise CSTValidationError("Must have at least one space between not and in.")
68 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "_BaseTwoTokenOp":
69 # pyre-ignore Pyre thinks that self.__class__ is CSTNode, not _BaseTwoTokenOp
70 return self.__class__(
71 whitespace_before=visit_required(
72 self, "whitespace_before", self.whitespace_before, visitor
73 ),
74 whitespace_between=visit_required(
75 self, "whitespace_between", self.whitespace_between, visitor
76 ),
77 whitespace_after=visit_required(
78 self, "whitespace_after", self.whitespace_after, visitor
79 ),
80 )
82 def _codegen_impl(self, state: CodegenState) -> None:
83 self.whitespace_before._codegen(state)
84 with state.record_syntactic_position(self):
85 state.add_token(self._get_tokens()[0])
86 self.whitespace_between._codegen(state)
87 state.add_token(self._get_tokens()[1])
88 self.whitespace_after._codegen(state)
90 @abstractmethod
91 def _get_tokens(self) -> Tuple[str, str]:
92 ...
95class BaseUnaryOp(CSTNode, ABC):
96 """
97 Any node that has a static value used in a :class:`UnaryOperation` expression.
98 """
100 __slots__ = ()
102 #: Any space that appears directly after this operator.
103 whitespace_after: BaseParenthesizableWhitespace
105 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "BaseUnaryOp":
106 # pyre-ignore Pyre thinks that self.__class__ is CSTNode, not BaseUnaryOp
107 return self.__class__(
108 whitespace_after=visit_required(
109 self, "whitespace_after", self.whitespace_after, visitor
110 )
111 )
113 def _codegen_impl(self, state: CodegenState) -> None:
114 state.add_token(self._get_token())
115 self.whitespace_after._codegen(state)
117 @abstractmethod
118 def _get_token(self) -> str:
119 ...
122class BaseBooleanOp(_BaseOneTokenOp, ABC):
123 """
124 Any node that has a static value used in a :class:`BooleanOperation` expression.
125 This node is purely for typing.
126 """
128 __slots__ = ()
131class BaseBinaryOp(CSTNode, ABC):
132 """
133 Any node that has a static value used in a :class:`BinaryOperation` expression.
134 This node is purely for typing.
135 """
137 __slots__ = ()
140class BaseCompOp(CSTNode, ABC):
141 """
142 Any node that has a static value used in a :class:`Comparison` expression.
143 This node is purely for typing.
144 """
146 __slots__ = ()
149class BaseAugOp(CSTNode, ABC):
150 """
151 Any node that has a static value used in an :class:`AugAssign` assignment.
152 This node is purely for typing.
153 """
155 __slots__ = ()
158@add_slots
159@dataclass(frozen=True)
160class Semicolon(_BaseOneTokenOp):
161 """
162 Used by any small statement (any subclass of :class:`BaseSmallStatement`
163 such as :class:`Pass`) as a separator between subsequent nodes contained
164 within a :class:`SimpleStatementLine` or :class:`SimpleStatementSuite`.
165 """
167 #: Any space that appears directly before this semicolon.
168 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
170 #: Any space that appears directly after this semicolon.
171 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
173 def _get_token(self) -> str:
174 return ";"
177@add_slots
178@dataclass(frozen=True)
179class Colon(_BaseOneTokenOp):
180 """
181 Used by :class:`Slice` as a separator between subsequent expressions,
182 and in :class:`Lambda` to separate arguments and body.
183 """
185 #: Any space that appears directly before this colon.
186 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
188 #: Any space that appears directly after this colon.
189 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
191 def _get_token(self) -> str:
192 return ":"
195@add_slots
196@dataclass(frozen=True)
197class Comma(_BaseOneTokenOp):
198 """
199 Syntactic trivia used as a separator between subsequent items in various
200 parts of the grammar.
202 Some use-cases are:
204 * :class:`Import` or :class:`ImportFrom`.
205 * :class:`FunctionDef` arguments.
206 * :class:`Tuple`/:class:`List`/:class:`Set`/:class:`Dict` elements.
207 """
209 #: Any space that appears directly before this comma.
210 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
212 #: Any space that appears directly after this comma.
213 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
215 def _get_token(self) -> str:
216 return ","
219@add_slots
220@dataclass(frozen=True)
221class Dot(_BaseOneTokenOp):
222 """
223 Used by :class:`Attribute` as a separator between subsequent :class:`Name` nodes.
224 """
226 #: Any space that appears directly before this dot.
227 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
229 #: Any space that appears directly after this dot.
230 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
232 def _get_token(self) -> str:
233 return "."
236@add_slots
237@dataclass(frozen=True)
238class ImportStar(BaseLeaf):
239 """
240 Used by :class:`ImportFrom` to denote a star import instead of a list
241 of importable objects.
242 """
244 def _codegen_impl(self, state: CodegenState) -> None:
245 state.add_token("*")
248@add_slots
249@dataclass(frozen=True)
250class AssignEqual(_BaseOneTokenOp):
251 """
252 Used by :class:`AnnAssign` to denote a single equal character when doing an
253 assignment on top of a type annotation. Also used by :class:`Param` and
254 :class:`Arg` to denote assignment of a default value, and by
255 :class:`FormattedStringExpression` to denote usage of self-documenting
256 expressions.
257 """
259 #: Any space that appears directly before this equal sign.
260 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
262 #: Any space that appears directly after this equal sign.
263 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
265 def _get_token(self) -> str:
266 return "="
269@add_slots
270@dataclass(frozen=True)
271class Plus(BaseUnaryOp):
272 """
273 A unary operator that can be used in a :class:`UnaryOperation`
274 expression.
275 """
277 #: Any space that appears directly after this operator.
278 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
280 def _get_token(self) -> str:
281 return "+"
284@add_slots
285@dataclass(frozen=True)
286class Minus(BaseUnaryOp):
287 """
288 A unary operator that can be used in a :class:`UnaryOperation`
289 expression.
290 """
292 #: Any space that appears directly after this operator.
293 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
295 def _get_token(self) -> str:
296 return "-"
299@add_slots
300@dataclass(frozen=True)
301class BitInvert(BaseUnaryOp):
302 """
303 A unary operator that can be used in a :class:`UnaryOperation`
304 expression.
305 """
307 #: Any space that appears directly after this operator.
308 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field("")
310 def _get_token(self) -> str:
311 return "~"
314@add_slots
315@dataclass(frozen=True)
316class Not(BaseUnaryOp):
317 """
318 A unary operator that can be used in a :class:`UnaryOperation`
319 expression.
320 """
322 #: Any space that appears directly after this operator.
323 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
325 def _get_token(self) -> str:
326 return "not"
329@add_slots
330@dataclass(frozen=True)
331class And(BaseBooleanOp):
332 """
333 A boolean operator that can be used in a :class:`BooleanOperation`
334 expression.
335 """
337 #: Any space that appears directly before this operator.
338 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
340 #: Any space that appears directly after this operator.
341 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
343 def _get_token(self) -> str:
344 return "and"
347@add_slots
348@dataclass(frozen=True)
349class Or(BaseBooleanOp):
350 """
351 A boolean operator that can be used in a :class:`BooleanOperation`
352 expression.
353 """
355 #: Any space that appears directly before this operator.
356 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
358 #: Any space that appears directly after this operator.
359 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
361 def _get_token(self) -> str:
362 return "or"
365@add_slots
366@dataclass(frozen=True)
367class Add(BaseBinaryOp, _BaseOneTokenOp):
368 """
369 A binary operator that can be used in a :class:`BinaryOperation`
370 expression.
371 """
373 #: Any space that appears directly before this operator.
374 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
376 #: Any space that appears directly after this operator.
377 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
379 def _get_token(self) -> str:
380 return "+"
383@add_slots
384@dataclass(frozen=True)
385class Subtract(BaseBinaryOp, _BaseOneTokenOp):
386 """
387 A binary operator that can be used in a :class:`BinaryOperation`
388 expression.
389 """
391 #: Any space that appears directly before this operator.
392 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
394 #: Any space that appears directly after this operator.
395 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
397 def _get_token(self) -> str:
398 return "-"
401@add_slots
402@dataclass(frozen=True)
403class Multiply(BaseBinaryOp, _BaseOneTokenOp):
404 """
405 A binary operator that can be used in a :class:`BinaryOperation`
406 expression.
407 """
409 #: Any space that appears directly before this operator.
410 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
412 #: Any space that appears directly after this operator.
413 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
415 def _get_token(self) -> str:
416 return "*"
419@add_slots
420@dataclass(frozen=True)
421class Divide(BaseBinaryOp, _BaseOneTokenOp):
422 """
423 A binary operator that can be used in a :class:`BinaryOperation`
424 expression.
425 """
427 #: Any space that appears directly before this operator.
428 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
430 #: Any space that appears directly after this operator.
431 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
433 def _get_token(self) -> str:
434 return "/"
437@add_slots
438@dataclass(frozen=True)
439class FloorDivide(BaseBinaryOp, _BaseOneTokenOp):
440 """
441 A binary operator that can be used in a :class:`BinaryOperation`
442 expression.
443 """
445 #: Any space that appears directly before this operator.
446 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
448 #: Any space that appears directly after this operator.
449 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
451 def _get_token(self) -> str:
452 return "//"
455@add_slots
456@dataclass(frozen=True)
457class Modulo(BaseBinaryOp, _BaseOneTokenOp):
458 """
459 A binary operator that can be used in a :class:`BinaryOperation`
460 expression.
461 """
463 #: Any space that appears directly before this operator.
464 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
466 #: Any space that appears directly after this operator.
467 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
469 def _get_token(self) -> str:
470 return "%"
473@add_slots
474@dataclass(frozen=True)
475class Power(BaseBinaryOp, _BaseOneTokenOp):
476 """
477 A binary operator that can be used in a :class:`BinaryOperation`
478 expression.
479 """
481 #: Any space that appears directly before this operator.
482 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
484 #: Any space that appears directly after this operator.
485 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
487 def _get_token(self) -> str:
488 return "**"
491@add_slots
492@dataclass(frozen=True)
493class LeftShift(BaseBinaryOp, _BaseOneTokenOp):
494 """
495 A binary operator that can be used in a :class:`BinaryOperation`
496 expression.
497 """
499 #: Any space that appears directly before this operator.
500 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
502 #: Any space that appears directly after this operator.
503 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
505 def _get_token(self) -> str:
506 return "<<"
509@add_slots
510@dataclass(frozen=True)
511class RightShift(BaseBinaryOp, _BaseOneTokenOp):
512 """
513 A binary operator that can be used in a :class:`BinaryOperation`
514 expression.
515 """
517 #: Any space that appears directly before this operator.
518 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
520 #: Any space that appears directly after this operator.
521 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
523 def _get_token(self) -> str:
524 return ">>"
527@add_slots
528@dataclass(frozen=True)
529class BitOr(BaseBinaryOp, _BaseOneTokenOp):
530 """
531 A binary operator that can be used in a :class:`BinaryOperation`
532 expression.
533 """
535 #: Any space that appears directly before this operator.
536 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
538 #: Any space that appears directly after this operator.
539 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
541 def _get_token(self) -> str:
542 return "|"
545@add_slots
546@dataclass(frozen=True)
547class BitAnd(BaseBinaryOp, _BaseOneTokenOp):
548 """
549 A binary operator that can be used in a :class:`BinaryOperation`
550 expression.
551 """
553 #: Any space that appears directly before this operator.
554 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
556 #: Any space that appears directly after this operator.
557 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
559 def _get_token(self) -> str:
560 return "&"
563@add_slots
564@dataclass(frozen=True)
565class BitXor(BaseBinaryOp, _BaseOneTokenOp):
566 """
567 A binary operator that can be used in a :class:`BinaryOperation`
568 expression.
569 """
571 #: Any space that appears directly before this operator.
572 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
574 #: Any space that appears directly after this operator.
575 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
577 def _get_token(self) -> str:
578 return "^"
581@add_slots
582@dataclass(frozen=True)
583class MatrixMultiply(BaseBinaryOp, _BaseOneTokenOp):
584 """
585 A binary operator that can be used in a :class:`BinaryOperation`
586 expression.
587 """
589 #: Any space that appears directly before this operator.
590 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
592 #: Any space that appears directly after this operator.
593 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
595 def _get_token(self) -> str:
596 return "@"
599@add_slots
600@dataclass(frozen=True)
601class LessThan(BaseCompOp, _BaseOneTokenOp):
602 """
603 A comparision operator that can be used in a :class:`Comparison` expression.
604 """
606 #: Any space that appears directly before this operator.
607 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
609 #: Any space that appears directly after this operator.
610 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
612 def _get_token(self) -> str:
613 return "<"
616@add_slots
617@dataclass(frozen=True)
618class GreaterThan(BaseCompOp, _BaseOneTokenOp):
619 """
620 A comparision operator that can be used in a :class:`Comparison` expression.
621 """
623 #: Any space that appears directly before this operator.
624 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
626 #: Any space that appears directly after this operator.
627 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
629 def _get_token(self) -> str:
630 return ">"
633@add_slots
634@dataclass(frozen=True)
635class Equal(BaseCompOp, _BaseOneTokenOp):
636 """
637 A comparision operator that can be used in a :class:`Comparison` expression.
638 """
640 #: Any space that appears directly before this operator.
641 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
643 #: Any space that appears directly after this operator.
644 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
646 def _get_token(self) -> str:
647 return "=="
650@add_slots
651@dataclass(frozen=True)
652class LessThanEqual(BaseCompOp, _BaseOneTokenOp):
653 """
654 A comparision operator that can be used in a :class:`Comparison` expression.
655 """
657 #: Any space that appears directly before this operator.
658 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
660 #: Any space that appears directly after this operator.
661 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
663 def _get_token(self) -> str:
664 return "<="
667@add_slots
668@dataclass(frozen=True)
669class GreaterThanEqual(BaseCompOp, _BaseOneTokenOp):
670 """
671 A comparision operator that can be used in a :class:`Comparison` expression.
672 """
674 #: Any space that appears directly before this operator.
675 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
677 #: Any space that appears directly after this operator.
678 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
680 def _get_token(self) -> str:
681 return ">="
684@add_slots
685@dataclass(frozen=True)
686class NotEqual(BaseCompOp, _BaseOneTokenOp):
687 """
688 A comparison operator that can be used in a :class:`Comparison` expression.
690 This node defines a static value for convenience, but in reality due to
691 PEP 401 it can be one of two values, both of which should be a
692 :class:`NotEqual` :class:`Comparison` operator.
693 """
695 #: The actual text value of this operator. Can be either ``!=`` or ``<>``.
696 value: str = "!="
698 #: Any space that appears directly before this operator.
699 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
701 #: Any space that appears directly after this operator.
702 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
704 def _validate(self) -> None:
705 if self.value not in ["!=", "<>"]:
706 raise CSTValidationError("Invalid value for NotEqual node.")
708 def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "NotEqual":
709 return self.__class__(
710 whitespace_before=visit_required(
711 self, "whitespace_before", self.whitespace_before, visitor
712 ),
713 value=self.value,
714 whitespace_after=visit_required(
715 self, "whitespace_after", self.whitespace_after, visitor
716 ),
717 )
719 def _get_token(self) -> str:
720 return self.value
723@add_slots
724@dataclass(frozen=True)
725class In(BaseCompOp, _BaseOneTokenOp):
726 """
727 A comparision operator that can be used in a :class:`Comparison` expression.
728 """
730 #: Any space that appears directly before this operator.
731 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
733 #: Any space that appears directly after this operator.
734 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
736 def _get_token(self) -> str:
737 return "in"
740@add_slots
741@dataclass(frozen=True)
742class NotIn(BaseCompOp, _BaseTwoTokenOp):
743 """
744 A comparision operator that can be used in a :class:`Comparison` expression.
746 This operator spans two tokens that must be separated by at least one space,
747 so there is a third whitespace attribute to represent this.
748 """
750 #: Any space that appears directly before this operator.
751 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
753 #: Any space that appears between the ``not`` and ``in`` tokens.
754 whitespace_between: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
756 #: Any space that appears directly after this operator.
757 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
759 def _get_tokens(self) -> Tuple[str, str]:
760 return ("not", "in")
763@add_slots
764@dataclass(frozen=True)
765class Is(BaseCompOp, _BaseOneTokenOp):
766 """
767 A comparision operator that can be used in a :class:`Comparison` expression.
768 """
770 #: Any space that appears directly before this operator.
771 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
773 #: Any space that appears directly after this operator.
774 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
776 def _get_token(self) -> str:
777 return "is"
780@add_slots
781@dataclass(frozen=True)
782class IsNot(BaseCompOp, _BaseTwoTokenOp):
783 """
784 A comparision operator that can be used in a :class:`Comparison` expression.
786 This operator spans two tokens that must be separated by at least one space,
787 so there is a third whitespace attribute to represent this.
788 """
790 #: Any space that appears directly before this operator.
791 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
793 #: Any space that appears between the ``is`` and ``not`` tokens.
794 whitespace_between: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
796 #: Any space that appears directly after this operator.
797 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
799 def _get_tokens(self) -> Tuple[str, str]:
800 return ("is", "not")
803@add_slots
804@dataclass(frozen=True)
805class AddAssign(BaseAugOp, _BaseOneTokenOp):
806 """
807 An augmented assignment operator that can be used in a :class:`AugAssign`
808 statement.
809 """
811 #: Any space that appears directly before this operator.
812 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
814 #: Any space that appears directly after this operator.
815 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
817 def _get_token(self) -> str:
818 return "+="
821@add_slots
822@dataclass(frozen=True)
823class SubtractAssign(BaseAugOp, _BaseOneTokenOp):
824 """
825 An augmented assignment operator that can be used in a :class:`AugAssign`
826 statement.
827 """
829 #: Any space that appears directly before this operator.
830 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
832 #: Any space that appears directly after this operator.
833 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
835 def _get_token(self) -> str:
836 return "-="
839@add_slots
840@dataclass(frozen=True)
841class MultiplyAssign(BaseAugOp, _BaseOneTokenOp):
842 """
843 An augmented assignment operator that can be used in a :class:`AugAssign`
844 statement.
845 """
847 #: Any space that appears directly before this operator.
848 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
850 #: Any space that appears directly after this operator.
851 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
853 def _get_token(self) -> str:
854 return "*="
857@add_slots
858@dataclass(frozen=True)
859class MatrixMultiplyAssign(BaseAugOp, _BaseOneTokenOp):
860 """
861 An augmented assignment operator that can be used in a :class:`AugAssign`
862 statement.
863 """
865 #: Any space that appears directly before this operator.
866 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
868 #: Any space that appears directly after this operator.
869 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
871 def _get_token(self) -> str:
872 return "@="
875@add_slots
876@dataclass(frozen=True)
877class DivideAssign(BaseAugOp, _BaseOneTokenOp):
878 """
879 An augmented assignment operator that can be used in a :class:`AugAssign`
880 statement.
881 """
883 #: Any space that appears directly before this operator.
884 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
886 #: Any space that appears directly after this operator.
887 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
889 def _get_token(self) -> str:
890 return "/="
893@add_slots
894@dataclass(frozen=True)
895class ModuloAssign(BaseAugOp, _BaseOneTokenOp):
896 """
897 An augmented assignment operator that can be used in a :class:`AugAssign`
898 statement.
899 """
901 #: Any space that appears directly before this operator.
902 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
904 #: Any space that appears directly after this operator.
905 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
907 def _get_token(self) -> str:
908 return "%="
911@add_slots
912@dataclass(frozen=True)
913class BitAndAssign(BaseAugOp, _BaseOneTokenOp):
914 """
915 An augmented assignment operator that can be used in a :class:`AugAssign`
916 statement.
917 """
919 #: Any space that appears directly before this operator.
920 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
922 #: Any space that appears directly after this operator.
923 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
925 def _get_token(self) -> str:
926 return "&="
929@add_slots
930@dataclass(frozen=True)
931class BitOrAssign(BaseAugOp, _BaseOneTokenOp):
932 """
933 An augmented assignment operator that can be used in a :class:`AugAssign`
934 statement.
935 """
937 #: Any space that appears directly before this operator.
938 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
940 #: Any space that appears directly after this operator.
941 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
943 def _get_token(self) -> str:
944 return "|="
947@add_slots
948@dataclass(frozen=True)
949class BitXorAssign(BaseAugOp, _BaseOneTokenOp):
950 """
951 An augmented assignment operator that can be used in a :class:`AugAssign`
952 statement.
953 """
955 #: Any space that appears directly before this operator.
956 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
958 #: Any space that appears directly after this operator.
959 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
961 def _get_token(self) -> str:
962 return "^="
965@add_slots
966@dataclass(frozen=True)
967class LeftShiftAssign(BaseAugOp, _BaseOneTokenOp):
968 """
969 An augmented assignment operator that can be used in a :class:`AugAssign`
970 statement.
971 """
973 #: Any space that appears directly before this operator.
974 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
976 #: Any space that appears directly after this operator.
977 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
979 def _get_token(self) -> str:
980 return "<<="
983@add_slots
984@dataclass(frozen=True)
985class RightShiftAssign(BaseAugOp, _BaseOneTokenOp):
986 """
987 An augmented assignment operator that can be used in a :class:`AugAssign`
988 statement.
989 """
991 #: Any space that appears directly before this operator.
992 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
994 #: Any space that appears directly after this operator.
995 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
997 def _get_token(self) -> str:
998 return ">>="
1001@add_slots
1002@dataclass(frozen=True)
1003class PowerAssign(BaseAugOp, _BaseOneTokenOp):
1004 """
1005 An augmented assignment operator that can be used in a :class:`AugAssign`
1006 statement.
1007 """
1009 #: Any space that appears directly before this operator.
1010 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1012 #: Any space that appears directly after this operator.
1013 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1015 def _get_token(self) -> str:
1016 return "**="
1019@add_slots
1020@dataclass(frozen=True)
1021class FloorDivideAssign(BaseAugOp, _BaseOneTokenOp):
1022 """
1023 An augmented assignment operator that can be used in a :class:`AugAssign`
1024 statement.
1025 """
1027 #: Any space that appears directly before this operator.
1028 whitespace_before: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1030 #: Any space that appears directly after this operator.
1031 whitespace_after: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
1033 def _get_token(self) -> str:
1034 return "//="