Skip to content
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

(🎁) What if unsupported features reported a warning instead of silently(or unexpectedly) failing #12397

Closed
KotlinIsland opened this issue Mar 21, 2022 · 3 comments
Labels

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 21, 2022

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.

@henryiii
Copy link
Contributor

henryiii commented 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:

...: error: The first argument to Callable must be a list of types or "..."  [misc]
...: error: Incompatible return value type (got "Callable[P, None]", expected "Callable[P, None]")  [return-value]

The last one is quite, um, interesting. :)

@KotlinIsland
Copy link
Contributor Author

Related #9531

@hauntsaninja
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants