Naming consumers that are classmethods (#324)

This commit is contained in:
Krukov D 2016-08-29 20:37:09 +03:00 committed by Andrew Godwin
parent 7de6ff17d6
commit b62ea7dd0a

View File

@ -13,9 +13,11 @@ def name_that_thing(thing):
return name_that_thing(thing.im_class) + "." + thing.im_func.func_name
# Other named thing
if hasattr(thing, "__name__"):
if hasattr(thing, "__class__") and not isinstance(thing, types.FunctionType):
if hasattr(thing, "__class__") and not isinstance(thing, (types.FunctionType, types.MethodType)):
if thing.__class__ is not type:
return name_that_thing(thing.__class__)
if hasattr(thing, "__self__"):
return "%s.%s" % (thing.__self__.__module__, thing.__self__.__name__)
if hasattr(thing, "__module__"):
return "%s.%s" % (thing.__module__, thing.__name__)
# Generic instance of a class