Skip to content

Expected type arguments for generic class "StreamHandler" #8840

Closed

Description

@GabrielCappelli

Hello,

I'm inheriting from logging.StreamHandler and getting this error on Pyright

class MyStreamHandler(StreamHandler):

Expected type arguments for generic class "StreamHandler"

If I try to add an argument then I get code that doesn't work:

class MyStreamHandler(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

  1. AlexWaygood commented on Oct 4, 2022

    @AlexWaygood
    Member

    See also the discussion in #5954 (comment), and the following comments

  2. GabrielCappelli commented on Oct 5, 2022

    @GabrielCappelli
    Author

    Thank you! was a bit tunnel visioned on StreamHandler and didn't search properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions