(self, n: UnaryOp)
| 2061 | |
| 2062 | # UnaryOp(op, operand) |
| 2063 | def visit_UnaryOp(self, n: UnaryOp) -> Type: |
| 2064 | # We support specifically Literal[-4], Literal[+4], and nothing else. |
| 2065 | # For example, Literal[~6] or Literal[not False] is not supported. |
| 2066 | typ = self.visit(n.operand) |
| 2067 | if ( |
| 2068 | isinstance(typ, RawExpressionType) |
| 2069 | # Use type() because we do not want to allow bools. |
| 2070 | and type(typ.literal_value) is int |
| 2071 | ): |
| 2072 | if isinstance(n.op, USub): |
| 2073 | typ.literal_value *= -1 |
| 2074 | return typ |
| 2075 | if isinstance(n.op, UAdd): |
| 2076 | return typ |
| 2077 | return self.invalid_type(n) |
| 2078 | |
| 2079 | def numeric_type(self, value: object, n: AST) -> Type: |
| 2080 | # The node's field has the type complex, but complex isn't *really* |
nothing calls this directly
no test coverage detected