Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions distutils/archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import os
from collections.abc import Callable
from typing import Literal, overload

try:
Expand Down Expand Up @@ -116,7 +117,10 @@ def _set_uid_gid(tarinfo):
return tarinfo

if not dry_run:
tar = tarfile.open(archive_name, f'w|{tar_compression[compress]}')
tar = tarfile.open(
archive_name,
f'w|{tar_compression[compress]}', # type: ignore[call-overload] # Typeshed doesn't allow non-literal string here
)
try:
tar.add(base_dir, filter=_set_uid_gid)
finally:
Expand Down Expand Up @@ -191,7 +195,9 @@ def make_zipfile( # noqa: C901
return zip_filename


ARCHIVE_FORMATS = {
ARCHIVE_FORMATS: dict[
str, tuple[Callable[..., str], list[tuple[str, str | None]], str]
] = {
'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
'xztar': (make_tarball, [('compress', 'xz')], "xz'ed tar-file"),
Expand Down
4 changes: 1 addition & 3 deletions distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,7 @@ def get_command_obj(
self, command: str, create: Literal[True] = True
) -> Command: ...
@overload
def get_command_obj(
self, command: str, create: Literal[False]
) -> Command | None: ...
def get_command_obj(self, command: str, create: bool) -> Command | None: ...
def get_command_obj(self, command: str, create: bool = True) -> Command | None:
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
Expand Down
8 changes: 4 additions & 4 deletions distutils/filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def process_template_line(self, line: str) -> None: # noqa: C901
@overload
def include_pattern(
self,
pattern: str,
pattern: str | None,
anchor: bool = True,
prefix: str | None = None,
is_regex: Literal[False] = False,
Expand All @@ -224,7 +224,7 @@ def include_pattern(
) -> bool: ...
def include_pattern(
self,
pattern: str | re.Pattern,
pattern: str | re.Pattern | None,
anchor: bool = True,
prefix: str | None = None,
is_regex: bool = False,
Expand Down Expand Up @@ -272,7 +272,7 @@ def include_pattern(
@overload
def exclude_pattern(
self,
pattern: str,
pattern: str | None,
anchor: bool = True,
prefix: str | None = None,
is_regex: Literal[False] = False,
Expand All @@ -296,7 +296,7 @@ def exclude_pattern(
) -> bool: ...
def exclude_pattern(
self,
pattern: str | re.Pattern,
pattern: str | re.Pattern | None,
anchor: bool = True,
prefix: str | None = None,
is_regex: bool = False,
Expand Down
11 changes: 6 additions & 5 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ disable_error_code =

# local

# Code that is too dynamic using variable command names;
# and code that uses platform checks mypy doesn't understand
attr-defined,
# These reveal issues in distutils/_modified.py that should be fixed
return-value,
type-var,
# TODO: Resolve and re-enable these gradually
operator,
attr-defined,
arg-type,
assignment,
call-overload,
return-value,
index,
type-var,
func-returns-value,
union-attr,
str-bytes-safe,
misc,
has-type,

# stdlib's test module is not typed on typeshed
[mypy-test.*]
Expand Down
Loading