MCPcopy Create free account
hub / github.com/python/mypy / is_definition

Method is_definition

mypy/checker.py:4566–4580  ·  view source on GitHub ↗
(self, s: Lvalue)

Source from the content-addressed store, hash-verified

4564 return lvalue_type, index_lvalue, inferred
4565
4566 def is_definition(self, s: Lvalue) -> bool:
4567 if isinstance(s, NameExpr):
4568 if s.is_inferred_def:
4569 return True
4570 # If the node type is not defined, this must the first assignment
4571 # that we process => this is a definition, even though the semantic
4572 # analyzer did not recognize this as such. This can arise in code
4573 # that uses isinstance checks, if type checking of the primary
4574 # definition is skipped due to an always False type check.
4575 node = s.node
4576 if isinstance(node, Var):
4577 return node.type is None
4578 elif isinstance(s, MemberExpr):
4579 return s.is_inferred_def
4580 return False
4581
4582 def infer_variable_type(
4583 self, name: Var, lvalue: Lvalue, init_type: Type, context: Context

Callers 1

check_lvalueMethod · 0.95

Calls 1

isinstanceFunction · 0.85

Tested by

no test coverage detected