lazy_isinstance(): use .__class__ for type check (#6974)

This commit is contained in:
Mads R. B. Kristensen 2021-05-21 05:33:08 +02:00 committed by GitHub
parent 29c942f2a8
commit 81bdfb835d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,9 +20,13 @@ def py_str(x):
def lazy_isinstance(instance, module, name):
'''Use string representation to identify a type.'''
module = type(instance).__module__ == module
name = type(instance).__name__ == name
"""Use string representation to identify a type."""
# Notice, we use .__class__ as opposed to type() in order
# to support object proxies such as weakref.proxy
cls = instance.__class__
module = cls.__module__ == module
name = cls.__name__ == name
return module and name