--extra-checks
is too strict when using Concatenate
within a Protocol
#17122
Labels
--extra-checks
is too strict when using Concatenate
within a Protocol
#17122
Bug Report
This is admittedly a fairly niche use-case, but this came up when adding more precise type hints to
itsdangerous
and trying to write aProtocol
that accepts any object that has aloads
anddumps
method wheredumps
can take arbitrary extra keyword arguments.The docs for
--extra-checks
state that uses ofConcatenate
will force positional-only for equality, but this seems incorrect to me in the specific case of a property on aProtocol
, since we're performing a structural match against methods there.*args: Any, **kwargs: Any
doesn't really work, because it will only be recognized as a gradual extension of the method by some type checkers and not consistently, it's also not part of the typing spec, unless I'm mistaken. SoConcatenate
with...
is the only way to spell this.To Reproduce
mypy Playground
Expected Behavior
I would expect
MySerializer
to match theProtocol
in my example. As soon as I change thepayload
argument to positional-only it does. It also does if I disable--extra-checks
.Actual Behavior
It is rejected based on the first argument not being positional-only.
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: