mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Enable mypy's strict equality checks (#12209)
This makes mypy check more behaviours within the codebase. Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
This commit is contained in:
parent
4b0e7e5c44
commit
eddd9ddb66
11
setup.cfg
11
setup.cfg
|
@ -36,11 +36,14 @@ per-file-ignores =
|
||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
mypy_path = $MYPY_CONFIG_FILE_DIR/src
|
mypy_path = $MYPY_CONFIG_FILE_DIR/src
|
||||||
|
|
||||||
|
strict = True
|
||||||
|
|
||||||
|
no_implicit_reexport = False
|
||||||
|
allow_subclassing_any = True
|
||||||
|
allow_untyped_calls = True
|
||||||
|
warn_return_any = False
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
disallow_untyped_defs = True
|
|
||||||
disallow_any_generics = True
|
|
||||||
warn_unused_ignores = True
|
|
||||||
no_implicit_optional = True
|
|
||||||
|
|
||||||
[mypy-pip._internal.utils._jaraco_text]
|
[mypy-pip._internal.utils._jaraco_text]
|
||||||
ignore_errors = True
|
ignore_errors = True
|
||||||
|
|
|
@ -6,9 +6,9 @@ import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
from contextlib import ExitStack, contextmanager
|
from contextlib import ExitStack, contextmanager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import FunctionType
|
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
Generator,
|
Generator,
|
||||||
List,
|
List,
|
||||||
|
@ -187,7 +187,7 @@ class TempDirectory:
|
||||||
errors: List[BaseException] = []
|
errors: List[BaseException] = []
|
||||||
|
|
||||||
def onerror(
|
def onerror(
|
||||||
func: FunctionType,
|
func: Callable[..., Any],
|
||||||
path: Path,
|
path: Path,
|
||||||
exc_val: BaseException,
|
exc_val: BaseException,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -595,8 +595,7 @@ def test_outdated_formats(script: PipTestEnvironment, data: TestData) -> None:
|
||||||
"--outdated",
|
"--outdated",
|
||||||
"--format=json",
|
"--format=json",
|
||||||
)
|
)
|
||||||
data = json.loads(result.stdout)
|
assert json.loads(result.stdout) == [
|
||||||
assert data == [
|
|
||||||
{
|
{
|
||||||
"name": "simple",
|
"name": "simple",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
|
|
|
@ -46,7 +46,9 @@ if TYPE_CHECKING:
|
||||||
# Literal was introduced in Python 3.8.
|
# Literal was introduced in Python 3.8.
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
ResolverVariant = Literal["resolvelib", "legacy"]
|
ResolverVariant = Literal[
|
||||||
|
"resolvelib", "legacy", "2020-resolver", "legacy-resolver"
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
ResolverVariant = str
|
ResolverVariant = str
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ class KeyringModuleV2:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_keyring_get_credential(
|
def test_keyring_get_credential(
|
||||||
monkeypatch: pytest.MonkeyPatch, url: str, expect: str
|
monkeypatch: pytest.MonkeyPatch, url: str, expect: Tuple[str, str]
|
||||||
) -> None:
|
) -> None:
|
||||||
monkeypatch.setitem(sys.modules, "keyring", KeyringModuleV2())
|
monkeypatch.setitem(sys.modules, "keyring", KeyringModuleV2())
|
||||||
auth = MultiDomainBasicAuth(
|
auth = MultiDomainBasicAuth(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from optparse import Values
|
from optparse import Values
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from typing import Any, Dict, Iterator, List, Tuple, Union, cast
|
from typing import Any, Dict, Iterator, List, Tuple, Type, Union, cast
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ class TestOptionsConfigFiles:
|
||||||
self,
|
self,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
args: List[str],
|
args: List[str],
|
||||||
expect: Union[None, str, PipError],
|
expect: Union[None, str, Type[PipError]],
|
||||||
) -> None:
|
) -> None:
|
||||||
cmd = cast(ConfigurationCommand, create_command("config"))
|
cmd = cast(ConfigurationCommand, create_command("config"))
|
||||||
# Replace a handler with a no-op to avoid side effects
|
# Replace a handler with a no-op to avoid side effects
|
||||||
|
|
|
@ -99,17 +99,17 @@ class TestTargetPython:
|
||||||
py_version_info: Optional[Tuple[int, ...]],
|
py_version_info: Optional[Tuple[int, ...]],
|
||||||
expected_version: Optional[str],
|
expected_version: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
mock_get_supported.return_value = ["tag-1", "tag-2"]
|
dummy_tags = [Tag("py4", "none", "any"), Tag("py5", "none", "any")]
|
||||||
|
mock_get_supported.return_value = dummy_tags
|
||||||
|
|
||||||
target_python = TargetPython(py_version_info=py_version_info)
|
target_python = TargetPython(py_version_info=py_version_info)
|
||||||
actual = target_python.get_sorted_tags()
|
actual = target_python.get_sorted_tags()
|
||||||
assert actual == ["tag-1", "tag-2"]
|
assert actual == dummy_tags
|
||||||
|
|
||||||
actual = mock_get_supported.call_args[1]["version"]
|
assert mock_get_supported.call_args[1]["version"] == expected_version
|
||||||
assert actual == expected_version
|
|
||||||
|
|
||||||
# Check that the value was cached.
|
# Check that the value was cached.
|
||||||
assert target_python._valid_tags == ["tag-1", "tag-2"]
|
assert target_python._valid_tags == dummy_tags
|
||||||
|
|
||||||
def test_get_unsorted_tags__uses_cached_value(self) -> None:
|
def test_get_unsorted_tags__uses_cached_value(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue