Skip to content

Commit 887c1eb

Browse files
authored
Use double quotes in errors Duplicate argument and Cannot assign multiple modules (#10344)
1 parent 001e4a7 commit 887c1eb

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

mypy/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3225,7 +3225,7 @@ def check_arg_names(names: Sequence[Optional[str]], nodes: List[T], fail: Callab
32253225
seen_names = set() # type: Set[Optional[str]]
32263226
for name, node in zip(names, nodes):
32273227
if name is not None and name in seen_names:
3228-
fail("Duplicate argument '{}' in {}".format(name, description), node)
3228+
fail('Duplicate argument "{}" in {}'.format(name, description), node)
32293229
break
32303230
seen_names.add(name)
32313231

mypy/semanal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,8 +3270,8 @@ def process_module_assignment(self, lvals: List[Lvalue], rval: Expression,
32703270
if isinstance(lnode.node, MypyFile) and lnode.node is not rnode.node:
32713271
assert isinstance(lval, (NameExpr, MemberExpr))
32723272
self.fail(
3273-
"Cannot assign multiple modules to name '{}' "
3274-
"without explicit 'types.ModuleType' annotation".format(lval.name),
3273+
'Cannot assign multiple modules to name "{}" '
3274+
'without explicit "types.ModuleType" annotation'.format(lval.name),
32753275
ctx)
32763276
# never create module alias except on initial var definition
32773277
elif lval.is_inferred_def:

test-data/unit/check-fastparse.test

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,50 +395,50 @@ def f(x: int): # E: Function has duplicate type signatures
395395
def f(x, y, z):
396396
pass
397397

398-
def g(x, y, x): # E: Duplicate argument 'x' in function definition
398+
def g(x, y, x): # E: Duplicate argument "x" in function definition
399399
pass
400400

401-
def h(x, y, *x): # E: Duplicate argument 'x' in function definition
401+
def h(x, y, *x): # E: Duplicate argument "x" in function definition
402402
pass
403403

404-
def i(x, y, *z, **z): # E: Duplicate argument 'z' in function definition
404+
def i(x, y, *z, **z): # E: Duplicate argument "z" in function definition
405405
pass
406406

407-
def j(x: int, y: int, *, x: int = 3): # E: Duplicate argument 'x' in function definition
407+
def j(x: int, y: int, *, x: int = 3): # E: Duplicate argument "x" in function definition
408408
pass
409409

410-
def k(*, y, z, y): # E: Duplicate argument 'y' in function definition
410+
def k(*, y, z, y): # E: Duplicate argument "y" in function definition
411411
pass
412412

413-
lambda x, y, x: ... # E: Duplicate argument 'x' in function definition
413+
lambda x, y, x: ... # E: Duplicate argument "x" in function definition
414414

415415
[case testFastParserDuplicateNames_python2]
416416

417417
def f(x, y, z):
418418
pass
419419

420-
def g(x, y, x): # E: Duplicate argument 'x' in function definition
420+
def g(x, y, x): # E: Duplicate argument "x" in function definition
421421
pass
422422

423-
def h(x, y, *x): # E: Duplicate argument 'x' in function definition
423+
def h(x, y, *x): # E: Duplicate argument "x" in function definition
424424
pass
425425

426-
def i(x, y, *z, **z): # E: Duplicate argument 'z' in function definition
426+
def i(x, y, *z, **z): # E: Duplicate argument "z" in function definition
427427
pass
428428

429-
def j(x, (y, y), z): # E: Duplicate argument 'y' in function definition
429+
def j(x, (y, y), z): # E: Duplicate argument "y" in function definition
430430
pass
431431

432-
def k(x, (y, x)): # E: Duplicate argument 'x' in function definition
432+
def k(x, (y, x)): # E: Duplicate argument "x" in function definition
433433
pass
434434

435-
def l((x, y), (z, x)): # E: Duplicate argument 'x' in function definition
435+
def l((x, y), (z, x)): # E: Duplicate argument "x" in function definition
436436
pass
437437

438-
def m(x, ((x, y), z)): # E: Duplicate argument 'x' in function definition
438+
def m(x, ((x, y), z)): # E: Duplicate argument "x" in function definition
439439
pass
440440

441-
lambda x, (y, x): None # E: Duplicate argument 'x' in function definition
441+
lambda x, (y, x): None # E: Duplicate argument "x" in function definition
442442

443443
[case testNoCrashOnImportFromStar]
444444
from pack import *

test-data/unit/check-functions.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ def k(f: Callable[[KwArg(), NamedArg(Any, 'x')], int]): pass # E: A **kwargs arg
18511851
from typing import Callable
18521852
from mypy_extensions import Arg, VarArg, KwArg, DefaultArg
18531853

1854-
def f(f: Callable[[Arg(int, 'x'), int, Arg(int, 'x')], int]): pass # E: Duplicate argument 'x' in Callable
1854+
def f(f: Callable[[Arg(int, 'x'), int, Arg(int, 'x')], int]): pass # E: Duplicate argument "x" in Callable
18551855

18561856
[builtins fixtures/dict.pyi]
18571857

test-data/unit/check-modules.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ else:
17461746
if bool():
17471747
z = m
17481748
else:
1749-
z = n # E: Cannot assign multiple modules to name 'z' without explicit 'types.ModuleType' annotation
1749+
z = n # E: Cannot assign multiple modules to name "z" without explicit "types.ModuleType" annotation
17501750

17511751
[file m.py]
17521752
a = 'foo'
@@ -1782,13 +1782,13 @@ import m, n, o
17821782

17831783
x = m
17841784
if int():
1785-
x = n # E: Cannot assign multiple modules to name 'x' without explicit 'types.ModuleType' annotation
1785+
x = n # E: Cannot assign multiple modules to name "x" without explicit "types.ModuleType" annotation
17861786
if int():
1787-
x = o # E: Cannot assign multiple modules to name 'x' without explicit 'types.ModuleType' annotation
1787+
x = o # E: Cannot assign multiple modules to name "x" without explicit "types.ModuleType" annotation
17881788

17891789
y = o
17901790
if int():
1791-
y, z = m, n # E: Cannot assign multiple modules to name 'y' without explicit 'types.ModuleType' annotation
1791+
y, z = m, n # E: Cannot assign multiple modules to name "y" without explicit "types.ModuleType" annotation
17921792

17931793
xx = m
17941794
if int():
@@ -1808,7 +1808,7 @@ a = 'bar'
18081808

18091809
[case testModuleAliasToOtherModule]
18101810
import m, n
1811-
m = n # E: Cannot assign multiple modules to name 'm' without explicit 'types.ModuleType' annotation
1811+
m = n # E: Cannot assign multiple modules to name "m" without explicit "types.ModuleType" annotation
18121812

18131813
[file m.py]
18141814

@@ -1958,7 +1958,7 @@ import othermod
19581958
alias = mod.submod
19591959
reveal_type(alias.whatever('/')) # N: Revealed type is "builtins.str*"
19601960
if int():
1961-
alias = othermod # E: Cannot assign multiple modules to name 'alias' without explicit 'types.ModuleType' annotation
1961+
alias = othermod # E: Cannot assign multiple modules to name "alias" without explicit "types.ModuleType" annotation
19621962
[file mod.py]
19631963
import submod
19641964
[file submod.py]

test-data/unit/parse-python2.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ def f(a, (a, b)):
371371
def g((x, (x, y))):
372372
pass
373373
[out]
374-
main:1: error: Duplicate argument 'a' in function definition
375-
main:3: error: Duplicate argument 'x' in function definition
374+
main:1: error: Duplicate argument "a" in function definition
375+
main:3: error: Duplicate argument "x" in function definition
376376

377377
[case testBackquotesInPython2]
378378
`1 + 2`

0 commit comments

Comments
 (0)