Skip to content

Commit 2aab462

Browse files
committed
Bump mypy to 0.910
This notably gets us on a version of mypy that uses modular typeshed: https://mypy-lang.blogspot.com/2021/05/the-upcoming-switch-to-modular-typeshed.html which allows us to have finer control over what version of stubs we pull in from typeshed. Also contains other routine improvements to mypy. Required a few minor typing changes. Add flag --show-error-code so errors look like this src/pip/_internal/network/auth.py:70: error: Incompatible types in assignment (expression has type "None", variable has type Module) [assignment] rather than src/pip/_internal/network/auth.py:70: error: Incompatible types in assignment (expression has type "None", variable has type Module)
1 parent 618f7e7 commit 2aab462

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ repos:
5151
files: \.py$
5252

5353
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v0.800
54+
rev: v0.910
5555
hooks:
5656
- id: mypy
5757
exclude: tests
58-
args: ["--pretty"]
59-
additional_dependencies: ['nox==2020.12.31']
58+
args: ["--pretty", "--show-error-codes"]
59+
additional_dependencies: [
60+
'keyring==23.0.1',
61+
'nox==2020.12.31',
62+
'types-docutils==0.1.8',
63+
'types-six==0.1.9',
64+
]
6065

6166
- repo: https://github.com/pre-commit/pygrep-hooks
6267
rev: v1.7.0

docs/pip_sphinxext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ def _format_option(
127127
line += f" <{metavar.lower()}>"
128128
# fix defaults
129129
assert option.help is not None
130-
# https://github.com/python/typeshed/pull/5080
131-
opt_help = option.help.replace("%default", str(option.default)) # type: ignore
130+
opt_help = option.help.replace("%default", str(option.default))
132131
# fix paths with sys.prefix
133132
opt_help = opt_help.replace(sys.prefix, "<sys.prefix>")
134133
return [bookmark_line, "", line, "", " " + opt_help, ""]

src/pip/_internal/network/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
try:
2929
import keyring
3030
except ImportError:
31-
keyring = None
31+
keyring = None # type: ignore[assignment]
3232
except Exception as exc:
3333
logger.warning(
3434
"Keyring is skipped due to an exception: %s",
3535
str(exc),
3636
)
37-
keyring = None
37+
keyring = None # type: ignore[assignment]
3838

3939

4040
def get_keyring_auth(url: Optional[str], username: Optional[str]) -> Optional[AuthInfo]:
@@ -66,7 +66,7 @@ def get_keyring_auth(url: Optional[str], username: Optional[str]) -> Optional[Au
6666
"Keyring is skipped due to an exception: %s",
6767
str(exc),
6868
)
69-
keyring = None
69+
keyring = None # type: ignore[assignment]
7070
return None
7171

7272

src/pip/_internal/operations/install/wheel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def is_data_scheme_path(path: RecordPath) -> bool:
566566
wheel_zip,
567567
ensure_text(lib_dir, encoding=sys.getfilesystemencoding()),
568568
)
569-
files = map(make_root_scheme_file, root_scheme_paths)
569+
files: Iterator[File] = map(make_root_scheme_file, root_scheme_paths)
570570

571571
def is_script_scheme_path(path: RecordPath) -> bool:
572572
parts = path.split("/", 2)
@@ -604,7 +604,9 @@ def is_entrypoint_wrapper(file: "File") -> bool:
604604
# Ignore setuptools-generated scripts
605605
return (matchname in console or matchname in gui)
606606

607-
script_scheme_files = map(make_data_scheme_file, script_scheme_paths)
607+
script_scheme_files: Iterator[File] = map(
608+
make_data_scheme_file, script_scheme_paths
609+
)
608610
script_scheme_files = filterfalse(
609611
is_entrypoint_wrapper, script_scheme_files
610612
)

0 commit comments

Comments
 (0)