-
-
Notifications
You must be signed in to change notification settings - Fork 242
Open
Description
Not sure if this is an issue with wrapt or abc. The following code will raise a TypeError: issubclass() arg 1 must be a class instead of printing True as I would expect:
import wrapt
import abc
class Base(abc.ABC):
pass
@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
@pass_through
class Klass(Base):
pass
print(issubclass(Klass, Base))
Apparently, abc.ABC replaces the subclasscheck with its own special subclasscheck, which in turn raises the exception. Unfortunately, that subclasscheck is some internal function that I cannot debug. The last arguments for this internal subclasscheck that the debugger can see are <class '__main__.Base'> and <class '__main__.Klass'>, which looks fine to me.
The example above can be simplified even further to
import wrapt
import abc
@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
@pass_through
class Klass(abc.ABC):
pass
print(issubclass(Klass, abc.ABC))
but I chose the first example because it demonstrates better what I want to achieve.
Metadata
Metadata
Assignees
Labels
No labels