Skip to content

Commit a1eeddb

Browse files
authored
Improve error message for --strict-concatenate (#13777)
Resolves #13711, resolves #13429
1 parent a68f0a5 commit a1eeddb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mypy/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ def maybe_note_concatenate_pos_args(
791791
if names:
792792
missing_arguments = '"' + '", "'.join(names) + '"'
793793
self.note(
794-
f'This may be because "{original_caller_type.name}" has arguments '
795-
f"named: {missing_arguments}",
794+
f'This is likely because "{original_caller_type.name}" has named arguments: '
795+
f"{missing_arguments}. Consider marking them positional-only",
796796
context,
797797
code=code,
798798
)

test-data/unit/check-parameter-specification.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ reveal_type(transform(bar)) # N: Revealed type is "def (builtins.str, *args: bui
530530
def expects_int_first(x: Callable[Concatenate[int, P], int]) -> None: ...
531531

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

536536
@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]"
@@ -598,7 +598,7 @@ f2(lambda x: 42)(42, x=42)
598598
main:10: error: invalid syntax; you likely need to run mypy using Python 3.8 or newer
599599
[out version>=3.8]
600600
main:17: error: Incompatible return value type (got "Callable[[Arg(int, 'x'), **P], R]", expected "Callable[[int, **P], R]")
601-
main:17: note: This may be because "result" has arguments named: "x"
601+
main:17: note: This is likely because "result" has named arguments: "x". Consider marking them positional-only
602602

603603
[case testNonStrictParamSpecConcatenateNamedArgs]
604604
# flags: --python-version 3.8

0 commit comments

Comments
 (0)