WPS451 breaks type safety
Dreamsorcerer opened this issue · 2 comments
Dreamsorcerer commented
What's wrong
WPS451 breaks type safety by disallowing positional-only arguments.
For example:
from typing import Callable, Concatenate, ParamSpec
P = ParamSpec("P")
def decorator(f: Callable[Concatenate[str, P], int]) -> Callable[P, int]:
def inner(*args: P.args, **kwargs: P.kwargs) -> int:
return f("foo", *args, **kwargs)
return inner
@decorator
def func(foo: str, **kwargs: object) -> int:
return 1
test.py:11: error: Argument 1 to "decorator" has incompatible type "Callable[[Arg(str, 'foo'), KwArg(object)], int]"; expected "Callable[[str, KwArg(object)], int]" [arg-type]
test.py:11: note: This is likely because "func" has named arguments: "foo". Consider marking them positional-only
Found 1 error in 1 file (checked 1 source file)
How it should be
I think the rule should be abandoned.
sobolevn commented
Yes, it is time to reconsider this rule