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
6 changes: 3 additions & 3 deletions distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections.abc import Callable
from distutils._log import log
from site import USER_BASE
from typing import ClassVar
from typing import ClassVar, cast

from .._modified import newer_group
from ..ccompiler import CCompiler, new_compiler, show_compilers
Expand Down Expand Up @@ -736,7 +736,7 @@ def get_ext_filename(self, ext_name: str) -> str:
from ..sysconfig import get_config_var

ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')
ext_suffix = cast('str | None', get_config_var('EXT_SUFFIX')) or ''
return os.path.join(*ext_path) + ext_suffix

def get_export_symbols(self, ext: Extension) -> list[str]:
Expand Down Expand Up @@ -817,7 +817,7 @@ def get_libraries(self, ext: Extension) -> list[str]:
link_libpython = True

if link_libpython:
ldversion = get_config_var('LDVERSION')
ldversion = cast('str | None', get_config_var('LDVERSION')) or ''
return ext.libraries + ['python' + ldversion]

return ext.libraries
13 changes: 11 additions & 2 deletions distutils/compilers/C/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ClassVar,
Literal,
TypeVar,
cast,
overload,
)

Expand Down Expand Up @@ -1082,7 +1083,11 @@ def shared_object_filename(
assert output_dir is not None
if strip_dir:
basename = os.path.basename(basename)
return os.path.join(output_dir, basename + self.shared_lib_extension)
return os.path.join(
output_dir,
# cast: we only allow basename to PathLike if strip_dir=True, so we always coerce
cast("str", basename) + (self.shared_lib_extension or ''),
)

@overload
def executable_filename(
Expand All @@ -1107,7 +1112,11 @@ def executable_filename(
assert output_dir is not None
if strip_dir:
basename = os.path.basename(basename)
return os.path.join(output_dir, basename + (self.exe_extension or ''))
return os.path.join(
output_dir,
# cast: we only allow basename to PathLike if strip_dir=True, so we always coerce
cast("str", basename) + (self.exe_extension or ''),
)

def library_filename(
self,
Expand Down
1 change: 0 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ disable_error_code =
return-value,
type-var,
# TODO: Resolve and re-enable these gradually
operator,
arg-type,

allow_redefinition = true
Expand Down
Loading