Closed
Description
Full ParamSpec
support is on the way(#8645) but until that time, completely valid usages of ParamSpec
and Concatenate
are met with perplexing error messages that most people would misinterpret as misusing the feature.
I believe it would be at least 10 times more understandable if mypy showed a warning in these circumstances:
from typing import type_check_only, ParamSpec, Concatenate, Callable
@type_check_only # no warning about unsupported functionality
def foo() -> None: ...
P = ParamSpec("P")
def bar(func: # error: The first argument to Callable must be a list of types or "..."
Callable[
Concatenate[P, int],
None,
]
) -> None: #
...
Proposed behavior:
> mypy test.py
test.py:3: warning: Unsupported typing feature: "type_check_only"
test.py:9: warning: Unsupported typing feature: "Concatenate"
Success 0 errors in 1 file
Idk if it's possible to determine what would constitute a warning, next best thing would be to show the current error with an info message.
Activity
henryiii commentedon Mar 23, 2022
I was trying to implement Concatenate for a while before realizing it was unsupported, since I thought I was simply using it incorrectly. This would be very nice to have! 👍 Another example of a as-yet unsupported feature: Self.
This is the current result of using Concatenate, FYI:
The last one is quite, um, interesting. :)
KotlinIsland commentedon Mar 27, 2022
Related #9531
hauntsaninja commentedon Nov 12, 2023
Closing, since we support PEP 612. We'll try to keep in mind for future type system features, e.g. we currently do issue a warning about PEP 695