1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #9381 from jdufresne/typing-type-checking

Replace pip._internal.utils.typing with stdlib typing
This commit is contained in:
Tzu-ping Chung 2021-02-19 13:11:58 +08:00 committed by GitHub
commit 751cbb72f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
130 changed files with 274 additions and 326 deletions

View file

@ -91,7 +91,7 @@ exclude_lines =
# it.
pragma: no cover
# This excludes typing-specific code, which will be validated by mypy anyway.
if MYPY_CHECK_RUNNING
if TYPE_CHECKING
# Can be set to exclude e.g. `if PY2:` on Python 3
${PIP_CI_COVERAGE_EXCLUDES}

View file

@ -1,6 +1,6 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional

View file

@ -1,7 +1,8 @@
import pip._internal.utils.inject_securetransport # noqa
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
import pip._internal.utils.inject_securetransport # noqa
if TYPE_CHECKING:
from typing import List, Optional

View file

@ -8,6 +8,7 @@ import textwrap
from collections import OrderedDict
from distutils.sysconfig import get_python_lib
from sysconfig import get_paths
from typing import TYPE_CHECKING
from pip._vendor.pkg_resources import Requirement, VersionConflict, WorkingSet
@ -15,9 +16,8 @@ from pip import __file__ as pip_location
from pip._internal.cli.spinners import open_spinner
from pip._internal.utils.subprocess import call_subprocess
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from types import TracebackType
from typing import Iterable, List, Optional, Set, Tuple, Type

View file

@ -5,6 +5,7 @@ import hashlib
import json
import logging
import os
from typing import TYPE_CHECKING
from pip._vendor.packaging.tags import interpreter_name, interpreter_version
from pip._vendor.packaging.utils import canonicalize_name
@ -13,10 +14,9 @@ from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.models.link import Link
from pip._internal.models.wheel import Wheel
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import path_to_url
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, List, Optional, Set
from pip._vendor.packaging.tags import Tag

View file

@ -5,13 +5,13 @@ import optparse
import os
import sys
from itertools import chain
from typing import TYPE_CHECKING
from pip._internal.cli.main_parser import create_main_parser
from pip._internal.commands import commands_dict, create_command
from pip._internal.utils.misc import get_installed_distributions
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Iterable, List, Optional

View file

@ -6,6 +6,7 @@ import optparse
import os
import sys
import traceback
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.command_context import CommandContextMixIn
@ -29,10 +30,9 @@ from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.logging import BrokenStdoutLoggingError, setup_logging
from pip._internal.utils.misc import get_prog, normalize_path
from pip._internal.utils.temp_dir import global_tempdir_manager, tempdir_registry
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import running_under_virtualenv
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Any, List, Optional, Tuple

View file

@ -16,6 +16,7 @@ import warnings
from functools import partial
from optparse import SUPPRESS_HELP, Option, OptionGroup
from textwrap import dedent
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
@ -27,9 +28,8 @@ from pip._internal.models.index import PyPI
from pip._internal.models.target_python import TargetPython
from pip._internal.utils.hashes import STRONG_HASHES
from pip._internal.utils.misc import strtobool
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import OptionParser, Values
from typing import Any, Callable, Dict, Optional, Tuple

View file

@ -1,10 +1,9 @@
from contextlib import contextmanager
from typing import TYPE_CHECKING
from pip._vendor.contextlib2 import ExitStack
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import ContextManager, Iterator, TypeVar
_T = TypeVar('_T', covariant=True)

View file

@ -4,15 +4,15 @@ import locale
import logging
import os
import sys
from typing import TYPE_CHECKING
from pip._internal.cli.autocompletion import autocomplete
from pip._internal.cli.main_parser import parse_command
from pip._internal.commands import create_command
from pip._internal.exceptions import PipError
from pip._internal.utils import deprecation
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional
logger = logging.getLogger(__name__)

View file

@ -3,15 +3,15 @@
import os
import sys
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
from pip._internal.commands import commands_dict, get_similar_commands
from pip._internal.exceptions import CommandError
from pip._internal.utils.misc import get_pip_version, get_prog
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Tuple

View file

@ -8,15 +8,15 @@ import optparse
import shutil
import sys
import textwrap
from typing import TYPE_CHECKING
from pip._vendor.contextlib2 import suppress
from pip._internal.cli.status_codes import UNKNOWN_ERROR
from pip._internal.configuration import Configuration, ConfigurationError
from pip._internal.utils.misc import redact_auth_from_url, strtobool
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any
logger = logging.getLogger(__name__)

View file

@ -1,6 +1,7 @@
import itertools
import sys
from signal import SIGINT, default_int_handler, signal
from typing import TYPE_CHECKING
from pip._vendor.progress.bar import Bar, FillingCirclesBar, IncrementalBar
from pip._vendor.progress.spinner import Spinner
@ -8,9 +9,8 @@ from pip._vendor.progress.spinner import Spinner
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.logging import get_indentation
from pip._internal.utils.misc import format_size
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, List
try:

View file

@ -8,6 +8,7 @@ PackageFinder machinery and all its vendored dependencies, etc.
import logging
import os
from functools import partial
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.base_command import Command
@ -27,9 +28,8 @@ from pip._internal.req.constructors import (
from pip._internal.req.req_file import parse_requirements
from pip._internal.self_outdated_check import pip_self_version_check
from pip._internal.utils.temp_dir import tempdir_kinds
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Any, List, Optional, Tuple

View file

@ -3,14 +3,14 @@ import itertools
import logging
import sys
import time
from typing import TYPE_CHECKING
from pip._vendor.progress import HIDE_CURSOR, SHOW_CURSOR
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.logging import get_indentation
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import IO, Iterator
logger = logging.getLogger(__name__)

View file

@ -4,10 +4,9 @@ Package containing all pip commands
import importlib
from collections import OrderedDict, namedtuple
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Optional
from pip._internal.cli.base_command import Command

View file

@ -1,14 +1,14 @@
import logging
import os
import textwrap
from typing import TYPE_CHECKING
import pip._internal.utils.filesystem as filesystem
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.exceptions import CommandError, PipError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Any, List

View file

@ -1,4 +1,5 @@
import logging
from typing import TYPE_CHECKING
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
@ -7,11 +8,10 @@ from pip._internal.operations.check import (
create_package_set_from_installed,
)
from pip._internal.utils.misc import write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
logger = logging.getLogger(__name__)
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Any, List

View file

@ -1,12 +1,12 @@
import sys
import textwrap
from typing import TYPE_CHECKING
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.utils.misc import get_prog
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -1,6 +1,7 @@
import logging
import os
import subprocess
from typing import TYPE_CHECKING
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
@ -8,9 +9,8 @@ from pip._internal.configuration import Configuration, get_configuration_files,
from pip._internal.exceptions import PipError
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import get_prog, write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Any, List, Optional

View file

@ -2,6 +2,7 @@ import locale
import logging
import os
import sys
from typing import TYPE_CHECKING
import pip._vendor
from pip._vendor.certifi import where
@ -15,9 +16,8 @@ from pip._internal.cli.status_codes import SUCCESS
from pip._internal.metadata import get_environment
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import get_pip_version
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from types import ModuleType
from typing import Dict, List, Optional

View file

@ -1,5 +1,6 @@
import logging
import os
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.cmdoptions import make_target_python
@ -8,9 +9,8 @@ from pip._internal.cli.status_codes import SUCCESS
from pip._internal.req.req_tracker import get_requirement_tracker
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -1,4 +1,5 @@
import sys
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.base_command import Command
@ -6,11 +7,10 @@ from pip._internal.cli.status_codes import SUCCESS
from pip._internal.operations.freeze import freeze
from pip._internal.utils.compat import stdlib_pkgs
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -1,14 +1,14 @@
import hashlib
import logging
import sys
from typing import TYPE_CHECKING
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES
from pip._internal.utils.misc import read_chunks, write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -1,9 +1,10 @@
from typing import TYPE_CHECKING
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.exceptions import CommandError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -5,6 +5,7 @@ import os
import shutil
import site
from optparse import SUPPRESS_HELP
from typing import TYPE_CHECKING
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
@ -29,11 +30,10 @@ from pip._internal.utils.misc import (
write_output,
)
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import virtualenv_no_global
from pip._internal.wheel_builder import build, should_build_for_install_command
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Iterable, List, Optional

View file

@ -1,5 +1,6 @@
import json
import logging
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.cli.req_command import IndexGroupCommand
@ -17,9 +18,8 @@ from pip._internal.utils.misc import (
)
from pip._internal.utils.packaging import get_installer
from pip._internal.utils.parallel import map_multithread
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Iterator, List, Set, Tuple

View file

@ -3,6 +3,7 @@ import shutil
import sys
import textwrap
from collections import OrderedDict
from typing import TYPE_CHECKING
from pip._vendor.packaging.version import parse as parse_version
@ -19,9 +20,8 @@ from pip._internal.models.index import PyPI
from pip._internal.network.xmlrpc import PipXmlrpcTransport
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Dict, List, Optional

View file

@ -1,6 +1,7 @@
import logging
import os
from email.parser import FeedParser
from typing import TYPE_CHECKING
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
@ -8,9 +9,8 @@ from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.utils.misc import write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import Dict, Iterator, List

View file

@ -1,3 +1,5 @@
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.cli.base_command import Command
@ -10,9 +12,8 @@ from pip._internal.req.constructors import (
install_req_from_parsed_requirement,
)
from pip._internal.utils.misc import protect_pip_from_modification_on_windows
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -1,6 +1,7 @@
import logging
import os
import shutil
from typing import TYPE_CHECKING
from pip._internal.cache import WheelCache
from pip._internal.cli import cmdoptions
@ -10,10 +11,9 @@ from pip._internal.exceptions import CommandError
from pip._internal.req.req_tracker import get_requirement_tracker
from pip._internal.utils.misc import ensure_dir, normalize_path
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.wheel_builder import build, should_build_for_wheel_command
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import List

View file

@ -16,6 +16,7 @@ import locale
import logging
import os
import sys
from typing import TYPE_CHECKING
from pip._internal.exceptions import (
ConfigurationError,
@ -24,9 +25,8 @@ from pip._internal.exceptions import (
from pip._internal.utils import appdirs
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.misc import ensure_dir, enum
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Iterable, List, NewType, Optional, Tuple
RawConfigParser = configparser.RawConfigParser # Shorthand

View file

@ -1,8 +1,9 @@
from typing import TYPE_CHECKING
from pip._internal.distributions.sdist import SourceDistribution
from pip._internal.distributions.wheel import WheelDistribution
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._internal.distributions.base import AbstractDistribution
from pip._internal.req.req_install import InstallRequirement

View file

@ -1,8 +1,7 @@
import abc
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Optional
from pip._vendor.pkg_resources import Distribution

View file

@ -1,7 +1,8 @@
from pip._internal.distributions.base import AbstractDistribution
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
from pip._internal.distributions.base import AbstractDistribution
if TYPE_CHECKING:
from typing import Optional
from pip._vendor.pkg_resources import Distribution

View file

@ -1,12 +1,12 @@
import logging
from typing import TYPE_CHECKING
from pip._internal.build_env import BuildEnvironment
from pip._internal.distributions.base import AbstractDistribution
from pip._internal.exceptions import InstallationError
from pip._internal.utils.subprocess import runner_with_spinner_message
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Set, Tuple
from pip._vendor.pkg_resources import Distribution

View file

@ -1,10 +1,10 @@
from typing import TYPE_CHECKING
from zipfile import ZipFile
from pip._internal.distributions.base import AbstractDistribution
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._vendor.pkg_resources import Distribution
from pip._internal.index.package_finder import PackageFinder

View file

@ -1,10 +1,9 @@
"""Exceptions used throughout package"""
from itertools import chain, groupby, repeat
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
import configparser
from hashlib import _Hash
from typing import Dict, List, Optional

View file

@ -12,6 +12,7 @@ import re
import urllib.parse
import urllib.request
from collections import OrderedDict
from typing import TYPE_CHECKING
from pip._vendor import html5lib, requests
from pip._vendor.distlib.compat import unescape
@ -23,11 +24,10 @@ from pip._internal.models.search_scope import SearchScope
from pip._internal.network.utils import raise_for_status
from pip._internal.utils.filetypes import is_archive_file
from pip._internal.utils.misc import pairwise, redact_auth_from_url
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import path_to_url, url_to_path
from pip._internal.vcs import is_url, vcs
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
import xml.etree.ElementTree
from optparse import Values
from typing import (

View file

@ -6,6 +6,7 @@
import functools
import logging
import re
from typing import TYPE_CHECKING
from pip._vendor.packaging import specifiers
from pip._vendor.packaging.utils import canonicalize_name
@ -28,11 +29,10 @@ from pip._internal.utils.filetypes import WHEEL_EXTENSION
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import build_netloc
from pip._internal.utils.packaging import check_requires_python
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.unpacking import SUPPORTED_EXTENSIONS
from pip._internal.utils.urls import url_to_path
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import FrozenSet, Iterable, List, Optional, Set, Tuple, Union
from pip._vendor.packaging.tags import Tag

View file

@ -10,14 +10,14 @@ import sys
import sysconfig
from distutils.command.install import SCHEME_KEYS
from distutils.command.install import install as distutils_install_command
from typing import TYPE_CHECKING, cast
from pip._internal.models.scheme import Scheme
from pip._internal.utils import appdirs
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
from pip._internal.utils.virtualenv import running_under_virtualenv
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from distutils.cmd import Command as DistutilsCommand
from typing import Dict, List, Optional, Union

View file

@ -1,6 +1,6 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional

View file

@ -1,6 +1,6 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional
from .base import BaseDistribution, BaseEnvironment

View file

@ -1,7 +1,8 @@
from pip._internal.utils.misc import stdlib_pkgs # TODO: Move definition here.
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
from pip._internal.utils.misc import stdlib_pkgs # TODO: Move definition here.
if TYPE_CHECKING:
from typing import Container, Iterator, List, Optional
from pip._vendor.packaging.version import _BaseVersion

View file

@ -1,16 +1,16 @@
import zipfile
from typing import TYPE_CHECKING
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.utils import misc # TODO: Move definition here.
from pip._internal.utils.packaging import get_installer
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
from .base import BaseDistribution, BaseEnvironment
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Iterator, List, Optional
from pip._vendor.packaging.version import _BaseVersion

View file

@ -1,9 +1,10 @@
from typing import TYPE_CHECKING
from pip._vendor.packaging.version import parse as parse_version
from pip._internal.utils.models import KeyBasedCompareMixin
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._vendor.packaging.version import _BaseVersion
from pip._internal.models.link import Link

View file

@ -2,10 +2,9 @@
import json
import re
import urllib.parse
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Iterable, Optional, Type, TypeVar, Union
T = TypeVar("T")
@ -156,7 +155,7 @@ class DirInfo:
return _filter_none(editable=self.editable or None)
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
InfoType = Union[ArchiveInfo, DirInfo, VcsInfo]

View file

@ -1,9 +1,10 @@
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.exceptions import CommandError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import FrozenSet, Optional, Set

View file

@ -2,6 +2,7 @@ import os
import posixpath
import re
import urllib.parse
from typing import TYPE_CHECKING
from pip._internal.utils.filetypes import WHEEL_EXTENSION
from pip._internal.utils.misc import (
@ -10,10 +11,9 @@ from pip._internal.utils.misc import (
splitext,
)
from pip._internal.utils.models import KeyBasedCompareMixin
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import path_to_url, url_to_path
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Optional, Tuple, Union
from pip._internal.index.collector import HTMLPage

View file

@ -3,15 +3,15 @@ import logging
import os
import posixpath
import urllib.parse
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.models.index import PyPI
from pip._internal.utils.compat import has_tls
from pip._internal.utils.misc import normalize_path, redact_auth_from_url
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List

View file

@ -1,6 +1,6 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Optional
from pip._internal.models.format_control import FormatControl

View file

@ -1,10 +1,10 @@
import sys
from typing import TYPE_CHECKING
from pip._internal.utils.compatibility_tags import get_supported, version_info_to_nodot
from pip._internal.utils.misc import normalize_version_info
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional, Tuple
from pip._vendor.packaging.tags import Tag

View file

@ -2,13 +2,13 @@
name that have meaning.
"""
import re
from typing import TYPE_CHECKING
from pip._vendor.packaging.tags import Tag
from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List

View file

@ -6,6 +6,7 @@ providing credentials in the context of network requests.
import logging
import urllib.parse
from typing import TYPE_CHECKING
from pip._vendor.requests.auth import AuthBase, HTTPBasicAuth
from pip._vendor.requests.utils import get_netrc_auth
@ -17,9 +18,8 @@ from pip._internal.utils.misc import (
remove_auth_from_url,
split_auth_netloc_from_url,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, List, Optional, Tuple
from pip._vendor.requests.models import Request, Response

View file

@ -3,6 +3,7 @@
import os
from contextlib import contextmanager
from typing import TYPE_CHECKING
from pip._vendor.cachecontrol.cache import BaseCache
from pip._vendor.cachecontrol.caches import FileCache
@ -10,9 +11,8 @@ from pip._vendor.requests.models import Response
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
from pip._internal.utils.misc import ensure_dir
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Iterator, Optional

View file

@ -4,6 +4,7 @@ import cgi
import logging
import mimetypes
import os
from typing import TYPE_CHECKING
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE
@ -13,9 +14,8 @@ from pip._internal.models.index import PyPI
from pip._internal.network.cache import is_from_cache
from pip._internal.network.utils import HEADERS, raise_for_status, response_chunks
from pip._internal.utils.misc import format_size, redact_auth_from_url, splitext
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Iterable, Optional, Tuple
from pip._vendor.requests.models import Response

View file

@ -5,15 +5,15 @@ __all__ = ['HTTPRangeRequestUnsupported', 'dist_from_wheel_url']
from bisect import bisect_left, bisect_right
from contextlib import contextmanager
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING
from zipfile import BadZipfile, ZipFile
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE
from pip._internal.network.utils import HEADERS, raise_for_status, response_chunks
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Iterator, List, Optional, Tuple
from pip._vendor.pkg_resources import Distribution

View file

@ -15,6 +15,7 @@ import platform
import sys
import urllib.parse
import warnings
from typing import TYPE_CHECKING
from pip._vendor import requests, urllib3
from pip._vendor.cachecontrol import CacheControlAdapter
@ -35,10 +36,9 @@ from pip._internal.utils.misc import (
get_installed_version,
parse_netloc,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import url_to_path
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Iterator, List, Optional, Sequence, Tuple, Union
from pip._internal.models.link import Link

View file

@ -1,9 +1,10 @@
from typing import TYPE_CHECKING
from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response
from pip._internal.exceptions import NetworkConnectionError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict, Iterator
# The following comments and HTTP headers were originally added by

View file

@ -3,6 +3,7 @@
import logging
import urllib.parse
from typing import TYPE_CHECKING
# NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is
# why we ignore the type on this import
@ -10,9 +11,8 @@ from pip._vendor.six.moves import xmlrpc_client # type: ignore
from pip._internal.exceptions import NetworkConnectionError
from pip._internal.network.utils import raise_for_status
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict
from pip._internal.network.session import PipSession

View file

@ -2,12 +2,12 @@
"""
import os
from typing import TYPE_CHECKING
from pip._internal.utils.subprocess import runner_with_spinner_message
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._vendor.pep517.wrappers import Pep517HookCaller
from pip._internal.build_env import BuildEnvironment

View file

@ -3,14 +3,14 @@
import logging
import os
from typing import TYPE_CHECKING
from pip._internal.exceptions import InstallationError
from pip._internal.utils.setuptools_build import make_setuptools_egg_info_args
from pip._internal.utils.subprocess import call_subprocess
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._internal.build_env import BuildEnvironment
logger = logging.getLogger(__name__)

View file

@ -1,10 +1,10 @@
import logging
import os
from typing import TYPE_CHECKING
from pip._internal.utils.subprocess import runner_with_spinner_message
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional
from pip._vendor.pep517.wrappers import Pep517HookCaller

View file

@ -1,5 +1,6 @@
import logging
import os.path
from typing import TYPE_CHECKING
from pip._internal.cli.spinners import open_spinner
from pip._internal.utils.setuptools_build import make_setuptools_bdist_wheel_args
@ -8,9 +9,8 @@ from pip._internal.utils.subprocess import (
call_subprocess,
format_command_args,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional
logger = logging.getLogger(__name__)

View file

@ -3,17 +3,17 @@
import logging
from collections import namedtuple
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.pkg_resources import RequirementParseError
from pip._internal.distributions import make_distribution_for_install_requirement
from pip._internal.utils.misc import get_installed_distributions
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
logger = logging.getLogger(__name__)
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
from pip._internal.req.req_install import InstallRequirement

View file

@ -1,6 +1,7 @@
import collections
import logging
import os
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.pkg_resources import RequirementParseError
@ -16,9 +17,8 @@ from pip._internal.utils.direct_url_helpers import (
dist_get_direct_url,
)
from pip._internal.utils.misc import dist_is_editable, get_installed_distributions
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import (
Container,
Dict,

View file

@ -1,13 +1,13 @@
"""Legacy editable installation process, i.e. `setup.py develop`.
"""
import logging
from typing import TYPE_CHECKING
from pip._internal.utils.logging import indent_log
from pip._internal.utils.setuptools_build import make_setuptools_develop_args
from pip._internal.utils.subprocess import call_subprocess
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional, Sequence
from pip._internal.build_env import BuildEnvironment

View file

@ -5,6 +5,7 @@ import logging
import os
import sys
from distutils.util import change_root
from typing import TYPE_CHECKING
from pip._internal.exceptions import InstallationError
from pip._internal.utils.logging import indent_log
@ -12,9 +13,8 @@ from pip._internal.utils.misc import ensure_dir
from pip._internal.utils.setuptools_build import make_setuptools_install_args
from pip._internal.utils.subprocess import runner_with_spinner_message
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional, Sequence
from pip._internal.build_env import BuildEnvironment

View file

@ -14,6 +14,7 @@ import sys
import warnings
from base64 import urlsafe_b64encode
from itertools import chain, filterfalse, starmap
from typing import TYPE_CHECKING, cast
from zipfile import ZipFile
from pip._vendor import pkg_resources
@ -27,7 +28,6 @@ from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, DirectUrl
from pip._internal.models.scheme import SCHEME_KEYS
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file, partition
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.unpacking import (
current_umask,
is_within_directory,
@ -36,12 +36,7 @@ from pip._internal.utils.unpacking import (
)
from pip._internal.utils.wheel import parse_wheel, pkg_resources_distribution_for_wheel
# Use the custom cast function at runtime to make cast work,
# and import typing.cast when performing pre-commit and type
# checks
if not MYPY_CHECK_RUNNING:
from pip._internal.utils.typing import cast
else:
if TYPE_CHECKING:
from email.message import Message
from typing import (
IO,
@ -59,7 +54,6 @@ else:
Set,
Tuple,
Union,
cast,
)
from zipfile import ZipInfo

View file

@ -8,6 +8,7 @@ import logging
import mimetypes
import os
import shutil
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
@ -33,11 +34,10 @@ from pip._internal.utils.hashes import MissingHashes
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import display_path, hide_url, path_to_display, rmtree
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.unpacking import unpack_file
from pip._internal.vcs import vcs
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict, Iterable, List, Optional, Tuple
from pip._vendor.pkg_resources import Distribution

View file

@ -1,13 +1,13 @@
import os
from collections import namedtuple
from typing import TYPE_CHECKING
from pip._vendor import toml
from pip._vendor.packaging.requirements import InvalidRequirement, Requirement
from pip._internal.exceptions import InstallationError
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, List, Optional

View file

@ -1,14 +1,14 @@
import collections
import logging
from typing import TYPE_CHECKING
from pip._internal.utils.logging import indent_log
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from .req_file import parse_requirements
from .req_install import InstallRequirement
from .req_set import RequirementSet
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Iterator, List, Optional, Sequence, Tuple
__all__ = [

View file

@ -11,6 +11,7 @@ InstallRequirement.
import logging
import os
import re
from typing import TYPE_CHECKING
from pip._vendor.packaging.markers import Marker
from pip._vendor.packaging.requirements import InvalidRequirement, Requirement
@ -25,11 +26,10 @@ from pip._internal.pyproject import make_pyproject_path
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.filetypes import is_archive_file
from pip._internal.utils.misc import is_installable_dir
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import path_to_url
from pip._internal.vcs import is_url, vcs
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Optional, Set, Tuple, Union
from pip._internal.req.req_file import ParsedRequirement

View file

@ -7,16 +7,16 @@ import os
import re
import shlex
import urllib.parse
from typing import TYPE_CHECKING
from pip._internal.cli import cmdoptions
from pip._internal.exceptions import InstallationError, RequirementsFileParseError
from pip._internal.models.search_scope import SearchScope
from pip._internal.network.utils import raise_for_status
from pip._internal.utils.encoding import auto_decode
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import get_url_scheme, url_to_path
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from optparse import Values
from typing import (
Any,

View file

@ -7,6 +7,7 @@ import shutil
import sys
import uuid
import zipfile
from typing import TYPE_CHECKING
from pip._vendor import pkg_resources, six
from pip._vendor.packaging.requirements import Requirement
@ -48,11 +49,10 @@ from pip._internal.utils.misc import (
)
from pip._internal.utils.packaging import get_metadata
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import running_under_virtualenv
from pip._internal.vcs import vcs
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
from pip._vendor.packaging.markers import Marker

View file

@ -1,14 +1,14 @@
import logging
from collections import OrderedDict
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.exceptions import InstallationError
from pip._internal.models.wheel import Wheel
from pip._internal.utils import compatibility_tags
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict, Iterable, List, Optional, Tuple
from pip._internal.req.req_install import InstallRequirement

View file

@ -2,13 +2,13 @@ import contextlib
import hashlib
import logging
import os
from typing import TYPE_CHECKING
from pip._vendor import contextlib2
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from types import TracebackType
from typing import Dict, Iterator, Optional, Set, Type, Union

View file

@ -5,6 +5,7 @@ import os
import sys
import sysconfig
from importlib.util import cache_from_source
from typing import TYPE_CHECKING
from pip._vendor import pkg_resources
@ -23,9 +24,8 @@ from pip._internal.utils.misc import (
rmtree,
)
from pip._internal.utils.temp_dir import AdjacentTempDirectory, TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import (
Any,
Callable,

View file

@ -1,6 +1,6 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Callable, List
from pip._internal.req.req_install import InstallRequirement

View file

@ -18,6 +18,7 @@ import logging
import sys
from collections import defaultdict
from itertools import chain
from typing import TYPE_CHECKING
from pip._vendor.packaging import specifiers
@ -35,9 +36,8 @@ from pip._internal.utils.compatibility_tags import get_supported
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import dist_in_usersite, normalize_version_info
from pip._internal.utils.packaging import check_requires_python, get_requires_python
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import DefaultDict, List, Optional, Set, Tuple
from pip._vendor.pkg_resources import Distribution

View file

@ -1,11 +1,12 @@
from typing import TYPE_CHECKING
from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.hashes import Hashes
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import FrozenSet, Iterable, Optional, Tuple
from pip._vendor.packaging.version import _BaseVersion

View file

@ -1,5 +1,6 @@
import logging
import sys
from typing import TYPE_CHECKING
from pip._vendor.packaging.specifiers import InvalidSpecifier, SpecifierSet
from pip._vendor.packaging.utils import canonicalize_name
@ -14,11 +15,10 @@ from pip._internal.req.constructors import (
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.misc import dist_is_editable, normalize_version_info
from pip._internal.utils.packaging import get_requires_python
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from .base import Candidate, format_name
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, FrozenSet, Iterable, Optional, Tuple, Union
from pip._vendor.packaging.version import _BaseVersion

View file

@ -1,5 +1,6 @@
import functools
import logging
from typing import TYPE_CHECKING
from pip._vendor.packaging.utils import canonicalize_name
@ -20,7 +21,6 @@ from pip._internal.utils.misc import (
dist_in_usersite,
get_installed_distributions,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import running_under_virtualenv
from .base import Constraint
@ -39,7 +39,7 @@ from .requirements import (
UnsatisfiableRequirement,
)
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import (
Dict,
FrozenSet,

View file

@ -9,12 +9,11 @@ something.
"""
import functools
from typing import TYPE_CHECKING
from pip._vendor.six.moves import collections_abc # type: ignore
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Callable, Iterator, Optional, Set, Tuple
from pip._vendor.packaging.version import _BaseVersion

View file

@ -1,10 +1,10 @@
from pip._vendor.resolvelib.providers import AbstractProvider
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._vendor.resolvelib.providers import AbstractProvider
from .base import Constraint
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Dict, Iterable, Optional, Sequence, Tuple, Union
from .base import Candidate, Requirement

View file

@ -1,11 +1,10 @@
from collections import defaultdict
from logging import getLogger
from typing import TYPE_CHECKING
from pip._vendor.resolvelib.reporters import BaseReporter
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, DefaultDict
from .base import Candidate, Requirement

View file

@ -1,10 +1,10 @@
from pip._vendor.packaging.utils import canonicalize_name
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._vendor.packaging.utils import canonicalize_name
from .base import Requirement, format_name
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from pip._vendor.packaging.specifiers import SpecifierSet
from pip._internal.req.req_install import InstallRequirement

View file

@ -1,6 +1,7 @@
import functools
import logging
import os
from typing import TYPE_CHECKING
from pip._vendor import six
from pip._vendor.packaging.utils import canonicalize_name
@ -19,12 +20,11 @@ from pip._internal.resolution.resolvelib.reporter import (
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.filetypes import is_archive_file
from pip._internal.utils.misc import dist_is_editable
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from .base import Constraint
from .factory import Factory
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict, List, Optional, Set, Tuple
from pip._vendor.resolvelib.resolvers import Result

View file

@ -4,6 +4,7 @@ import json
import logging
import os.path
import sys
from typing import TYPE_CHECKING
from pip._vendor.packaging import version as packaging_version
@ -13,9 +14,8 @@ from pip._internal.metadata import get_default_environment
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.utils.filesystem import adjacent_tmp_file, check_path_owner, replace
from pip._internal.utils.misc import ensure_dir, get_installed_version
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
import optparse
from typing import Any, Dict

View file

@ -7,12 +7,11 @@ and eventually drop this after all usages are changed.
"""
import os
from typing import TYPE_CHECKING
from pip._vendor import appdirs as _appdirs
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List

View file

@ -9,10 +9,9 @@ import locale
import logging
import os
import sys
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Optional, Union

View file

@ -2,6 +2,7 @@
"""
import re
from typing import TYPE_CHECKING
from pip._vendor.packaging.tags import (
Tag,
@ -13,9 +14,7 @@ from pip._vendor.packaging.tags import (
mac_platforms,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional, Tuple
from pip._vendor.packaging.tags import PythonVersion

View file

@ -7,13 +7,13 @@ A module that implements tooling to enable easy warnings about deprecations.
import logging
import warnings
from typing import TYPE_CHECKING
from pip._vendor.packaging.version import parse
from pip import __version__ as current_version
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, Optional

View file

@ -1,5 +1,6 @@
import json
import logging
from typing import TYPE_CHECKING
from pip._internal.models.direct_url import (
DIRECT_URL_METADATA_NAME,
@ -9,10 +10,9 @@ from pip._internal.models.direct_url import (
DirInfo,
VcsInfo,
)
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.vcs import vcs
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Optional
from pip._vendor.pkg_resources import Distribution

View file

@ -1,9 +1,8 @@
from distutils.errors import DistutilsArgError
from distutils.fancy_getopt import FancyGetopt
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Dict, List

View file

@ -2,10 +2,9 @@ import codecs
import locale
import re
import sys
from typing import TYPE_CHECKING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Tuple
BOMS = [

View file

@ -1,9 +1,9 @@
import sys
from typing import TYPE_CHECKING
from pip._internal.cli.main import main
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import List, Optional

View file

@ -7,6 +7,7 @@ import stat
import sys
from contextlib import contextmanager
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING, cast
# NOTE: retrying is not annotated in typeshed as on 2017-07-17, which is
# why we ignore the type on this import.
@ -14,9 +15,8 @@ from pip._vendor.retrying import retry # type: ignore
from pip._internal.utils.compat import get_path_uid
from pip._internal.utils.misc import format_size
from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
if MYPY_CHECK_RUNNING:
if TYPE_CHECKING:
from typing import Any, BinaryIO, Iterator, List, Union

View file

@ -1,9 +1,10 @@
"""Filetype information.
"""
from pip._internal.utils.misc import splitext
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from typing import TYPE_CHECKING
if MYPY_CHECK_RUNNING:
from pip._internal.utils.misc import splitext
if TYPE_CHECKING:
from typing import Tuple
WHEEL_EXTENSION = '.whl'

Some files were not shown because too many files have changed in this diff Show more