Skip to content

Commit

Permalink
Upgrade to mypy 0.720 (#6808)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Jul 30, 2019
2 parents a28ba64 + 2a5c23b commit 800f866
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/pip/_internal/pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

if MYPY_CHECK_RUNNING:
from typing import (
Tuple, Callable, List, Optional, Union, Dict
Tuple, Callable, List, Optional, Union, Dict, Set
)

Pep425Tag = Tuple[str, str, str]
Expand Down Expand Up @@ -105,6 +105,8 @@ def get_abi_tag():
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
abi = None # type: Optional[str]

if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
d = ''
m = ''
Expand All @@ -129,8 +131,7 @@ def get_abi_tag():
abi = 'cp' + soabi.split('-')[1]
elif soabi:
abi = soabi.replace('.', '_').replace('-', '_')
else:
abi = None

return abi


Expand Down Expand Up @@ -310,7 +311,7 @@ def get_supported(
if abi:
abis[0:0] = [abi]

abi3s = set()
abi3s = set() # type: Set[str]
for suffix in get_extension_suffixes():
if suffix.startswith('.abi'):
abi3s.add(suffix.split('.', 2)[1])
Expand Down
5 changes: 4 additions & 1 deletion src/pip/_internal/utils/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def _get_win_folder_from_registry(csidl_name):

def _get_win_folder_with_ctypes(csidl_name):
# type: (str) -> str
# On Python 2, ctypes.create_unicode_buffer().value returns "unicode",
# which isn't the same as str in the annotation above.
csidl_const = {
"CSIDL_APPDATA": 26,
"CSIDL_COMMON_APPDATA": 35,
Expand All @@ -239,7 +241,8 @@ def _get_win_folder_with_ctypes(csidl_name):
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
buf = buf2

return buf.value
# The type: ignore is explained under the type annotation for this function
return buf.value # type: ignore


if WINDOWS:
Expand Down
17 changes: 7 additions & 10 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,18 @@
if MYPY_CHECK_RUNNING:
from typing import (
Any, AnyStr, Container, Iterable, List, Mapping, Match, Optional, Text,
Union,
Tuple, Union, cast,
)
from pip._vendor.pkg_resources import Distribution
from pip._internal.models.link import Link
from pip._internal.utils.ui import SpinnerInterface

try:
from typing import cast, Tuple
VersionInfo = Tuple[int, int, int]
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):
return val
VersionInfo = None
else:
# typing's cast() is needed at runtime, but we don't want to import typing.
# Thus, we use a dummy no-op version, which we tell mypy to ignore.
def cast(type_, value): # type: ignore
return value


__all__ = ['rmtree', 'display_path', 'backup_dir',
Expand Down Expand Up @@ -140,7 +137,7 @@ def normalize_version_info(py_version_info):
elif len(py_version_info) > 3:
py_version_info = py_version_info[:3]

return cast(VersionInfo, py_version_info)
return cast('VersionInfo', py_version_info)


def ensure_dir(path):
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

0 comments on commit 800f866

Please sign in to comment.