8000 mypy: fix all misc by Avasam · Pull Request #364 · pypa/distutils · GitHub
[go: up one dir, main page]

Skip to content

mypy: fix all misc #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000
Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion distutils/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def make_archive(
owner: str | None = None,
group: str | None = None,
) -> str:
return archive_util.make_archive(
return archive_util.make_archive( # type: ignore[misc] # Mypy bailed out
base_name,
format,
root_dir,
Expand Down
5 changes: 2 additions & 3 deletions distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,10 @@ def _parse_command_opts(self, parser, args): # noqa: C901
hasattr(cmd_class, 'user_options')
and isinstance(cmd_class.user_options, list)
):
msg = (
"command class %s must provide "
raise DistutilsClassError(
f"command class {cmd_class} must provide "
"'user_options' attribute (a list of tuples)"
)
raise DistutilsClassError(msg % cmd_class)

# If the command class has a list of negative alias options,
# merge it in with the global negative aliases.
Expand Down
18 changes: 13 additions & 5 deletions distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ def customize_compiler(compiler: CCompiler) -> None:
'AR',
'ARFLAGS',
)
assert isinstance(cc, str)
assert isinstance(cxx, str)
assert isinstance(cflags, str)
assert isinstance(ccshared, str)
assert isinstance(ldshared, str)
assert isinstance(ldcxxshared, str)
assert isinstance(shlib_suffix, str)
assert isinstance(ar_flags, str)
ar = os.environ.get('AR', ar)
assert isinstance(ar, str)

cxxflags = cflags

Expand Down Expand Up @@ -354,8 +364,6 @@ def customize_compiler(compiler: CCompiler) -> None:
ldshared = _add_flags(ldshared, 'CPP')
ldcxxshared = _add_flags(ldcxxshared, 'CPP')

ar = os.environ.get('AR', ar)

archiver = ar + ' ' + os.environ.get('ARFLAGS', ar_flags)
cc_cmd = cc + ' ' + cflags
cxx_cmd = cxx + ' ' + cxxflags
Expand All @@ -376,7 +384,7 @@ def customize_compiler(compiler: CCompiler) -> None:
if 'RANLIB' in os.environ and compiler.executables.get('ranlib', None):
compiler.set_executables(ranlib=os.environ['RANLIB'])

compiler.shared_lib_extension = shlib_suffix
compiler.shared_lib_extension = shlib_suffix # type: ignore[misc] # Assigning to ClassVar


def get_config_h_filename() -> str:
Expand Down Expand Up @@ -549,8 +557,8 @@ def expand_makefile_vars(s, vars):
@overload
def get_config_vars() -> dict[str, str | int]: ...
@overload
def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ...
def get_config_vars(*args: str) -> list[str | int] | dict[str, str | int]:
def get_config_vars(arg: str, /, *args: str) -> list[str | int | None]: ...
def get_config_vars(*args: str) -> list[str | int | None] | dict[str, str | int]:
"""With no arguments, return a dictionary of all configuration
variables relevant for the current platform. Generally this includes
everything needed to build extensions and install both pure modules and
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
0