MCPcopy Index your code
hub / github.com/python/mypy / lookup_definer

Method lookup_definer

mypy/checkexpr.py:4097–4111  ·  view source on GitHub ↗

Returns the name of the class that contains the actual definition of attr_name. So if class A defines foo and class B subclasses A, running `get_class_defined_in(B, "foo")` would return the full name of A. However, if B were to override and redefine foo, that method call wo

(self, typ: Instance, attr_name: str)

Source from the content-addressed store, hash-verified

4095 return None if w.has_new_errors() else member
4096
4097 def lookup_definer(self, typ: Instance, attr_name: str) -> str | None:
4098 """Returns the name of the class that contains the actual definition of attr_name.
4099
4100 So if class A defines foo and class B subclasses A, running
4101 `get_class_defined_in(B, "foo")` would return the full name of A.
4102
4103 However, if B were to override and redefine foo, that method call would
4104 return the full name of B instead.
4105
4106 If the attr name is not present in the given class or its MRO, returns None.
4107 """
4108 for cls in typ.type.mro:
4109 if cls.names.get(attr_name):
4110 return cls.fullname
4111 return None
4112
4113 def check_op_reversible(
4114 self,

Callers 1

check_op_reversibleMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected