-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
How do you implement type-checking with methods for classes that inherit from NamedTuple? #2954
Comments
This is not a bug. You inherit addition from tuple with a wider signature.
|
Is there a way to use the method signature of the class itself? It would be nice to inherit the functionality of the NamedTuple class while being able to perform type-checking on the methods that are overridden. It's just not clear to me how one would do that. |
I'm not 100% sure what you're trying to accomplish, but on the basis of your initial example I'm guessing you want to redefine However there's a work-around: put |
I wasn't trying to do anything specific, per se. I was having a discussion about NamedTuples in Python and nominal vs structural typing and I came across this behavior when reading this person's comment. Thank you for taking the time to provide a thoughtful and helpful explanation, Benevolent Dictator!! I'll be sure to pass on the knowledge in case others have a similar question. |
Could it be related to the bug mentioned in #1987 ?
The text was updated successfully, but these errors were encountered: