diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 453036e37..abec3c89f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - # - id: check-builtin-literals # TODO: enable when fixed. + - id: check-builtin-literals - id: check-added-large-files - id: check-case-conflict - id: check-toml diff --git a/src/pip/_internal/index.py b/src/pip/_internal/index.py index 4db14eb1a..81bdd4ad5 100644 --- a/src/pip/_internal/index.py +++ b/src/pip/_internal/index.py @@ -34,7 +34,7 @@ from pip._internal.wheel import Wheel if MYPY_CHECK_RUNNING: from typing import ( - Any, FrozenSet, Iterable, List, Optional, Set, Text, Tuple, + FrozenSet, Iterable, List, Optional, Set, Text, Tuple, Union, ) from pip._vendor.packaging.version import _BaseVersion from pip._internal.collector import LinkCollector @@ -43,7 +43,7 @@ if MYPY_CHECK_RUNNING: from pip._internal.pep425tags import Pep425Tag from pip._internal.utils.hashes import Hashes - BuildTag = Tuple[Any, ...] # either empty tuple or Tuple[int, str] + BuildTag = Union[Tuple[()], Tuple[int, str]] CandidateSortingKey = ( Tuple[int, int, int, _BaseVersion, BuildTag, Optional[int]] ) @@ -511,7 +511,7 @@ class CandidateEvaluator(object): """ valid_tags = self._supported_tags support_num = len(valid_tags) - build_tag = tuple() # type: BuildTag + build_tag = () # type: BuildTag binary_preference = 0 link = candidate.link if link.is_wheel: diff --git a/src/pip/_internal/operations/check.py b/src/pip/_internal/operations/check.py index 3bc9f8107..9f7fe6a7f 100644 --- a/src/pip/_internal/operations/check.py +++ b/src/pip/_internal/operations/check.py @@ -68,8 +68,8 @@ def check_package_set(package_set, should_ignore=None): def should_ignore(name): return False - missing = dict() - conflicting = dict() + missing = {} + conflicting = {} for package_name in package_set: # Info about dependencies of package_name diff --git a/tests/conftest.py b/tests/conftest.py index 5982ebf90..e29f03e59 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -181,10 +181,10 @@ def pip_src(tmpdir_factory): return to_ignore # Ignore all compiled files and egg-info. - ignored = list() - for pattern in ["__pycache__", "*.pyc", "pip.egg-info"]: - ignored.extend(fnmatch.filter(names, pattern)) - return set(ignored) + ignored = set() + for pattern in ("__pycache__", "*.pyc", "pip.egg-info"): + ignored.update(fnmatch.filter(names, pattern)) + return ignored pip_src = Path(str(tmpdir_factory.mktemp('pip_src'))).joinpath('pip_src') # Copy over our source tree so that each use is self contained