10000 Add `__class_getitem__` to `logging.LoggerAdapter` and `logging.StreamHandler` · Issue #92128 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Add __class_getitem__ to logging.LoggerAdapter and logging.StreamHandler #92128

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

Closed
AlexWaygood opened this issue 8000 May 1, 2022 · 0 comments · Fixed by #92129
Closed

Add __class_getitem__ to logging.LoggerAdapter and logging.StreamHandler #92128

AlexWaygood opened this issue May 1, 2022 · 0 comments · Fixed by #92129
Labels
stdlib Python modules in the Lib dir topic-typing type-feature A feature request or enhancement

Comments

@AlexWaygood
Copy link
Member

Feature or enhancement

logging.LoggerAdapter and logging.StreamHandler are generic in typeshed but cannot currently be parameterised at runtime. This has been reported several times to typeshed as being quite painful for end users, since these are both classes that users like to subclass:

If you're a user of type hints, subclassing a class that's generic in the stub but not at runtime usually means that you have to do something horrible with if TYPE_CHECKING (e.g. see python/typeshed#5954 (comment)).

The stubs for these classes have been fairly stable in typeshed for a while; I think it's unlikely that we'll ever want to make them non-generic again over at typeshed. I therefore propose that __class_getitem__ be added to these two classes in 3.11, so that they can be parameterised at runtime.

Cc. @vsajip for the logging module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-typing type-feature A feature request or enhancement
Projects
None yet
1 participant
0