Skip to content

Commit c281d20

Browse files
committed
mypy: fix all call-overload
1 parent 248ee13 commit c281d20

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

distutils/archive_util.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import os
9+
from collections.abc import Callable
910
from typing import Literal, overload
1011

1112
try:
@@ -116,7 +117,10 @@ def _set_uid_gid(tarinfo):
116117
return tarinfo
117118

118119
if not dry_run:
119-
tar = tarfile.open(archive_name, f'w|{tar_compression[compress]}')
120+
tar = tarfile.open(
121+
archive_name,
122+
f'w|{tar_compression[compress]}', # type: ignore[call-overload] # Typeshed doesn't allow non-literal string here
123+
)
120124
try:
121125
tar.add(base_dir, filter=_set_uid_gid)
122126
finally:
@@ -191,7 +195,9 @@ def make_zipfile( # noqa: C901
191195
return zip_filename
192196

193197

194-
ARCHIVE_FORMATS = {
198+
ARCHIVE_FORMATS: dict[
199+
str, tuple[Callable[..., str], list[tuple[str, str | None]], str]
200+
] = {
195201
'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
196202
'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
197203
'xztar': (make_tarball, [('compress', 'xz')], "xz'ed tar-file"),

distutils/dist.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,7 @@ def get_command_obj(
865865
self, command: str, create: Literal[True] = True
866866
) -> Command: ...
867867
@overload
868-
def get_command_obj(
869-
self, command: str, create: Literal[False]
870-
) -> Command | None: ...
868+
def get_command_obj(self, command: str, create: bool) -> Command | None: ...
871869
def get_command_obj(self, command: str, create: bool = True) -> Command | None:
872870
"""Return the command object for 'command'. Normally this object
873871
is cached on a previous call to 'get_command_obj()'; if no command

distutils/filelist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def process_template_line(self, line: str) -> None: # noqa: C901
200200
@overload
201201
def include_pattern(
202202
self,
203-
pattern: str,
203+
pattern: str | None,
204204
anchor: bool = True,
205205
prefix: str | None = None,
206206
is_regex: Literal[False] = False,
@@ -272,7 +272,7 @@ def include_pattern(
272272
@overload
273273
def exclude_pattern(
274274
self,
275-
pattern: str,
275+
pattern: str | None,
276276
anchor: bool = True,
277277
prefix: str | None = None,
278278
is_regex: Literal[False] = False,
@@ -296,7 +296,7 @@ def exclude_pattern(
296296
) -> bool: ...
297297
def exclude_pattern(
298298
self,
299-
pattern: str | re.Pattern,
299+
pattern: str | re.Pattern | None,
300300
anchor: bool = True,
301301
prefix: str | None = None,
302302
is_regex: bool = False,

mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ disable_error_code =
2626
operator,
2727
arg-type,
2828
assignment,
29-
call-overload,
3029
index,
3130
func-returns-value,
3231
union-attr,

0 commit comments

Comments
 (0)