importlib_metadata: Breaking change in 7e5bae4 (importlib_metadata 5)
entry_points
previously returned a dict-like object and other projects have taken advantage of this functionality (stevedore, for example, iterates via .items()
). As entry_points
now returns a list-like object, it breaks these previously working dict-like methods.
Issue appears with this change: https://github.com/python/importlib_metadata/commit/7e5bae4c7fbd30366e49249825171b193dff22d4
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 12
- Comments: 21 (7 by maintainers)
Commits related to this issue
- Fixing entrypoint bug With the release of importlib_metadata 5.0 deprecation of an endpoint has caused stevedore to fail (at least in python 3.7). For now, I'm pinning importlib-metadata to < 5.0. ... — committed to muhrin/mincepy by muhrin 2 years ago
- Fix: dont use importlib_metadata v5.0 due to deprecated behavior and interface. Summary: Temporarily peg importlib_metadata to <5.0 due do breaking changes (https://github.com/python/importlib_metada... — committed to kurman/torchx by kurman 2 years ago
- Add minimum retention of DeprecatedTuple. Ref #409, #349. — committed to python/importlib_metadata by jaraco 2 years ago
- Add minimum retention of DeprecatedTuple. Ref #409, Ref #349. — committed to python/importlib_metadata by jaraco 2 years ago
- Add minimum retention of DeprecatedTuple. Ref #409, Ref #348. — committed to python/importlib_metadata by jaraco 2 years ago
- Fix: dont use importlib_metadata v5.0 due to deprecated behavior and interface. (#608) Summary: Pull Request resolved: https://github.com/pytorch/torchx/pull/608 Temporarily peg importlib_metadata t... — committed to pytorch/torchx by kurman 2 years ago
- dev: Require flake8 ≥4.0.0 The biggest impact of this change is on Python 3.7 where we were seeing CI test failures.¹ Those now pass again. The story is complicated. Let's start with the facts. Th... — committed to nextstrain/cli by tsibley 2 years ago
- [importlib-metadata-] update for importlib-metadata 5.0 API Closes #1550 Related to https://github.com/python/importlib_metadata/issues/409 `entry_points()` does not return dict-like objects anymor... — committed to saulpw/visidata by anjakefala 2 years ago
- dev: Require flake8 ≥4.0.0 The biggest impact of this change is on Python 3.7 where we were seeing CI test failures.¹ Those now pass again. The story is complicated. Let's start with the facts. Th... — committed to nextstrain/cli by tsibley 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, resulting... — committed to DataDog/dd-trace-py by majorgreys 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, resulting... — committed to DataDog/dd-trace-py by majorgreys 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, resulting... — committed to DataDog/dd-trace-py by majorgreys 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, resulting... — committed to DataDog/dd-trace-py by majorgreys 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, resulting... — committed to DataDog/dd-trace-py by majorgreys 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) (#4286) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, r... — committed to DataDog/dd-trace-py by mergify[bot] 2 years ago
- fix(ci): pin importlib_metadata<5.0.0 (#4257) (#4287) CI jobs `profile-windows-*`, `kombu` and `celery` are failing due to the release of `importlib_metadata==5.0.0` which removed deprecated shims, r... — committed to DataDog/dd-trace-py by mergify[bot] 2 years ago
- Order old importlib-metadata results by group A Debian Buster-based zuul-jobs test started failing when using stestr recently [1]. Upon further investigation, this is a Python 3.7 environment which ... — committed to openstack/stevedore by ianw 2 years ago
- Update git submodules * Update stevedore from branch 'master' to 5189992d719ad15e0e3504947895bf5ba9dc7a1d - Order old importlib-metadata results by group A Debian Buster-based zuul-jobs ... — committed to openstack/openstack by ianw 2 years ago
- Order old importlib-metadata results by group A Debian Buster-based zuul-jobs test started failing when using stestr recently [1]. Upon further investigation, this is a Python 3.7 environment which ... — committed to openstack/stevedore by ianw 2 years ago
- Order old importlib-metadata results by group A Debian Buster-based zuul-jobs test started failing when using stestr recently [1]. Upon further investigation, this is a Python 3.7 environment which ... — committed to openstack/stevedore by ianw 2 years ago
I appreciate everyone’s help on getting this through. I know it was painful for some of you, and I thank you for your patience and civil tone engaging with this somewhat tricky transition. I believe the biggest fires are out and the proposed solutions are having the intended effect of enabling projects to move forward.
I’m going to close this issue, but pin it for visibility, and I’ll gladly re-open if there’s more that this project can do to help.
I really appreciate the feedback.
That’s useful feedback. I’ve been operating under a less rigorous versioning strategy and I’ve only seen a few examples of projects that have adopted a rigorous strategy for breaking changes (Python recently with the two-version deprecation period, and pip with the breaking changes annually). I’ve found that different breaking changes have different blast radii, so it’s difficult to devise a specific strategy that accommodates the variety of impacts. I try to ascertain the level of impact and use that to devise a timeline for deprecation/removal. Often, I will put a specific date in the code “not to be removed before YYYY-MM-DD” to provide downstream consumers a minimum time. I have found that attempting to say specifically when or in what version a breaking change will occur is folly and often gets missed.
I didn’t put a particular date on this change in part because the deprecation itself was so impactful, I’d expected the major consumers to have already addressed the issue early and the 16 month delay gave sufficient time for systems to upgrade.
I do think it would have helped to put a minimum date on the deprecation warning. I’ll do that for the future and possibly remaining deprecation warnings.
That’s an interesting perspective. I’ve never taken that perspective. Whenever I’ve encountered a
DeprecationWarning
, that says to me that the functionality is slated for removal and could be removed at any time in any future version (unless stated otherwise). Interestingly, the Python documentation doesn’t clarify what the meaning of aDeprecationWarning
is.If some maintainers hold the opinion that
DeprecationWarning
just means limit additional usage, they will necessarily encounter the breakage every time it happens (even if it’s years in the future). That is, unless no project ever changes any expectation ever.I could imagine some projects employing a
PendingDeprecationWarning
to signal what you’re suggesting, that further use be curtailed, but that existing uses are still okay for now… but it still implies that a deprecation is imminent and when that happens, one should take action and adapt.Per the Python deprecation policy, this behavior is expected to change in Python 3.12 as well, which is why I wanted to get the backport change out sooner, so users would have a chance to adapt where they have more control over the behavior (pinning dependencies, adding backports, etc).
Good point. If there’s a specific example where the directly-affected project (the project using the interface) did not have visibility to the deprecation warning, I’d like to investigate that, because that’s an assumption I rely on to enact these changes. I know other projects downstream of the direct-consuming projects will be affected, and I rely on the direct consumers to take action when deprecations affect their projects and their users.
My current understanding is that the big projects affected are openstack (stevedore) and flake8, both projects with which I engaged directly at the time of the deprecation (or prior to it) and proposed multiple fixes to address the breakage early. If any project had reached out and requested that the removal be delayed, I certainly would have considered that and likely built it into the approach. Stability and predictability are important, but if a project chooses to ignore the warnings, they do so at their own risk (true of any project).
Breaks flake8 too, which uses
.get()
.I’m pretty sure you can simplify this to:
Because
.select()
(and also the same parameters toentry_points()
) will return an emptyEntryPoints
if no entry points match for the parameters passed.I really appreciate that
.select()
has been around since 3.6. It makes adapting to this change pretty elegant for me.fwiw, Celery is now tracking this - https://github.com/celery/celery/issues/7783 - which was why i came to the issue in this repo in the first place.
i understand that the change to 5.x was semantically a breaking change. on the other hand, because my project isn’t using poetry (😭) i didn’t even know i was using
importlib-metadata
so the error took several hours to track down to root cause. just sharing, not suggesting that you need to change anything about your process!Other things in the dep chain need a newer importlib_metadata, so pip walks back the flake8 versions until it finds flake8 3.9.2 which is the last release that includes
importlib_metadata
without a version pin. It doesn’t work, of course, but pip can’t know that.If I manually pin to flake8 >=4.0.0, the first release which includes the importlib_metadata pin, then pip instead walks back the versions of other things to a point where the version of importlib_metadata they need is compatible with the older version flake8 needs. (I’m not sure yet if this is acceptable or not for our usage, but at least it’s something.)
seconded. i don’t have specific details like @inno but i am able to trace this back to upgrading to 5.0.0. the package that triggered the error was
celery
for the time being i have downgraded to <5.0.0