-
Notifications
You must be signed in to change notification settings - Fork 76
Mypy error: Variable "Email" is not valid as a type mypy(error) #50
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
Comments
Correct me if I'm wrong, but don't think this is related to Your code can be reduced to the following, that mypy also rejects: from typing import Type
Email: Type[str] = str
class MySchema:
email: Email This also gives: |
I opened an issue at mypy, and they do not seem to be keen on implementing anything that would allow us make I am going to leave this issue open, and if anyone is interested in writing a mypy plugin, we'll track progress here. |
from typing import NewType
Email = NewType("Email", str)
class MySchema:
email: Email Instead of returning a function maybe A) Return a B) Construct and return a new Field Class. |
This is not possible. The logic for
This wouldn't work with the rest of class MySchema:
email: Email |
@tomdottom : Would you be interested in writing a mypy plugin ? |
I'd like for this to get fixed as well. |
Taking the example from the readme:
When using Email in a schema, for instance:
I'm getting this error from mypy:
Mypy error: Variable "Email" is not valid as a type mypy(error)
versions:
Thanks in advance.
The text was updated successfully, but these errors were encountered: