You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expected type arguments for generic class "StreamHandler" #8840
I'm inheriting from logging.StreamHandler and getting this error on Pyright
classMyStreamHandler(StreamHandler):
Expected type arguments for generic class "StreamHandler"
If I try to add an argument then I get code that doesn't work:
classMyStreamHandler(StreamHandler[TextIO]):
class MyStreamHandler(StreamHandler[TextIO]):
TypeError: 'type' object is not subscriptable
I believe this is due to this class being generic on typeshed, but not in stdlib. Now I'm not really sure how to inherit from it and make the typechecker happy
Activity
JelleZijlstra commentedon Oct 4, 2022
See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-classes-that-are-generic-in-stubs-but-not-at-runtime
AlexWaygood commentedon Oct 4, 2022
See also the discussion in #5954 (comment), and the following comments
GabrielCappelli commentedon Oct 5, 2022
Thank you! was a bit tunnel visioned on
StreamHandlerand didn't search properly