H
Size: a a a
H
БГ
from typing import Callable
def override(method):
func_name = method.__name__
bound_class = method.__objclass__
mro = bound_class.__mro__
attrs = (getattr(obj, func_name, None) for obj in mro)
is_func = (isinstance(attr, Callable) for attr in attrs)
if any(is_func):
return method
else:
raise TyMneNapizdelErrorБГ
БГ
<Ч
bound_class = method.__objclass__
AttributeError: 'function' object has no attribute '__objclass__'БГ
БГ
<Ч
БГ

БГ
БГ
БГ
def get_class_that_defined_method(meth):
if inspect.isfunction(meth):
return getattr(inspect.getmodule(meth), meth.__qualname__.split('.<locals>', 1)[0].rsplit('.', 1)[0], None)
return None
БГ
БГ
<Ч
<Ч
БГ
БГ
БГ