canonical / operator

Pure Python framework for writing Juju charms
Apache License 2.0
245 stars 119 forks source link

Should we vendor typing_extensions.NotRequired? #1337

Open dimaqq opened 2 weeks ago

dimaqq commented 2 weeks ago

The code is really simple:

https://github.com/python/typing_extensions/blob/70cec91bec65155dc339d631ede2a933582558df/src/typing_extensions.py#L2220-L2256

We're using:

benhoyt commented 2 weeks ago

What's the motivation for this? Are they being removed from typing_extensions, or is there some other reason?

dimaqq commented 2 weeks ago

The motivation is to avoide the if TYPE_CHECKING: block.

The Required/NotRequired are used in TypedDict definitions, which means that TypedDict's can't be used without quotes. Granted, those typed dicts are internal.

I think it may partially help with the following comment for public typed dicts: # In Python 3.11+ 'services' and 'labels' should be NotRequired, and total=True.

The latter could be an improvement for our library users, maybe?

Possibly related: #1336