Incompatibilty Error from Base Classes with **kwargs
#1235
Replies: 2 comments 2 replies
-
I believe, if I'm not mistaken, the error could be due to the potential for a keyword collision, which I gleaned from PEP 692. Confirmation from the community would be appreciated though! e.g. If I made the name of the 4th arguments the same, each could fail the same way if I tried to pass >>> a = Foo()
>>> a.run(1, 2, 'baz', foo='bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: func() got multiple values for argument 'foo' but if I keep the argument names different, then the above would work if I tried to call |
Beta Was this translation helpful? Give feedback.
-
I don't think there's a very principled answer here: strictly speaking both should be an error. I believe pyright will flag both as errors but I haven't tried. Mypy is fairly lenient with the names of positional parameters in overrides, in part because mypy's design predates convenient syntax for positional-only parameters. That's why your first example doesn't give an error. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Related to this SO question, I'm trying to understand why
but
**kwargs
to the end of therun
functions doesBeta Was this translation helpful? Give feedback.
All reactions