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

bpo-43780: Sync with importlib_metadata 3.10 #25297

Merged
merged 3 commits into from Apr 24, 2021

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Apr 9, 2021

@jaraco
Copy link
Member Author

jaraco commented Apr 9, 2021

@pablogsal I wanted to highlight this change because it introduces a deprecation. There's a lot of background in python/importlib_metadata#284 and linked issues, but I'm aiming to remove the compatibility wrapper that enables Mapping access on the entry_points result.

I've put a lot of work into developing a robust transition with low impact and options for every use-case. importlib_metadata 3.9 was released with this deprecation 12 days ago and there's been little disruption but for python/importlib_metadata#298, which instigated even more compatibility support.

I've demonstrated the recommended approach to avoid the deprecation in some high profile libraries including twine and keyring and intend to continue to provide direct support for other high-profile libraries.

I'd like to introduce this deprecation for Python 3.10 and in a future importlib_metadata and Python, drop the compatibility layer. I'm open to backing out the deprecation during the beta phase if it somehow introduces unmanageable disruption.

I welcome your feedback and questions.

@jaraco jaraco requested a review from pablogsal April 9, 2021 00:43
Lib/importlib/metadata.py Outdated Show resolved Hide resolved
Doc/library/importlib.metadata.rst Outdated Show resolved Hide resolved
@pablogsal
Copy link
Member

@pablogsal I wanted to highlight this change because it introduces a deprecation. There's a lot of background in python/importlib_metadata#284 and linked issues, but I'm aiming to remove the compatibility wrapper that enables Mapping access on the entry_points result.

I've put a lot of work into developing a robust transition with low impact and options for every use-case. importlib_metadata 3.9 was released with this deprecation 12 days ago and there's been little disruption but for python/importlib_metadata#298, which instigated even more compatibility support.

I've demonstrated the recommended approach to avoid the deprecation in some high profile libraries including twine and keyring and intend to continue to provide direct support for other high-profile libraries.

I'd like to introduce this deprecation for Python 3.10 and in a future importlib_metadata and Python, drop the compatibility layer. I'm open to backing out the deprecation during the beta phase if it somehow introduces unmanageable disruption.

I welcome your feedback and questions.

Will review this as soon as possible.

@jaraco
Copy link
Member Author

jaraco commented Apr 17, 2021

I realize I might be able to provide more context.

python/importlib_metadata#289 shows the change where the deprecation was introduced (and the change that would need to be backed out to remove the deprecation if needed).

Here's how the deprecation implemented here manifests:

$ ./python.exe -W error
>>> import importlib.metadata as md
>>> eps = md.entry_points()
>>> eps['group']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jaraco/code/public/cpython/Lib/importlib/metadata.py", line 300, in __getitem__
    self._warn()
DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
>>> eps.get('group', ())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jaraco/code/public/cpython/Lib/importlib/metadata.py", line 304, in get
    flake8_bypass(self._warn)()
DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.

It occurs to me looking at those tracebacks the stacklevel may need to be tweaked to improve the error message.

@jaraco
Copy link
Member Author

jaraco commented Apr 17, 2021

It occurs to me looking at those tracebacks the stacklevel may need to be tweaked to improve the error message.

On further consideration, the stacklevel does look correct:

cpython [bpo-43780](https://bugs.python.org/issue43780)/importlib_metadata-3.10 $ ./python.exe -Wd -c "import importlib.metadata as md; eps = md.entry_points(); eps['group']"
<string>:1: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jaraco/code/public/cpython/Lib/importlib/metadata.py", line 301, in __getitem__
    return super().__getitem__(name)
KeyError: 'group'
cpython [bpo-43780](https://bugs.python.org/issue43780)/importlib_metadata-3.10 $ ./python.exe -Wd -c "import importlib.metadata as md; eps = md.entry_points(); eps.get('group', ())"
<string>:1: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.

@jaraco
Copy link
Member Author

jaraco commented Apr 24, 2021

Because #25565 now depends on this change, I'd like to merge it now in order to resolve conflicts and get a clean diff for the subsequent PR. Since the deprecation can be readily disabled, I see no reason to get approval in advance. I'd appreciate Pablo's review if possible, but I won't block on it.

@jaraco jaraco merged commit c6ca368 into master Apr 24, 2021
@jaraco jaraco deleted the bpo-43780/importlib_metadata-3.10 branch April 24, 2021 14:13
@jaraco jaraco restored the bpo-43780/importlib_metadata-3.10 branch April 24, 2021 14:13
@jaraco jaraco deleted the bpo-43780/importlib_metadata-3.10 branch April 24, 2021 14:14
@jaraco jaraco restored the bpo-43780/importlib_metadata-3.10 branch April 24, 2021 14:14
kreathon pushed a commit to kreathon/cpython that referenced this pull request May 2, 2021
* bpo-43780: Sync with importlib_metadata 3.10.

* Add blurb

* Apply changes from importlib_metadata 3.10.1.
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.

None yet

5 participants