Skip to content

Improve error message for --strict-concatenate #13777

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

Merged
merged 2 commits into from
Sep 30, 2022

Conversation

hauntsaninja
Copy link
Collaborator

Resolves #13711, resolves #13429

@hauntsaninja
Copy link
Collaborator Author

cc @A5rocks

Copy link
Collaborator

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright to me. One big improvement would be fixing the error message for methods: original_caller_type.name is unexpected in that case.

To be specific, ATM the error message can be e.g. main.py:13: note: This may be because "inner of X" has arguments named: "x".

Reproducer (has other errors too):

from __future__ import annotations

from typing import Callable, Any
from typing_extensions import ParamSpec, Concatenate

_PRouteParams = ParamSpec("_PRouteParams")
def decorate_me(func: Callable[Concatenate[int, _PRouteParams], Any]) -> Callable[Concatenate[int, _PRouteParams], Any]:
    class X:
        def inner(x: int, *args: _PRouteParams.args, **kwargs: _PRouteParams.kwargs) -> dict[str, Any]:
            return {"result": func(x, *args, **kwargs)}

    return X.inner

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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

Successfully merging this pull request may close these issues.

Mypy doesn't recognize accept a callable result type when type hint allows any result type Arg(T, 'name') not equivalent to T in Callable
3 participants