Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/pip/_internal/utils/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ def _get_win_folder_with_ctypes(csidl_name):
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
buf = buf2

return buf.value
# `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
Copy link
Member

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.



if WINDOWS:
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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.)

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



__all__ = ['rmtree', 'display_path', 'backup_dir',
Expand Down
2 changes: 1 addition & 1 deletion tools/mypy-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mypy == 0.670
mypy == 0.720