Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing exception classes in setuptools.errors #10057

Merged
merged 2 commits into from
Apr 17, 2023

Conversation

maresb
Copy link
Contributor

@maresb maresb commented Apr 17, 2023

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.

@AlexWaygood AlexWaygood changed the title Readd C compiler errors in setuptools.errors Re-add C-compiler exception classes in setuptools.errors Apr 17, 2023
@Avasam
Copy link
Collaborator

Avasam commented Apr 17, 2023

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 = true https://github.com/python/typeshed/blob/main/stubs/setuptools/METADATA.toml#L4

So thanks for adding missing stubs!

@AlexWaygood AlexWaygood changed the title Re-add C-compiler exception classes in setuptools.errors Add C-compiler exception classes in setuptools.errors Apr 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 = true https://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

@AlexWaygood AlexWaygood 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.

@AlexWaygood AlexWaygood changed the title Add C-compiler exception classes in setuptools.errors Add missing exception classes in setuptools.errors Apr 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]

@AlexWaygood AlexWaygood merged commit 0b17faf into python:main Apr 17, 2023
@maresb
Copy link
Contributor Author

maresb commented Apr 17, 2023

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

@maresb maresb 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 free to 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