mirror of https://github.com/pypa/pip
Fix mypy warnings
This commit is contained in:
parent
9fce241457
commit
8f92b55997
|
@ -52,13 +52,16 @@ from pip._vendor.requests.packages.urllib3.exceptions import (
|
|||
)
|
||||
|
||||
|
||||
if False:
|
||||
from typing import Any
|
||||
|
||||
# assignment for flake8 to be happy
|
||||
|
||||
# This fixes a peculiarity when importing via __import__ - as we are
|
||||
# initialising the pip module, "from pip import cmdoptions" is recursive
|
||||
# and appears not to work properly in that situation.
|
||||
import pip.cmdoptions
|
||||
cmdoptions = pip.cmdoptions
|
||||
import pip.cmdoptions # noqa
|
||||
cmdoptions = pip.cmdoptions # type: Any
|
||||
|
||||
# The version as used in the setup.py and the docs conf.py
|
||||
__version__ = "10.0.0.dev0"
|
||||
|
|
|
@ -27,17 +27,19 @@ from pip.utils import deprecation, get_prog, normalize_path
|
|||
from pip.utils.logging import IndentingFormatter
|
||||
from pip.utils.outdated import pip_version_check
|
||||
|
||||
__all__ = ['Command']
|
||||
if False:
|
||||
from typing import Optional
|
||||
|
||||
__all__ = ['Command']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(object):
|
||||
name = None
|
||||
usage = None
|
||||
hidden = False
|
||||
ignore_require_venv = False
|
||||
name = None # type: Optional[str]
|
||||
usage = None # type: Optional[str]
|
||||
hidden = False # type: bool
|
||||
ignore_require_venv = False # type: bool
|
||||
log_streams = ("ext://sys.stdout", "ext://sys.stderr")
|
||||
|
||||
def __init__(self, isolated=False):
|
||||
|
|
|
@ -17,6 +17,10 @@ from pip.commands.install import InstallCommand
|
|||
from pip.commands.uninstall import UninstallCommand
|
||||
from pip.commands.wheel import WheelCommand
|
||||
|
||||
if False:
|
||||
from typing import List, Type
|
||||
from pip.basecommand import Command
|
||||
|
||||
commands_order = [
|
||||
InstallCommand,
|
||||
DownloadCommand,
|
||||
|
@ -31,7 +35,7 @@ commands_order = [
|
|||
HashCommand,
|
||||
CompletionCommand,
|
||||
HelpCommand,
|
||||
]
|
||||
] # type: List[Type[Command]]
|
||||
|
||||
commands_dict = {c.name: c for c in commands_order}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ from pip.utils.packaging import get_installer
|
|||
try:
|
||||
from itertools import zip_longest
|
||||
except ImportError:
|
||||
from itertools import izip_longest as zip_longest
|
||||
from itertools import izip_longest as zip_longest # type: ignore
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -14,9 +14,9 @@ try:
|
|||
import ipaddress
|
||||
except ImportError:
|
||||
try:
|
||||
from pip._vendor import ipaddress
|
||||
from pip._vendor import ipaddress # type: ignore
|
||||
except ImportError:
|
||||
import ipaddr as ipaddress
|
||||
import ipaddr as ipaddress # type: ignore
|
||||
ipaddress.ip_address = ipaddress.IPAddress
|
||||
ipaddress.ip_network = ipaddress.IPNetwork
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@ import site
|
|||
import sys
|
||||
import sysconfig
|
||||
from distutils import sysconfig as distutils_sysconfig
|
||||
from distutils.command.install import SCHEME_KEYS, install # noqa
|
||||
from distutils.command.install import SCHEME_KEYS, install # type: ignore
|
||||
|
||||
from pip.compat import WINDOWS, expanduser
|
||||
from pip.utils import appdirs
|
||||
|
||||
|
||||
# Application Directories
|
||||
USER_CACHE_DIR = appdirs.user_cache_dir("pip")
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ from __future__ import absolute_import
|
|||
import logging
|
||||
import warnings
|
||||
|
||||
if False:
|
||||
from typing import Any
|
||||
|
||||
|
||||
class PipDeprecationWarning(Warning):
|
||||
pass
|
||||
|
@ -26,7 +29,7 @@ class RemovedInPip12Warning(PipDeprecationWarning, Pending):
|
|||
# Warnings <-> Logging Integration
|
||||
|
||||
|
||||
_warnings_showwarning = None
|
||||
_warnings_showwarning = None # type: Any
|
||||
|
||||
|
||||
def _showwarning(message, category, filename, lineno, file=None, line=None):
|
||||
|
|
|
@ -11,7 +11,7 @@ from pip.utils import ensure_dir
|
|||
try:
|
||||
import threading
|
||||
except ImportError:
|
||||
import dummy_threading as threading
|
||||
import dummy_threading as threading # type: ignore
|
||||
|
||||
|
||||
try:
|
||||
|
|
|
@ -19,6 +19,9 @@ from pip.compat import WINDOWS
|
|||
from pip.utils import format_size
|
||||
from pip.utils.logging import get_indentation
|
||||
|
||||
if False:
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from pip._vendor import colorama
|
||||
# Lots of different errors can come from this, including SystemError and
|
||||
|
@ -56,7 +59,7 @@ def _select_progress_class(preferred, fallback):
|
|||
return preferred
|
||||
|
||||
|
||||
_BaseBar = _select_progress_class(IncrementalBar, Bar)
|
||||
_BaseBar = _select_progress_class(IncrementalBar, Bar) # type: Any
|
||||
|
||||
|
||||
class InterruptibleMixin(object):
|
||||
|
@ -125,7 +128,7 @@ class BlueEmojiBar(IncrementalBar):
|
|||
suffix = "%(percent)d%%"
|
||||
bar_prefix = " "
|
||||
bar_suffix = " "
|
||||
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535")
|
||||
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535") # type: Any
|
||||
|
||||
|
||||
class DownloadProgressMixin(object):
|
||||
|
|
|
@ -14,6 +14,11 @@ from pip.utils import (display_path, backup_dir, call_subprocess,
|
|||
rmtree, ask_path_exists)
|
||||
|
||||
|
||||
if False:
|
||||
from typing import Dict, Tuple
|
||||
from pip.basecommand import Command
|
||||
|
||||
|
||||
__all__ = ['vcs', 'get_src_requirement']
|
||||
|
||||
|
||||
|
@ -21,7 +26,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class VcsSupport(object):
|
||||
_registry = {}
|
||||
_registry = {} # type: Dict[str, Command]
|
||||
schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn']
|
||||
|
||||
def __init__(self):
|
||||
|
@ -98,7 +103,7 @@ class VersionControl(object):
|
|||
name = ''
|
||||
dirname = ''
|
||||
# List of supported schemes for this Version Control
|
||||
schemes = ()
|
||||
schemes = () # type: Tuple[str, ...]
|
||||
|
||||
def __init__(self, url=None, *args, **kwargs):
|
||||
self.url = url
|
||||
|
|
Loading…
Reference in New Issue