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

gh-121604: Make sure all deprecated items in importlib raise DeprecationWarning #128007

Merged
merged 15 commits into from
Jan 15, 2025

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Dec 16, 2024

Largely based on work done by @rashansmith, this adds deprecation warnings for the following importlib classes, methods and attributes (using the docs as the source of truth):

The deprecation messages are based on the docs. Warnings for DEBUG_BYTECODE_SUFFIXES and OPTIMIZED_BYTECODE_SUFFIXES are implemented using a module __getattr__.

Feedback welcome!

@tomasr8
Copy link
Member Author

tomasr8 commented Dec 16, 2024

cc @StanFromIreland

Copy link
Contributor

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

Two little things I noticed. I did not have time to go through the rest but it looks good in general.

Lib/importlib/_bootstrap_external.py Outdated Show resolved Hide resolved
Lib/importlib/abc.py Outdated Show resolved Hide resolved
Lib/importlib/_bootstrap_external.py Outdated Show resolved Hide resolved
Lib/importlib/machinery.py Outdated Show resolved Hide resolved
Lib/importlib/machinery.py Outdated Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented Jan 6, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@brettcannon
Copy link
Member

Sorry about the review delay!

@tomasr8
Copy link
Member Author

tomasr8 commented Jan 7, 2025

Sorry about the review delay!

No worries, and thanks for the review! I think I addressed your comments if you feel like having another look :)

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Jan 7, 2025

Thanks for making the requested changes!

@brettcannon: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from brettcannon January 7, 2025 23:37
@brettcannon brettcannon merged commit bd3baa8 into python:main Jan 15, 2025
38 checks passed
@brettcannon
Copy link
Member

Thanks, @tomasr8 for bearing with me and my delayed reviews! 😅

@tomasr8 tomasr8 deleted the importlib-deprecations branch January 15, 2025 06:59
@tomasr8
Copy link
Member Author

tomasr8 commented Jan 15, 2025

No worries :) Thanks for the review!

import warnings
warnings.warn('importlib.abc.ResourceLoader is deprecated in '
'favour of supporting resource loading through '
'importlib.resources.abc.ResourceReader.',
Copy link
Contributor

@graingert graingert Jan 15, 2025

Choose a reason for hiding this comment

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

ResourceReader is deprecated in favour of Superseded by TraversableResources

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch! I added this in another PR recently and forgot to update it here. I'll fix this later today if you don't beat me to it ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah I opened a PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Though, part of that is already covered by #128601

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok hmm, I'm afk for a while so I'm happy for my PR to be closed to make way for a narrower PR to fix just this issue and a followup for the wider change?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tomasr8 #128865 is probably next priority?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah ok hmm, I'm afk for a while so I'm happy for my PR to be closed to make way for a narrower PR to fix just this issue and a followup for the wider change?

I'm on my phone ATM so it's harder to check, but my PR only addresses the docs, not the deprecation message, so you don't need to close yours (just maybe keep only the message change) :)

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.

4 participants