-
Notifications
You must be signed in to change notification settings - Fork 21
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
"User defined generic does not accept provided constraints" error when 'Type' is used in hint #68
Comments
Note that this can be even reduced down to @runtime_validation
def foo(self, arg: Type[T]) -> T:
return arg() Apparently that's the |
Is this happening in the dev branch as well? It might be related to the fact that |
If it is actually a problem with |
TypeVar
type hints inside non-Generic classes
Please note that in early versions of typing.py module the In all of my code to cope with this restriction I always quote try:
from typing import Type
except ImportError:
# normal for old versions of typing
pass Of course in your case you do want to reason about a type hint being the ```python
try:
from typing import Type
except ImportError:
# normal for old versions of typing
class Type:
pass I guess that should do the trick. |
PEP484 allows
TypeVar
to be used anywhere, not necessarily in Generic classes, see this section.However as of today the following fails:
With error:
The text was updated successfully, but these errors were encountered: