Skip to content

Conversation

@maresb
Copy link
Contributor

As part of the distutils deprecation implemented in #9795 by @Avasam, several distutils-related exceptions were removed from setuptools.errors. I think that some exceptions may have unintentionally been removed, so I have added them back in this PR.

Indeed, evidence that setuptools.errors should not be entirely deprecated can be found in PEP 632, where setuptools is suggested as a substitute for distutils.errors.

@github-actions

This comment has been minimized.

@AlexWaygoodAlexWaygood changed the title Readd C compiler errors in setuptools.errorsRe-add C-compiler exception classes in setuptools.errorsApr 17, 2023
@Avasam
Copy link
Collaborator

I think that some exceptions may have unintentionally been removed, so I have added them back in this PR.

Small correction:
I don't think anything was removed from setuptools.errors (https://github.com/python/typeshed/pull/9795/files#diff-7881e6b106cbf3dcded0f78acc68b6b1144200ed8d6f96d7bb6e8cdbffc9eda2), it's more like they've always been missing, because setuptools/METADATA.toml has ignore_missing_stub = truehttps://github.com/python/typeshed/blob/main/stubs/setuptools/METADATA.toml#L4

So thanks for adding missing stubs!

@AlexWaygoodAlexWaygood changed the title Re-add C-compiler exception classes in setuptools.errorsAdd C-compiler exception classes in setuptools.errorsApr 17, 2023
@AlexWaygood
Copy link
Member

Small correction:
I don't think anything was removed from setuptools.errors (https://github.com/python/typeshed/pull/9795/files#diff-7881e6b106cbf3dcded0f78acc68b6b1144200ed8d6f96d7bb6e8cdbffc9eda2), it's more like they've always been missing, because setuptools/METADATA.toml has ignore_missing_stub = truehttps://github.com/python/typeshed/blob/main/stubs/setuptools/METADATA.toml#L4

This is true, but it is also true, looking at it again, that many exception classes were removed from setuptools/_distutils/errors.pyi, meaning users can no longer import them from setuptools._distutils.errors: https://github.com/python/typeshed/pull/9795/files#diff-8a7c86f8b0bf8367e2bbc71a6168e13ae3b279440ab5775da788c36a502854eeR1-L19. These classes weren't then added to setuptools/errors.pyi, so users now have nowhere they can import them from. This was probably an oversight :)

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've tweaked the PR a little bit so that it's a bit more faithful to what happens at runtime. Will merge once CI passes.

@AlexWaygoodAlexWaygood changed the title Add C-compiler exception classes in setuptools.errorsAdd missing exception classes in setuptools.errorsApr 17, 2023
@Avasam
Copy link
Collaborator

Avasam commented Apr 17, 2023

Given the push for the deprecation of distutils, it'd be a good idea indeed to ensure that all stubs in setuptools are accounted for. There aren't too many stubtest errors left. I should have a PR ready pretty soon.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sphinx (https://github.com/sphinx-doc/sphinx) - sphinx/setup_command.py:23:5: error: Module "setuptools.errors" has no attribute "ExecError" [attr-defined]+ sphinx/setup_command.py:26:5: error: Incompatible import of "ExecError" (imported name has type "Type[distutils.errors.DistutilsExecError]", local name has type "Type[setuptools._distutils.errors.DistutilsExecError]") [assignment]

@AlexWaygoodAlexWaygood merged commit 0b17faf into python:mainApr 17, 2023
@maresb
Copy link
ContributorAuthor

Awesome, thanks so much for the extremely fast response!!!

@maresbmaresb deleted the readd-c-compiler-errors branch April 17, 2023 19:16
maresb added a commit to pymc-devs/pytensor that referenced this pull request Apr 17, 2023
This is to ensure that we get python/typeshed#10057 so that #277 is resolved.
ricardoV94 pushed a commit to pymc-devs/pytensor that referenced this pull request Apr 18, 2023
This is to ensure that we get python/typeshed#10057 so that #277 is resolved.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@maresb@Avasam@AlexWaygood