Since the return value for importlib.metadata.metadata was fixed in #7331, mypy now incorrectly diagnoses calls to get as a call to an invalid method. That PR took the approach of importing PackageMetadata from the relevant module, but that protocol does not apparently capture the entire supported interface.
(Maybe this is a bug in my understanding of the return value of metadata and get isn't a valid call? But I have a lot of code that does this and it's always worked.)
% cat test.py
from importlib.metadata import metadata
print(metadata("mypy").get("Version"))
% python test.py
0.950
% mypy test.py
test.py:2: error: "PackageMetadata" has no attribute "get"
Found 1 error in 1 file (checked 1 source file)
Since the return value for
importlib.metadata.metadatawas fixed in #7331, mypy now incorrectly diagnoses calls togetas a call to an invalid method. That PR took the approach of importingPackageMetadatafrom the relevant module, but that protocol does not apparently capture the entire supported interface.(Maybe this is a bug in my understanding of the return value of metadata and
getisn't a valid call? But I have a lot of code that does this and it's always worked.)