diff --git a/mypy.ini b/mypy.ini index 569c7f0ace..e32a214cbb 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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 diff --git a/newsfragments/4567.bugfix.rst b/newsfragments/4567.bugfix.rst new file mode 100644 index 0000000000..00c7d8a9c3 --- /dev/null +++ b/newsfragments/4567.bugfix.rst @@ -0,0 +1 @@ +Ensured all methods in `setuptools.modified` raise a consistant `distutils.error.DistutilsError` type -- by :user:`Avasam` diff --git a/setuptools/command/build_clib.py b/setuptools/command/build_clib.py index 5366b0c5c6..f89a46d54a 100644 --- a/setuptools/command/build_clib.py +++ b/setuptools/command/build_clib.py @@ -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): """ diff --git a/setuptools/modified.py b/setuptools/modified.py index 245a61580b..cc8c89c10a 100644 --- a/setuptools/modified.py +++ b/setuptools/modified.py @@ -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']