(self, n: ast3.Constant)
| 2039 | ) |
| 2040 | |
| 2041 | def visit_Constant(self, n: ast3.Constant) -> Type: |
| 2042 | val = n.value |
| 2043 | if val is None: |
| 2044 | # None is a type. |
| 2045 | return UnboundType("None", line=self.line) |
| 2046 | if isinstance(val, str): |
| 2047 | # Parse forward reference. |
| 2048 | return parse_type_string(val, "builtins.str", self.line, n.col_offset) |
| 2049 | if val is Ellipsis: |
| 2050 | # '...' is valid in some types. |
| 2051 | return EllipsisType(line=self.line) |
| 2052 | if isinstance(val, bool): |
| 2053 | # Special case for True/False. |
| 2054 | return RawExpressionType(val, "builtins.bool", line=self.line) |
| 2055 | if isinstance(val, (int, float, complex)): |
| 2056 | return self.numeric_type(val, n) |
| 2057 | if isinstance(val, bytes): |
| 2058 | contents = bytes_to_human_readable_repr(val) |
| 2059 | return RawExpressionType(contents, "builtins.bytes", self.line, column=n.col_offset) |
| 2060 | # Everything else is invalid. |
| 2061 | |
| 2062 | # UnaryOp(op, operand) |
| 2063 | def visit_UnaryOp(self, n: UnaryOp) -> Type: |
nothing calls this directly
no test coverage detected