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

Type hint for Distribution.metadata is incorrect #513

Open
mpurnell1 opened this issue Feb 11, 2025 · 1 comment
Open

Type hint for Distribution.metadata is incorrect #513

mpurnell1 opened this issue Feb 11, 2025 · 1 comment

Comments

@mpurnell1
Copy link

mpurnell1 commented Feb 11, 2025

I encountered this while trying to help sentry-python prepare for the changes mentioned in #371. Their linter errored with "PackageMetadata" has no attribute "get", since metadata is advertised to return _meta.PackageMetadata, but actually returns _adapters.Message.

Is this intended, and if so what is the workaroud for the linter?

Reproduction steps:

  1. git clone [email protected]:mpurnell1/sentry-python.git
  2. pip install tox
  3. tox -e linters
@mpurnell1 mpurnell1 marked this as a duplicate of #514 Feb 11, 2025
@mpurnell1 mpurnell1 marked this as a duplicate of #515 Feb 11, 2025
@mpurnell1
Copy link
Author

It seems the issue is not caused by metadata returning _adapters.Message. Workaround is below, but the typing should maybe still be updated.

... mypy is complaining about PackageMetadata having no .get. Like in most cases that have to do with mypy I'm not sure what's confusing since it isn't the case. Feel free to add a type: ignore[attr-defined] on the line to silence it.

Originally posted by @sentrivana in getsentry/sentry-python#4039 (comment)

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

No branches or pull requests

1 participant