diff --git a/setuptools/command/build.py b/setuptools/command/build.py index afda7e3be9..2f9f568e54 100644 --- a/setuptools/command/build.py +++ b/setuptools/command/build.py @@ -98,12 +98,15 @@ def finalize_options(self): def initialize_options(self): """(Required by the original :class:`setuptools.Command` interface)""" + ... def finalize_options(self): """(Required by the original :class:`setuptools.Command` interface)""" + ... def run(self): """(Required by the original :class:`setuptools.Command` interface)""" + ... def get_source_files(self) -> List[str]: """ @@ -115,6 +118,7 @@ def get_source_files(self) -> List[str]: with all the files necessary to build the distribution. All files should be strings relative to the project root directory. """ + ... def get_outputs(self) -> List[str]: """ @@ -128,6 +132,7 @@ def get_outputs(self) -> List[str]: in ``get_output_mapping()`` plus files that are generated during the build and don't correspond to any source file already present in the project. """ + ... def get_output_mapping(self) -> Dict[str, str]: """ @@ -138,3 +143,4 @@ def get_output_mapping(self) -> Dict[str, str]: Destination files should be strings in the form of ``"{build_lib}/destination/file/path"``. """ + ... diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index f73d857f08..4b484c85bc 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -11,6 +11,7 @@ """ from glob import glob +from typing import TYPE_CHECKING, Optional, Union from distutils.util import get_platform from distutils.util import convert_path, subst_vars from distutils.errors import ( @@ -78,6 +79,8 @@ from .._path import ensure_directory from ..extern.jaraco.text import yield_lines +if TYPE_CHECKING: + _FileDescriptorOrPath = Union[int, str, bytes, os.PathLike[str], os.PathLike[bytes]] # Turn on PEP440Warnings warnings.filterwarnings("default", category=pkg_resources.PEP440Warning) @@ -2016,7 +2019,13 @@ def is_python_script(script_text, filename): from os import chmod as _chmod except ImportError: # Jython compatibility - def _chmod(*args): + def _chmod( + path: "_FileDescriptorOrPath", + mode: int, + *, + dir_fd: Optional[int] = None, + follow_symlinks: bool = True, + ) -> None: pass diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 32c9abd796..5de0721bd4 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -50,7 +50,7 @@ def has_sphinx(self): and metadata.entry_points(group='distutils.commands', name='build_sphinx') ) - sub_commands = [('build_sphinx', has_sphinx)] + sub_commands = [('build_sphinx', has_sphinx)] # type: ignore[list-item] # distutils stubs issue w/ Python 3.12 def initialize_options(self): upload.initialize_options(self) diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index 321e106e40..825f2d62c7 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -296,7 +296,10 @@ def _obtain(self, dist: "Distribution", field: str, package_dir: Mapping[str, st def _obtain_version(self, dist: "Distribution", package_dir: Mapping[str, str]): # Since plugins can set version, let's silently skip if it cannot be obtained if "version" in self.dynamic and "version" in self.dynamic_cfg: - return _expand.version(self._obtain(dist, "version", package_dir)) + return _expand.version( + # We already do an early check for the presence of "version" + self._obtain(dist, "version", package_dir) # pyright: ignore[reportArgumentType] + ) return None def _obtain_readme(self, dist: "Distribution") -> Optional[Dict[str, str]]: @@ -306,9 +309,10 @@ def _obtain_readme(self, dist: "Distribution") -> Optional[Dict[str, str]]: dynamic_cfg = self.dynamic_cfg if "readme" in dynamic_cfg: return { + # We already do an early check for the presence of "readme" "text": self._obtain(dist, "readme", {}), "content-type": dynamic_cfg["readme"].get("content-type", "text/x-rst"), - } + } # pyright: ignore[reportReturnType] self._ensure_previously_set(dist, "readme") return None diff --git a/setuptools/msvc.py b/setuptools/msvc.py index aa69db5810..33177503e9 100644 --- a/setuptools/msvc.py +++ b/setuptools/msvc.py @@ -19,10 +19,12 @@ import platform import itertools import subprocess +from typing import TYPE_CHECKING import distutils.errors from setuptools.extern.more_itertools import unique_everseen -if platform.system() == 'Windows': +# https://github.com/python/mypy/issues/8166 +if not TYPE_CHECKING and platform.system() == 'Windows': import winreg from os import environ else: diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 757074166a..502f248062 100644 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -19,7 +19,7 @@ else: _os = sys.modules[os.name] try: - _file = file + _file = file # type: ignore[name-defined] # Check for global variable except NameError: _file = None _open = open