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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@ def maybe_note_concatenate_pos_args(
if names:
missing_arguments = '"' + '", "'.join(names) + '"'
self.note(
f'This may be because "{original_caller_type.name}" has arguments '
f"named: {missing_arguments}",
f'This is likely because "{original_caller_type.name}" has named arguments: '
f"{missing_arguments}. Consider marking them positional-only",
context,
code=code,
)
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ reveal_type(transform(bar)) # N: Revealed type is "def (builtins.str, *args: bui
def expects_int_first(x: Callable[Concatenate[int, P], int]) -> None: ...

@expects_int_first # E: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" \
# N: This may be because "one" has arguments named: "x"
# N: This is likely because "one" has named arguments: "x". Consider marking them positional-only
def one(x: str) -> int: ...

@expects_int_first # E: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]"
Expand Down Expand Up @@ -598,7 +598,7 @@ f2(lambda x: 42)(42, x=42)
main:10: error: invalid syntax; you likely need to run mypy using Python 3.8 or newer
[out version>=3.8]
main:17: error: Incompatible return value type (got "Callable[[Arg(int, 'x'), **P], R]", expected "Callable[[int, **P], R]")
main:17: note: This may be because "result" has arguments named: "x"
main:17: note: This is likely because "result" has named arguments: "x". Consider marking them positional-only

[case testNonStrictParamSpecConcatenateNamedArgs]
# flags: --python-version 3.8
Expand Down