Skip to content

Commit

Permalink
lazy_isinstance(): use .__class__ for type check (#6974)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk authored May 21, 2021
1 parent 29c942f commit 81bdfb8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python-package/xgboost/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 81bdfb8

Please sign in to comment.