Skip to content

Commit 7efc814

Browse files
authored
Merge pull request #11374 from hauntsaninja/implicit-optional
2 parents 7607c14 + edbfeae commit 7efc814

File tree

11 files changed

+20
-14
lines changed

11 files changed

+20
-14
lines changed

news/5580954E-E089-4CDB-857A-868BA1F7435D.trivial.rst

Whitespace-only changes.

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ignore_missing_imports = True
4040
disallow_untyped_defs = True
4141
disallow_any_generics = True
4242
warn_unused_ignores = True
43+
no_implicit_optional = True
4344

4445
[mypy-pip._vendor.*]
4546
ignore_errors = True

src/pip/_internal/cli/spinners.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import sys
55
import time
6-
from typing import IO, Generator
6+
from typing import IO, Generator, Optional
77

88
from pip._internal.utils.compat import WINDOWS
99
from pip._internal.utils.logging import get_indentation
@@ -23,7 +23,7 @@ class InteractiveSpinner(SpinnerInterface):
2323
def __init__(
2424
self,
2525
message: str,
26-
file: IO[str] = None,
26+
file: Optional[IO[str]] = None,
2727
spin_chars: str = "-\\|/",
2828
# Empirically, 8 updates/second looks nice
2929
min_update_interval_seconds: float = 0.125,

src/pip/_internal/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ class NetworkConnectionError(PipError):
288288
"""HTTP connection error"""
289289

290290
def __init__(
291-
self, error_msg: str, response: Response = None, request: Request = None
291+
self,
292+
error_msg: str,
293+
response: Optional[Response] = None,
294+
request: Optional[Request] = None,
292295
) -> None:
293296
"""
294297
Initialize NetworkConnectionError with `request` and `response`

src/pip/_internal/locations/_distutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
def distutils_scheme(
3636
dist_name: str,
3737
user: bool = False,
38-
home: str = None,
39-
root: str = None,
38+
home: Optional[str] = None,
39+
root: Optional[str] = None,
4040
isolated: bool = False,
41-
prefix: str = None,
41+
prefix: Optional[str] = None,
4242
*,
4343
ignore_config_files: bool = False,
4444
) -> Dict[str, str]:

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ def _raise_for_invalid_entrypoint(specification: str) -> None:
420420

421421

422422
class PipScriptMaker(ScriptMaker):
423-
def make(self, specification: str, options: Dict[str, Any] = None) -> List[str]:
423+
def make(
424+
self, specification: str, options: Optional[Dict[str, Any]] = None
425+
) -> List[str]:
424426
_raise_for_invalid_entrypoint(specification)
425427
return super().make(specification, options)
426428

src/pip/_internal/utils/hashes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import hashlib
2-
from typing import TYPE_CHECKING, BinaryIO, Dict, Iterable, List
2+
from typing import TYPE_CHECKING, BinaryIO, Dict, Iterable, List, Optional
33

44
from pip._internal.exceptions import HashMismatch, HashMissing, InstallationError
55
from pip._internal.utils.misc import read_chunks
@@ -28,7 +28,7 @@ class Hashes:
2828
2929
"""
3030

31-
def __init__(self, hashes: Dict[str, List[str]] = None) -> None:
31+
def __init__(self, hashes: Optional[Dict[str, List[str]]] = None) -> None:
3232
"""
3333
:param hashes: A dict of algorithm names pointing to lists of allowed
3434
hex digests

src/pip/_internal/utils/setuptools_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
def make_setuptools_shim_args(
5050
setup_py_path: str,
51-
global_options: Sequence[str] = None,
51+
global_options: Optional[Sequence[str]] = None,
5252
no_user_config: bool = False,
5353
unbuffered_output: bool = False,
5454
) -> List[str]:

src/pip/_internal/vcs/subversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def is_commit_id_equal(cls, dest: str, name: Optional[str]) -> bool:
184184
"""Always assume the versions don't match"""
185185
return False
186186

187-
def __init__(self, use_interactive: bool = None) -> None:
187+
def __init__(self, use_interactive: Optional[bool] = None) -> None:
188188
if use_interactive is None:
189189
use_interactive = is_console_interactive()
190190
self.use_interactive = use_interactive

tests/lib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ def create_basic_wheel_for_package(
11681168
name: str,
11691169
version: str,
11701170
depends: Optional[List[str]] = None,
1171-
extras: Dict[str, List[str]] = None,
1171+
extras: Optional[Dict[str, List[str]]] = None,
11721172
requires_python: Optional[str] = None,
11731173
extra_files: Optional[Dict[str, Union[bytes, str]]] = None,
11741174
) -> pathlib.Path:

0 commit comments

Comments
 (0)