Skip to content

Commit

Permalink
Re-introduce some type-ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Mar 4, 2025
1 parent 1156767 commit d31a5b0
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
strict = False

# Early opt-in even when strict = False
warn_unused_ignores = True
# warn_unused_ignores = True # Disabled as long as there's inconsistent typing issues between pypa and stdlib's distutils
warn_redundant_casts = True
enable_error_code = ignore-without-code

Expand Down
2 changes: 1 addition & 1 deletion setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def ensure_string_list(self, option: str) -> None:
f"'{option}' must be a list of strings (got {val!r})"
)

@overload
@overload # type: ignore[override]
def reinitialize_command(
self, command: str, reinit_subcommands: bool = False, **kw
) -> _Command: ...
Expand Down
4 changes: 2 additions & 2 deletions setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def finalize_options(self):
if 'data_files' in self.__dict__:
del self.__dict__['data_files']

def copy_file(
def copy_file( # type: ignore[override] # No overload, no bytes support
self,
infile: StrPath,
outfile: StrPathT,
Expand Down Expand Up @@ -135,7 +135,7 @@ def find_data_files(self, package, src_dir):
)
return self.exclude_data_files(package, src_dir, files)

def get_outputs(self, include_bytecode: bool = True) -> list[str]:
def get_outputs(self, include_bytecode: bool = True) -> list[str]: # type: ignore[override] # Using a real boolean instead of 0|1
"""See :class:`setuptools.commands.build.SubCommand`"""
if self.editable_mode:
return list(self.get_output_mapping().keys())
Expand Down
7 changes: 4 additions & 3 deletions setuptools/command/install_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def copy_tree(
self,
infile: StrPath,
outfile: str,
preserve_mode: bool = True,
preserve_times: bool = True,
preserve_symlinks: bool = False,
# override: Using actual booleans
preserve_mode: bool = True, # type: ignore[override]
preserve_times: bool = True, # type: ignore[override]
preserve_symlinks: bool = False, # type: ignore[override]
level: object = 1,
) -> list[str]:
assert preserve_mode
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class sdist(orig.sdist):
]

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
negative_opt: ClassVar[dict[str, str]] = {}
negative_opt: ClassVar[dict[str, str]] = {} # type: ignore[misc] # TODO: Fix upstream

README_EXTENSIONS = ['', '.rst', '.txt', '.md']
READMES = tuple(f'README{ext}' for ext in README_EXTENSIONS)
Expand Down
2 changes: 1 addition & 1 deletion setuptools/config/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _apply(
filenames = [*other_files, filepath]

try:
_Distribution.parse_config_files(dist, filenames=filenames)
_Distribution.parse_config_files(dist, filenames=filenames) # type: ignore[arg-type] # stdlib's distutils is too restrictive here
handlers = parse_configuration(
dist, dist.command_options, ignore_option_errors=ignore_option_errors
)
Expand Down
2 changes: 1 addition & 1 deletion setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def fetch_build_egg(self, req):

return fetch_build_egg(self, req)

def get_command_class(self, command: str) -> type[distutils.cmd.Command]:
def get_command_class(self, command: str) -> type[distutils.cmd.Command]: # type: ignore[override] # Not doing complex overrides yet
"""Pluggable version of get_command_class()"""
if command in self.cmdclass:
return self.cmdclass[command]
Expand Down
2 changes: 1 addition & 1 deletion setuptools/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __init__(
# The *args is needed for compatibility as calls may use positional
# arguments. py_limited_api may be set only via keyword.
self.py_limited_api = py_limited_api
super().__init__(name, sources, *args, **kw)
super().__init__(name, sources, *args, **kw) # type: ignore[arg-type] # stdlib's distutils is too restrictive here

def _convert_pyx_sources_to_lang(self):
"""
Expand Down

0 comments on commit d31a5b0

Please sign in to comment.