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

Method get_method

mypy/nodes.py:4008–4024  ·  view source on GitHub ↗
(self, name: str)

Source from the content-addressed store, hash-verified

4006 return self.get(name) is not None
4007
4008 def get_method(self, name: str) -> FuncBase | Decorator | None:
4009 for cls in self.mro:
4010 if name in cls.names:
4011 node = cls.names[name].node
4012 elif possible_redefinitions := sorted(
4013 [n for n in cls.names.keys() if n.startswith(f"{name}-redefinition")]
4014 ):
4015 node = cls.names[possible_redefinitions[-1]].node
4016 else:
4017 continue
4018 if isinstance(node, SYMBOL_FUNCBASE_TYPES):
4019 return node
4020 elif isinstance(node, Decorator): # Two `if`s make `mypyc` happy
4021 return node
4022 else:
4023 return None
4024 return None
4025
4026 def calculate_metaclass_type(self) -> mypy.types.Instance | None:
4027 declared = self.declared_metaclass

Callers 15

partition_by_callableMethod · 0.45
is_untyped_decoratorFunction · 0.45
find_nodeFunction · 0.45
_arg_accepts_functionFunction · 0.45
find_memberFunction · 0.45
find_member_simpleFunction · 0.45
get_member_flagsFunction · 0.45

Calls 4

sortedFunction · 0.85
isinstanceFunction · 0.85
keysMethod · 0.80
startswithMethod · 0.45

Tested by

no test coverage detected