You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python allows you to create new classes using the three-argument form of the type() builtin. I can't tell if it's a mypy-zope problem or a mypy problem, but this doesn't typecheck properly:
In this example NormalClass and DynamicClass are equivalent (except for their names and the initial value of x). At runtime they behave similarly and the classImplements() calls do what you'd think. Mypy however produces this error:
error: dyntest.DynamicClass is not a class, cannot mark it as a interface implementation [misc]
The text was updated successfully, but these errors were encountered:
I get a similar issue when I try to pass in the class of an instance with .__class__. I use that in an adapter to mark classes I don't control as having an interface and verifying it afterwards. I already tried these variants on a wrapper function:
T = TypeVar("T")
def get_class(obj: T) -> Type[T]:
return obj.__class__
Python allows you to create new classes using the three-argument form of the
type()
builtin. I can't tell if it's a mypy-zope problem or a mypy problem, but this doesn't typecheck properly:In this example
NormalClass
andDynamicClass
are equivalent (except for their names and the initial value ofx
). At runtime they behave similarly and theclassImplements()
calls do what you'd think. Mypy however produces this error:The text was updated successfully, but these errors were encountered: