python / importlib_metadata

Library to access metadata for Python packages
https://importlib-metadata.readthedocs.io
Apache License 2.0
123 stars 80 forks source link

Sync PackageMetadata with email.message.Message #435

Closed FFY00 closed 1 year ago

FFY00 commented 1 year ago

Fixes #434

jaraco commented 1 year ago

This code makes me sad. It looks like the typing system requires overloads anywhere where a None is the default fallback object? It took me many minutes just to try to comprehend what's going on here and it's degrading the readability of the get_all method. The reader now has to incorporate additional concepts (Optional, overload) and reconcile the two interfaces just to reason about what, without typing checks, is a simple concept (failobj=None).

Moreover, this test fails the diffcov because it fails to cover the new line 23 (an ellipsis).

What ever happened to "elegance begets simplicity"?

Is there any expectation that this behavior will ever be simplified? I guess I can link to the PRs for those who need to track down the origin.

jaraco commented 1 year ago

For reference - upstream change at https://github.com/python/typeshed/pull/9620 and possible long-term simplification at https://github.com/python/typing/issues/307.

jaraco commented 1 year ago

This change also introduces errors in the docs build:

/home/runner/work/importlib_metadata/importlib_metadata/importlib_metadata/_meta.py:docstring of typing._overload_dummy:1: WARNING: py:class reference target not found: _T