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

Add casts for package metadata #99

Merged
merged 2 commits into from May 2, 2022
Merged

Add casts for package metadata #99

merged 2 commits into from May 2, 2022

Commits on May 2, 2022

  1. Add casts for package metadata

    In the latest mypy (0.942), importlib.metadata.metadata now returns
    a Protocol named PackageMetadata that doesn't implement the get
    method.  The actual object remains a Message class, however, so the
    get method works correctly.  Only mypy checking fails.
    
    Pending python/typeshed#7767, which may
    reveal that it is intentional that get not be supported, cast the
    return value to Message so that the existing functions work.  This
    seems better than adding try/catch blocks for every piece of
    metadata of interest given that the omission of get appears to be
    unintentional.
    rra committed May 2, 2022
    Configuration menu
    Copy the full SHA
    3612e45 View commit details
    Browse the repository at this point in the history
  2. Make PackageMetadata casts dependent on version

    mypy also complains when casting the return value of metadata to
    Message on older versions where that's the default return value,
    so make the cast conditional on the Python version.
    rra committed May 2, 2022
    Configuration menu
    Copy the full SHA
    3d1256f View commit details
    Browse the repository at this point in the history