From 1bd89038159b20c21793c6f9367ded2023a922e9 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Mon, 18 May 2020 03:11:19 +0530 Subject: [PATCH 1/5] Type annotations for pip._internal.models.format_control --- src/pip/_internal/models/format_control.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pip/_internal/models/format_control.py b/src/pip/_internal/models/format_control.py index 2e13727ca00..c39b84a84b5 100644 --- a/src/pip/_internal/models/format_control.py +++ b/src/pip/_internal/models/format_control.py @@ -1,6 +1,3 @@ -# The following comment should be removed at some point in the future. -# mypy: strict-optional=False - from pip._vendor.packaging.utils import canonicalize_name from pip._internal.exceptions import CommandError @@ -42,7 +39,7 @@ def __repr__(self): @staticmethod def handle_mutual_excludes(value, target, other): - # type: (str, Optional[Set[str]], Optional[Set[str]]) -> None + # type: (str, Set[str], Set[str]) -> None if value.startswith('-'): raise CommandError( "--no-binary / --only-binary option requires 1 argument." From e572d9e0c9bfe160957e17cd3fe150c19d2e73c6 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Mon, 18 May 2020 03:11:35 +0530 Subject: [PATCH 2/5] Type annotations for pip._internal.network.cache --- src/pip/_internal/network/cache.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pip/_internal/network/cache.py b/src/pip/_internal/network/cache.py index c9386e17360..a0d55b5e992 100644 --- a/src/pip/_internal/network/cache.py +++ b/src/pip/_internal/network/cache.py @@ -1,9 +1,6 @@ """HTTP cache implementation. """ -# The following comment should be removed at some point in the future. -# mypy: disallow-untyped-defs=False - import os from contextlib import contextmanager @@ -16,7 +13,7 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: - from typing import Optional + from typing import Optional, Iterator def is_from_cache(response): @@ -26,6 +23,7 @@ def is_from_cache(response): @contextmanager def suppressed_cache_errors(): + # type: () -> Iterator[None] """If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. """ From fdc062475ed34b41f71b53fa9eb28eba26c92fef Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Mon, 18 May 2020 03:11:44 +0530 Subject: [PATCH 3/5] Type annotations for pip._internal.network.xmlrpc --- src/pip/_internal/network/xmlrpc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pip/_internal/network/xmlrpc.py b/src/pip/_internal/network/xmlrpc.py index 121edd93056..8e360cc0f74 100644 --- a/src/pip/_internal/network/xmlrpc.py +++ b/src/pip/_internal/network/xmlrpc.py @@ -1,9 +1,6 @@ """xmlrpclib.Transport implementation """ -# The following comment should be removed at some point in the future. -# mypy: disallow-untyped-defs=False - import logging from pip._vendor import requests @@ -12,6 +9,12 @@ from pip._vendor.six.moves import xmlrpc_client # type: ignore from pip._vendor.six.moves.urllib import parse as urllib_parse +from pip._internal.utils.typing import MYPY_CHECK_RUNNING + +if MYPY_CHECK_RUNNING: + from typing import Optional, Dict + from pip._internal.network.session import PipSession + logger = logging.getLogger(__name__) @@ -21,12 +24,14 @@ class PipXmlrpcTransport(xmlrpc_client.Transport): """ def __init__(self, index_url, session, use_datetime=False): + # type: (str, PipSession, Optional[bool]) -> None xmlrpc_client.Transport.__init__(self, use_datetime) index_parts = urllib_parse.urlparse(index_url) self._scheme = index_parts.scheme self._session = session def request(self, host, handler, request_body, verbose=False): + # type: (str, str, Dict[str, str], Optional[bool]) -> None parts = (self._scheme, host, handler, None, None, None) url = urllib_parse.urlunparse(parts) try: From 2fe5d84d68ac656f1f3d35f3d2f4aedb75c4ade5 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Tue, 19 May 2020 22:16:10 +0530 Subject: [PATCH 4/5] Add news file --- news/99C26CF6-C60A-4ECD-8ED9-426918DCA4ED.trivial | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 news/99C26CF6-C60A-4ECD-8ED9-426918DCA4ED.trivial diff --git a/news/99C26CF6-C60A-4ECD-8ED9-426918DCA4ED.trivial b/news/99C26CF6-C60A-4ECD-8ED9-426918DCA4ED.trivial new file mode 100644 index 00000000000..e69de29bb2d From 65a6152f024de93c91a152847faee925f73c050a Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Wed, 20 May 2020 12:40:05 +0530 Subject: [PATCH 5/5] Remove Optional type from xmlrpc bool parameters --- src/pip/_internal/network/xmlrpc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pip/_internal/network/xmlrpc.py b/src/pip/_internal/network/xmlrpc.py index 8e360cc0f74..beab4fcfa7a 100644 --- a/src/pip/_internal/network/xmlrpc.py +++ b/src/pip/_internal/network/xmlrpc.py @@ -12,7 +12,7 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: - from typing import Optional, Dict + from typing import Dict from pip._internal.network.session import PipSession logger = logging.getLogger(__name__) @@ -24,14 +24,14 @@ class PipXmlrpcTransport(xmlrpc_client.Transport): """ def __init__(self, index_url, session, use_datetime=False): - # type: (str, PipSession, Optional[bool]) -> None + # type: (str, PipSession, bool) -> None xmlrpc_client.Transport.__init__(self, use_datetime) index_parts = urllib_parse.urlparse(index_url) self._scheme = index_parts.scheme self._session = session def request(self, host, handler, request_body, verbose=False): - # type: (str, str, Dict[str, str], Optional[bool]) -> None + # type: (str, str, Dict[str, str], bool) -> None parts = (self._scheme, host, handler, None, None, None) url = urllib_parse.urlunparse(parts) try: