-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update mypy to 0.720 #6713
Update mypy to 0.720 #6713
Conversation
@@ -59,9 +59,9 @@ | |||
except ImportError: | |||
# typing's cast() isn't supported in code comments, so we need to | |||
# define a dummy, no-op version. | |||
def cast(typ, val): | |||
def cast(typ, val): # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add ignore
here. (Also, in general I think we should try to avoid adding ignore
if we can because otherwise it defeats the purpose of the typing.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if you need help finding ways to avoid ignore
, feel free to ask.
return val | ||
VersionInfo = None | ||
VersionInfo = None # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could try using the as
workaround used here in PR #6704: https://github.com/pypa/pip/pull/6704/files#diff-f31f8cfd2ff510432f665b48dfe46646R33
# `buf.value` is `unicode`, but methods return type is `str`. | ||
# If we annotate here as unicode, lots of other places should be | ||
# changed / ignored. | ||
return buf.value # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better fix here might be to encode the path to str
using sys.getfilesystemencoding()
. Otherwise, we risk getting exceptions in calling code when trying to combine str
and unicode
if the path has non-ascii characters. As it is now these errors would be hard to prevent by the developer because the type annotation would be showing str
, so a developer looking at it wouldn't know they have to encode it first.
@cjerdonek Could you finish it for me? |
Refs #4748