Skip to content

Commit

Permalink
Trivial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jan 25, 2024
1 parent 2ce2037 commit e7c0804
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions setuptools/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand All @@ -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]:
"""
Expand All @@ -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]:
"""
Expand All @@ -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"``.
"""
...
11 changes: 10 additions & 1 deletion setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/upload_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion setuptools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setuptools/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7c0804

Please sign in to comment.