diff --git a/distutils/cmd.py b/distutils/cmd.py index 241621bd..9152dcbc 100644 --- a/distutils/cmd.py +++ b/distutils/cmd.py @@ -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, diff --git a/distutils/dist.py b/distutils/dist.py index b9552a8b..ea4e24c8 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -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. diff --git a/distutils/sysconfig.py b/distutils/sysconfig.py index 7ddc869a..68f4068f 100644 --- a/distutils/sysconfig.py +++ b/distutils/sysconfig.py @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/mypy.ini b/mypy.ini index 146222a5..d8dbde24 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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.*]