Skip to content

Commit

Permalink
Merge pull request #8271 from deveshks/add-mypy-cache-xmlrpc-form_contr
Browse files Browse the repository at this point in the history
Add mypy type annotations to cache, xmlrpc in network and format_control in models module
  • Loading branch information
sbidoul authored May 20, 2020
2 parents 15f0863 + 65a6152 commit 803a6f2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Empty file.
5 changes: 1 addition & 4 deletions src/pip/_internal/models/format_control.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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."
Expand Down
6 changes: 2 additions & 4 deletions src/pip/_internal/network/cache.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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):
Expand All @@ -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.
"""
Expand Down
11 changes: 8 additions & 3 deletions src/pip/_internal/network/xmlrpc.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 Dict
from pip._internal.network.session import PipSession

logger = logging.getLogger(__name__)


Expand All @@ -21,12 +24,14 @@ class PipXmlrpcTransport(xmlrpc_client.Transport):
"""

def __init__(self, index_url, session, use_datetime=False):
# 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], bool) -> None
parts = (self._scheme, host, handler, None, None, None)
url = urllib_parse.urlunparse(parts)
try:
Expand Down

0 comments on commit 803a6f2

Please sign in to comment.