Skip to content
Discussion options

You must be logged in to vote

When you have a non-protocol class that inherits from a protocol class, the child class effectively "promises" that it will implement the protocol. In the case of a method, this means it must implement that method. In the case of a variable, it's not so clear what "implements" means. In general, pyright doesn't enforce that a class or instance variable is assigned a value.

My recommendation is to not use the protocol class as a base class here. Simply remove Action from the base class list when defining SingleArgAction and MultiArgAction. Pyright will then detect a protocol mismatch if these classes don't declare the three class variables defined in Action. I presume that you intended for…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Timmmm
Comment options

Answer selected by M1kep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants