MCPcopy
hub / github.com/python/mypy / invalid_type

Method invalid_type

mypy/fastparse.py:1899–1911  ·  view source on GitHub ↗

Constructs a type representing some expression that normally forms an invalid type. For example, if we see a type hint that says "3 + 4", we would transform that expression into a RawExpressionType. The semantic analysis layer will report an "Invalid type" error when it

(self, node: AST, note: str | None = None)

Source from the content-addressed store, hash-verified

1897 return self.override_column
1898
1899 def invalid_type(self, node: AST, note: str | None = None) -> RawExpressionType:
1900 """Constructs a type representing some expression that normally forms an invalid type.
1901 For example, if we see a type hint that says "3 + 4", we would transform that
1902 expression into a RawExpressionType.
1903
1904 The semantic analysis layer will report an "Invalid type" error when it
1905 encounters this type, along with the given note if one is provided.
1906
1907 See RawExpressionType's docstring for more details on how it's used.
1908 """
1909 return RawExpressionType(
1910 None, "typing.Any", line=self.line, column=getattr(node, "col_offset", -1), note=note
1911 )
1912
1913 @overload
1914 def visit(self, node: ast3.expr) -> ProperType: ...

Callers 8

visitMethod · 0.95
visit_CallMethod · 0.95
visit_BinOpMethod · 0.95
visit_UnaryOpMethod · 0.95
visit_SliceMethod · 0.95
visit_SubscriptMethod · 0.95
visit_DictMethod · 0.95
visit_AttributeMethod · 0.95

Calls 2

RawExpressionTypeClass · 0.90
getattrFunction · 0.85

Tested by

no test coverage detected