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

inspection: error on unsupported metadata versions #9203

Merged
merged 2 commits into from
Mar 23, 2024

Conversation

abn
Copy link
Member

@abn abn commented Mar 22, 2024

Resolves: #9195

This change also handles a previously unidentified bug. Previously, when processing wheel files, PackageInfo incorrectly
returned an empty instance. This change ensures a PackageInfoError is correctly raised. See 36bf325.

@abn abn requested a review from a team March 22, 2024 22:42
@abn abn force-pushed the issue/9195 branch 2 times, most recently from 4e749a0 to 312e75c Compare March 22, 2024 23:10
abn added 2 commits March 23, 2024 13:06
Previously, when processing wheel files, PackageInfo incorrectly
returned an empty instance. This change ensures a PackageInfoError
is correctly raised.
@abn abn merged commit 2a2abce into python-poetry:main Mar 23, 2024
22 checks passed
@abn abn deleted the issue/9195 branch March 23, 2024 13:21
Copy link
Contributor

@jfly jfly left a comment

Choose a reason for hiding this comment

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

Thanks, @abn <3 I love this change. Fail-fast!

I tested this out with the test harness I put together, and it works great!

$ docker compose run poetry-1.9.x.prerelease-pkginfo-1.9.6 -c 'cd backend-with-mydevpi && poetry lock -vv'
...
Using virtualenv: /opt/venv
Updating dependencies
Resolving dependencies...
   1: fact: backend-with-mydevpi is 0.1.0
   1: derived: backend-with-mydevpi
   1: fact: backend-with-mydevpi depends on hatchling (*)
   1: selecting backend-with-mydevpi (0.1.0)
   1: derived: hatchling
   1: Version solving took 0.070 seconds.
   1: Tried 1 solutions.

  ValueError

  Package('hatchling', '1.22.4') is not in list

  at /opt/poetry/lib/python3.11/site-packages/poetry/repositories/legacy_repository.py:57 in package
       53│         Note that this will be cached so the subsequent operations
       54│         should be much faster.
       55│         """
       56│         try:
    →  57│             index = self._packages.index(Package(name, version))
       58│
       59│             return self._packages[index]
       60│         except ValueError:
       61│             package = super().package(name, version, extras)

The following error occurred when trying to handle this error:
...

PackageInfoError

Unable to determine package info for path: /tmp/tmpdkj0o8_8/hatchling-1.22.4-py3-none-any.whl

Unknown metadata version

at /opt/poetry/lib/python3.11/site-packages/poetry/inspection/info.py:554 in from_wheel
    550│         try:
    551│             wheel = pkginfo.Wheel(str(path))
    552│             return cls._from_distribution(wheel)
    553│         except ValueError as e:
  → 554│             raise PackageInfoError(path, e)
    555│
    556│     @classmethod
    557│     def from_bdist(cls, path: Path) -> PackageInfo:
    558│         """

src/poetry/inspection/info.py Show resolved Hide resolved
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better handling of unrecognized metadata versions
3 participants