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
2 changes: 1 addition & 1 deletion distutils/compilers/C/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Compiler:
# dictionary (see below -- used by the 'new_compiler()' factory
# function) -- authors of new compiler interface classes are
# responsible for updating 'compiler_class'!
compiler_type: ClassVar[str] = None # type: ignore[assignment]
compiler_type: ClassVar[str] = None

# XXX things not handled by this compiler abstraction model:
# * client can't provide additional options for a compiler,
Expand Down
12 changes: 10 additions & 2 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 Down
4 changes: 3 additions & 1 deletion distutils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def change_root(
if not os.path.isabs(pathname):
return os.path.join(new_root, pathname)
else:
return os.path.join(new_root, pathname[1:])
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, pathname[1:]) # type: ignore[index]
Comment on lines +154 to +156
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a decision to be taken here.

  1. Don't support PathLike in this branch (current behaviour)
  2. Don't support bytes | PathLike[bytes] in this branch
Suggested change
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, pathname[1:]) # type: ignore[index]
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, str(pathname)[1:])
  1. Support both, requires extra checking.


elif os.name == 'nt':
(drive, path) = os.path.splitdrive(pathname)
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