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

Rely on .get for possibly undefined metadata. #1124

Closed
wants to merge 2 commits into from

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Jun 25, 2024

Closes #977

@JohnVillalovos
Copy link

Would it make sense to put the data that is being requested into the pyproject.toml file?

@henryiii
Copy link
Contributor

This is a deprecated field, so no. Project URLs has replaced home-page; home-page should not be required! (And you can't put it into a pyproject.toml file, it's not part of PEP 621)

@JohnVillalovos
Copy link

This is a deprecated field, so no. Project URLs has replaced home-page; home-page should not be required! (And you can't put it into a pyproject.toml file, it's not part of PEP 621)

So looks like can do: metadata["Project-URL"]

@jaraco
Copy link
Member Author

jaraco commented Jun 25, 2024

Tests are failing for other reasons. I'm merging this to get the fix out ASAP.

@JohnVillalovos
Copy link

Tests are failing for other reasons. I'm merging this to get the fix out ASAP.

Should use get with a default value of an empty string. The type checking CI is failing due to that.

@jaraco
Copy link
Member Author

jaraco commented Jun 25, 2024

This repo is secure, so nothing I can do but wait for other maintainers to come by. @sigmavirus24 or @bhrutledge Can you merge and cut a release?

@henryiii
Copy link
Contributor

This is the wrong solution. This is on twine itself, so the metadata shouldn't ever be undefined. Instead, it should pull the correct metadata (from URLs) for this entry.

@henryiii
Copy link
Contributor

I think it's metadata["Project-URL"]["Homepage"]

@jaraco
Copy link
Member Author

jaraco commented Jun 25, 2024

This is the wrong solution. This is on twine itself, so the metadata shouldn't ever be undefined. Instead, it should pull the correct metadata (from URLs) for this entry.

I also believe it's the wrong solution and my recommendation would be to remove this boilerplate and let users call importlib metadata themselves. However, this PR aims to address narrowly the deprecation warning and emergent failure without making other changes to the logic.

@jaraco
Copy link
Member Author

jaraco commented Jun 25, 2024

I think it's metadata["Project-URL"]["Homepage"]

importlib metadata doesn't provide a high-level interface for the metadata, so it's going to require something like this to get the URL.

@JohnVillalovos
Copy link

I think it's metadata["Project-URL"]["Homepage"]

Sadly no ☹️

But can do: metadata.get_all("Project-URL") which gets a list, containing sort of comma-separated values.

[
"Homepage, https://twine.readthedocs.io/", 
"Source, https://github.com/pypa/twine/",
...
]

@JohnVillalovos
Copy link

The easiest fix would be to just hard-code the value until a more elegant fix can happen. IMHO.

@JohnVillalovos
Copy link

The easiest fix would be to just hard-code the value until a more elegant fix can happen. IMHO.

I did that in: #1127

@jaraco
Copy link
Member Author

jaraco commented Jun 26, 2024

We're preferring the first submission in #1115 to this approach.

mtlynch added a commit to mtlynch/resticpy that referenced this pull request Jul 3, 2024
This fixes an issue with twine version 4.0.2, which depends on the
latest version of importlib-metadata (>= 3.6).
Consequently, it is impacted by the breaking changes introduced in
importlib-metadata version 8.0.0.

This issue has been resolved in pypa/twine#1124.

Co-authored-by: Jeroen Wellner <[email protected]>
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.

DeprecationWarning: Implicit None on return values is deprecated and will raise KeyErrors.
5 participants