Jason R. Coombs

Results 1062 comments of Jason R. Coombs

Honestly, I'm conflicted. My instinct is that the current protocol definition is right and that `__getitem__` should raise a `KeyError` if a key is missing. I'm unsure why `EmailMessage` deviated...

Separately, I'm disappointed that `mypy` was no help here. As much grief as mypy gives, nitpicking and requiring lots of redundant type hints, it's simultaneously failed here to identify the...

Spurred by considerations in that bpo issue, I'm inclined to say the implementation should be limited to raise a KeyError when an item is not defined in the metadata. I...

In 614a522, I confirmed that at least internally, there's no issue with raising KeyError on missing keys.

Since this change is likely to create disruption, I'd like to reserve it for a new backward-incompatible release to only go into new versions of CPython (3.12 or later), but...

Before the release could even hit PyPI, the backward incompatibility struck. The [release process failed](https://github.com/python/importlib_metadata/actions/runs/3722907257/jobs/6314136479) because `twine` is [relying on `__getitem__` returning `None`](https://github.com/pypa/twine/blob/f001a7ea89b8496a3c9145cfe2eda4c3d6a19144/twine/__init__.py#L43). This finding leads me to believe there...

> What's the proper way to write code that can handle a missing item? If you wrap the getitem in a `try`/`except`, you still get a deprecation warning. How about...

Finally, importlib_metadata 8 provides the desired behavior, raising KeyError on a missing key. If you want the KeyError behavior, depend on and use importlib_metadata 8 or later (to be incorporated...

Thanks for the proposal. I'm going to have to think about this more. This library is merged back into CPython as `importlib.metadata` so these annotations won't make sense when that...

It's important to remember that `importlib.metadata` was provisional until Python 3.10, where the selectable entry points was introduced. If a project is relying on `importlib.metadata` on Python 3.9 to supply...