From 22fe45d4622ab33575fb44ec7bf4479905c8cdaf Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Tue, 18 Dec 2018 11:16:22 +0530 Subject: [PATCH] Fix new issues found in mypy 0.620 -> 0.650 --- src/pip/_internal/exceptions.py | 4 ++-- src/pip/_internal/locations.py | 8 +++++--- src/pip/_internal/req/constructors.py | 6 +++--- src/pip/_internal/req/req_file.py | 2 +- src/pip/_internal/req/req_install.py | 4 ++-- src/pip/_internal/utils/compat.py | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py index 7b291a1e4..38ceeea92 100644 --- a/src/pip/_internal/exceptions.py +++ b/src/pip/_internal/exceptions.py @@ -8,8 +8,8 @@ from pip._vendor.six import iteritems from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: - from typing import Optional - from pip._internal.req.req_install import InstallRequirement + from typing import Optional # noqa: F401 + from pip._internal.req.req_install import InstallRequirement # noqa: F401 class PipError(Exception): diff --git a/src/pip/_internal/locations.py b/src/pip/_internal/locations.py index 89a3656b2..c6e2a3e48 100644 --- a/src/pip/_internal/locations.py +++ b/src/pip/_internal/locations.py @@ -15,7 +15,7 @@ from pip._internal.utils.compat import WINDOWS, expanduser from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: - from typing import Union, Dict, List, Optional # noqa: F401 + from typing import Any, Union, Dict, List, Optional # noqa: F401 # Application Directories @@ -163,8 +163,10 @@ def distutils_scheme(dist_name, user=False, home=None, root=None, d = Distribution(dist_args) # Ignoring, typeshed issue reported python/typeshed/issues/2567 - d.parse_config_files() # type: ignore - i = d.get_command_obj('install', create=True) # type: ignore + d.parse_config_files() + # NOTE: Ignoring type since mypy can't find attributes on 'Command' + i = d.get_command_obj('install', create=True) # type: Any + assert i is not None # NOTE: setting user or home has the side-effect of creating the home dir # or user base for installations during finalize_options() # ideally, we'd prefer a scheme class that has no side-effects. diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index c26c1ed28..755c10d57 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -31,7 +31,7 @@ from pip._internal.wheel import Wheel if MYPY_CHECK_RUNNING: from typing import ( # noqa: F401 - Optional, Tuple, Set, Any, Mapping, Union, Text + Optional, Tuple, Set, Any, Union, Text, Dict, ) from pip._internal.cache import WheelCache # noqa: F401 @@ -160,7 +160,7 @@ def install_req_from_editable( comes_from=None, # type: Optional[str] use_pep517=None, # type: Optional[bool] isolated=False, # type: bool - options=None, # type: Optional[Mapping[Text, Any]] + options=None, # type: Optional[Dict[str, Any]] wheel_cache=None, # type: Optional[WheelCache] constraint=False # type: bool ): @@ -196,7 +196,7 @@ def install_req_from_line( comes_from=None, # type: Optional[Union[str, InstallRequirement]] use_pep517=None, # type: Optional[bool] isolated=False, # type: bool - options=None, # type: Optional[Mapping[Text, Any]] + options=None, # type: Optional[Dict[str, Any]] wheel_cache=None, # type: Optional[WheelCache] constraint=False # type: bool ): diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index 50976e1c5..fd9b2b45c 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -68,7 +68,7 @@ SUPPORTED_OPTIONS_REQ = [ ] # type: List[Callable[..., optparse.Option]] # the 'dest' string values -SUPPORTED_OPTIONS_REQ_DEST = [o().dest for o in SUPPORTED_OPTIONS_REQ] +SUPPORTED_OPTIONS_REQ_DEST = [str(o().dest) for o in SUPPORTED_OPTIONS_REQ] def parse_requirements( diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index fa2ad8bf7..1854e5212 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -42,7 +42,7 @@ from pip._internal.wheel import move_wheel_files if MYPY_CHECK_RUNNING: from typing import ( # noqa: F401 - Optional, Iterable, List, Union, Any, Mapping, Text, Sequence + Optional, Iterable, List, Union, Any, Text, Sequence, Dict ) from pip._internal.build_env import BuildEnvironment # noqa: F401 from pip._internal.cache import WheelCache # noqa: F401 @@ -73,7 +73,7 @@ class InstallRequirement(object): markers=None, # type: Optional[Marker] use_pep517=None, # type: Optional[bool] isolated=False, # type: bool - options=None, # type: Optional[Mapping[Text, Any]] + options=None, # type: Optional[Dict[str, Any]] wheel_cache=None, # type: Optional[WheelCache] constraint=False, # type: bool extras=() # type: Iterable[str] diff --git a/src/pip/_internal/utils/compat.py b/src/pip/_internal/utils/compat.py index 2ae27fd13..2d8b3bf06 100644 --- a/src/pip/_internal/utils/compat.py +++ b/src/pip/_internal/utils/compat.py @@ -23,8 +23,8 @@ except ImportError: from pip._vendor import ipaddress # type: ignore except ImportError: import ipaddr as ipaddress # type: ignore - ipaddress.ip_address = ipaddress.IPAddress - ipaddress.ip_network = ipaddress.IPNetwork + ipaddress.ip_address = ipaddress.IPAddress # type: ignore + ipaddress.ip_network = ipaddress.IPNetwork # type: ignore __all__ = [