Skip to content

Commit

Permalink
Standardize error type for all _distutils.modified methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 13, 2024
1 parent 6fcce38 commit 322e6bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ disable_error_code = attr-defined
[mypy-pkg_resources.tests.*]
disable_error_code = import-not-found

# - distutils._modified has different errors on Python 3.8 [import-untyped], on Python 3.9+ [import-not-found]
# - distutils._modified has different errors on Python 3.8 on Windows only [import-untyped],
# where it's an [import-not-found] on all other platforms and versions
# - All jaraco modules are still untyped
# - _validate_project sometimes complains about trove_classifiers (#4296)
# - wheel appears to be untyped
Expand Down
1 change: 1 addition & 0 deletions newsfragments/4567.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensured all methods in ``setuptools.modified`` raise a consistant ``distutils.error.DistutilsError`` type -- by :user:`Avasam`
8 changes: 2 additions & 6 deletions setuptools/command/build_clib.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from ..modified import newer_pairwise_group

import distutils.command.build_clib as orig
from distutils import log
from distutils.errors import DistutilsSetupError

try:
from distutils._modified import newer_pairwise_group
except ImportError:
# fallback for SETUPTOOLS_USE_DISTUTILS=stdlib
from .._distutils._modified import newer_pairwise_group


class build_clib(orig.build_clib):
"""
Expand Down
22 changes: 16 additions & 6 deletions setuptools/modified.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from ._distutils._modified import (
newer,
newer_group,
newer_pairwise,
newer_pairwise_group,
)
try:
# Ensure a DistutilsError raised by these methods is the same as distutils.error.DistutilsError
from distutils._modified import (
newer,
newer_group,
newer_pairwise,
newer_pairwise_group,
)
except ImportError:
# fallback for SETUPTOOLS_USE_DISTUTILS=stdlib, because _modified never existed in stdlib
from ._distutils._modified import (
newer,
newer_group,
newer_pairwise,
newer_pairwise_group,
)

__all__ = ['newer', 'newer_pairwise', 'newer_group', 'newer_pairwise_group']

0 comments on commit 322e6bb

Please sign in to comment.