-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isinstance(x, Type) not accepted #3060
Comments
I almost fixed it inside #3070, but then I realized that the required change to What else can we do? Map |
Yeah, that would be equivalent to making the type |
I guess a narrow fix could be to redefine We would still have to add some code elsewhere to make @JukkaL example pass, since at present |
Is this about mypy or runtime? Making the behaviors of isinstance()/issubclass() match between static checks and runtime can be tricky. |
I think mypy. It seems Python runtime returns |
On current master the error is even worse:
|
…#808) * Add support for Type[T] typehints when arbitrary_types_allowe==True. * Add documentation. * Let black do its magic. * Ignore mypy warning - see here: python/mypy#3060 * Prettify docs. * Change Changelog. * Refactor and simplify check for Type[T]. * Black again. ^^ - Really need pre-commit hooks. * Update pydantic/validators.py Co-Authored-By: Samuel Colvin <samcolvin@gmail.com> * Rename arbitrary_class to class. * Black. * Add type hints. * Make private function public. * Add support for bare Type. * Black again. * Update docs. * CO_ct not meant for export. * Fix get_class for Python3.6 * Update error message of ClassError. * Use relative import. * Incorporate typing feedback (both versions are fine with mypy). * Move from issubclass to lenient_issubclass. * correct docs
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
isinstance(x, Type)
generates in an error, even though it should probably be considered equivalent toisinstance(x, type)
. Example:The text was updated successfully, but these errors were encountered: