Skip to content

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

Closed
@KotlinIsland

Description

@KotlinIsland
Contributor

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

henryiii commented on Mar 23, 2022

@henryiii
Contributor

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

KotlinIsland commented on Mar 27, 2022

@KotlinIsland
ContributorAuthor

Related #9531

hauntsaninja

hauntsaninja commented on Nov 12, 2023

@hauntsaninja
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @henryiii@hauntsaninja@KotlinIsland

        Issue actions

          (🎁) What if unsupported features reported a warning instead of silently(or unexpectedly) failing · Issue #12397 · python/mypy