Skip to content

Commit 484c7b6

Browse files
committed
Change name from StarArg to VarArg
1 parent b26c534 commit 484c7b6

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

extensions/mypy_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def DefaultNamedArg(typ=Any, name=None):
115115
return typ
116116

117117

118-
def StarArg(typ=Any):
118+
def VarArg(typ=Any):
119119
return typ
120120

121121

mypy/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
ARG_OPT: "DefaultArg",
8989
ARG_NAMED: "NamedArg",
9090
ARG_NAMED_OPT: "DefaultNamedArg",
91-
ARG_STAR: "StarArg",
91+
ARG_STAR: "VarArg",
9292
ARG_STAR2: "KwArg",
9393
}
9494

mypy/typeanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'mypy_extensions.DefaultArg': nodes.ARG_OPT,
3535
'mypy_extensions.NamedArg': nodes.ARG_NAMED,
3636
'mypy_extensions.DefaultNamedArg': nodes.ARG_NAMED_OPT,
37-
'mypy_extensions.StarArg': nodes.ARG_STAR,
37+
'mypy_extensions.VarArg': nodes.ARG_STAR,
3838
'mypy_extensions.KwArg': nodes.ARG_STAR2,
3939
}
4040

test-data/unit/check-functions.test

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ee_var = everything
143143
ee_var = everywhere
144144

145145
ee_var = specific_1 # The difference between Callable[..., blah] and one with a *args: Any, **kwargs: Any is that the ... goes loosely both ways.
146-
ee_def = specific_1 # E: Incompatible types in assignment (expression has type Callable[[int, str], None], variable has type Callable[[StarArg(Any), KwArg(Any)], None])
146+
ee_def = specific_1 # E: Incompatible types in assignment (expression has type Callable[[int, str], None], variable has type Callable[[VarArg(Any), KwArg(Any)], None])
147147

148148
[builtins fixtures/dict.pyi]
149149

@@ -1409,7 +1409,7 @@ def a(f: F):
14091409

14101410
[case testCallableParsingFromExpr]
14111411
from typing import Callable
1412-
from mypy_extensions import Arg, StarArg, KwArg
1412+
from mypy_extensions import Arg, VarArg, KwArg
14131413

14141414
def WrongArg(x, y): return y
14151415
# Note that for this test, the 'Value of type "int" is not indexable' errors are silly,
@@ -1418,10 +1418,10 @@ def WrongArg(x, y): return y
14181418
# that looks like a function call.
14191419
F = Callable[[WrongArg(int, 'x')], int] # E: Unknown argument constructor WrongArg
14201420
G = Callable[[Arg(1, 'x')], int] # E: Invalid type alias # E: Value of type "int" is not indexable
1421-
H = Callable[[StarArg(int, 'x')], int] # E: StarArg should not have a specified name
1422-
I = Callable[[StarArg(int)], int] # ok
1423-
J = Callable[[StarArg(), KwArg()], int] # ok
1424-
K = Callable[[StarArg(), int], int] # E: Required positional args may not appear after default, named or star args
1421+
H = Callable[[VarArg(int, 'x')], int] # E: VarArg should not have a specified name
1422+
I = Callable[[VarArg(int)], int] # ok
1423+
J = Callable[[VarArg(), KwArg()], int] # ok
1424+
K = Callable[[VarArg(), int], int] # E: Required positional args may not appear after default, named or star args
14251425
L = Callable[[Arg(name='x', typ=int)], int] # ok
14261426
# I have commented out the following test because I don't know how to expect the "defined here" note part of the error.
14271427
# M = Callable[[Arg(gnome='x', typ=int)], int] # Invalid type alias, Unexpected keyword argument "gnome" for "Arg"
@@ -1431,16 +1431,16 @@ N = Callable[[Arg(name=None, typ=int)], int] # ok
14311431

14321432
[case testCallableParsing]
14331433
from typing import Callable
1434-
from mypy_extensions import Arg, StarArg, KwArg
1434+
from mypy_extensions import Arg, VarArg, KwArg
14351435

14361436
def WrongArg(x, y): return y
14371437

14381438
# This test only shows parse-time errors
14391439
def a(f: Callable[[WrongArg(int, 'x')], int]): pass # typeanal-time error
14401440
def b(f: Callable[[Arg(1, 'x')], int]): pass # E: invalid type comment or annotation
1441-
def c(f: Callable[[StarArg(int, 'x')], int]): pass # typeanal-time error
1442-
def d(f: Callable[[StarArg(int)], int]): pass # ok
1443-
def e(f: Callable[[StarArg(), KwArg()], int]): pass # ok
1441+
def c(f: Callable[[VarArg(int, 'x')], int]): pass # typeanal-time error
1442+
def d(f: Callable[[VarArg(int)], int]): pass # ok
1443+
def e(f: Callable[[VarArg(), KwArg()], int]): pass # ok
14441444
def g(f: Callable[[Arg(name='x', typ=int)], int]): pass # ok
14451445
def h(f: Callable[[Arg(gnome='x', typ=int)], int]): pass # E: Unexpected argument "gnome" for argument constructor
14461446
def i(f: Callable[[Arg(name=None, typ=int)], int]): pass # ok
@@ -1461,19 +1461,19 @@ from mypy_extensions import Arg
14611461
def b(f: Callable[[Arg(1, 'x')], int]): pass # E: invalid type comment or annotation
14621462
[builtins fixtures/dict.pyi]
14631463

1464-
[case testCallableFastParseTooManyStarArg]
1464+
[case testCallableFastParseTooManyVarArg]
14651465
# flags: --fast-parser
14661466
from typing import Callable
1467-
from mypy_extensions import StarArg
1468-
def c(f: Callable[[StarArg(int, 'x')], int]): pass # E: StarArg should not have a specified name
1467+
from mypy_extensions import VarArg
1468+
def c(f: Callable[[VarArg(int, 'x')], int]): pass # E: VarArg should not have a specified name
14691469
[builtins fixtures/dict.pyi]
14701470

14711471
[case testCallableFastParseGood]
14721472
# flags: --fast-parser
14731473
from typing import Callable
1474-
from mypy_extensions import StarArg, Arg, KwArg
1475-
def d(f: Callable[[StarArg(int)], int]): pass # ok
1476-
def e(f: Callable[[StarArg(), KwArg()], int]): pass # ok
1474+
from mypy_extensions import VarArg, Arg, KwArg
1475+
def d(f: Callable[[VarArg(int)], int]): pass # ok
1476+
def e(f: Callable[[VarArg(), KwArg()], int]): pass # ok
14771477
def g(f: Callable[[Arg(name='x', typ=int)], int]): pass # ok
14781478
def i(f: Callable[[Arg(name=None, typ=int)], int]): pass # ok
14791479
[builtins fixtures/dict.pyi]
@@ -1487,10 +1487,10 @@ def h(f: Callable[[Arg(gnome='x', typ=int)], int]): pass # E: Unexpected argumen
14871487

14881488
[case testCallableKindsOrdering]
14891489
from typing import Callable
1490-
from mypy_extensions import Arg, StarArg, KwArg, DefaultArg, NamedArg
1490+
from mypy_extensions import Arg, VarArg, KwArg, DefaultArg, NamedArg
14911491

1492-
def f(f: Callable[[StarArg(), int], int]): pass # E: Required positional args may not appear after default, named or star args
1493-
def g(f: Callable[[StarArg(), StarArg()], int]): pass # E: Star args may not appear after named or star args
1492+
def f(f: Callable[[VarArg(), int], int]): pass # E: Required positional args may not appear after default, named or star args
1493+
def g(f: Callable[[VarArg(), VarArg()], int]): pass # E: Star args may not appear after named or star args
14941494
def h(f: Callable[[KwArg(), KwArg()], int]): pass # E: You may only have one **kwargs argument
14951495
def i(f: Callable[[DefaultArg(), int], int]): pass # E: Required positional args may not appear after default, named or star args
14961496
def j(f: Callable[[NamedArg(int, 'x'), DefaultArg(int, 'y')], int]): pass # E: Positional default args may not appear after named or star args
@@ -1499,7 +1499,7 @@ def j(f: Callable[[NamedArg(int, 'x'), DefaultArg(int, 'y')], int]): pass # E: P
14991499

15001500
[case testCallableDuplicateNames]
15011501
from typing import Callable
1502-
from mypy_extensions import Arg, StarArg, KwArg, DefaultArg
1502+
from mypy_extensions import Arg, VarArg, KwArg, DefaultArg
15031503

15041504
def f(f: Callable[[Arg(int, 'x'), int, Arg(int, 'x')], int]): pass # E: duplicate argument 'x' in callable type
15051505

test-data/unit/check-inference.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ from typing import Callable
10481048
def f(a: Callable[..., None] = lambda *a, **k: None):
10491049
pass
10501050

1051-
def g(a: Callable[..., None] = lambda *a, **k: 1): # E: Incompatible types in assignment (expression has type Callable[[StarArg(Any), KwArg(Any)], int], variable has type Callable[..., None])
1051+
def g(a: Callable[..., None] = lambda *a, **k: 1): # E: Incompatible types in assignment (expression has type Callable[[VarArg(Any), KwArg(Any)], int], variable has type Callable[..., None])
10521052
pass
10531053
[builtins fixtures/dict.pyi]
10541054

test-data/unit/check-varargs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ x = None # type: Callable[[int], None]
574574
def f(*x: int) -> None: pass
575575
def g(*x: str) -> None: pass
576576
x = f
577-
x = g # E: Incompatible types in assignment (expression has type Callable[[StarArg(str)], None], variable has type Callable[[int], None])
577+
x = g # E: Incompatible types in assignment (expression has type Callable[[VarArg(str)], None], variable has type Callable[[int], None])
578578
[builtins fixtures/list.pyi]
579579
[out]
580580

test-data/unit/lib-stub/mypy_extensions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def NamedArg(name=None, typ: T = ...) -> T: pass
1515

1616
def DefaultNamedArg(name=None, typ: T = ...) -> T: pass
1717

18-
def StarArg(typ: T = ...) -> T: pass
18+
def VarArg(typ: T = ...) -> T: pass
1919

2020
def KwArg(typ: T = ...) -> T: pass

test-data/unit/pythoneval.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ print('hello, world')
1111
[out]
1212
hello, world
1313

14-
-- Skipped because different typing package versions have different repr()s.
14+
-- Skipped because different typing package versions have different repr()s.
1515
[case testAbstractBaseClasses-skip]
1616
import re
1717
from typing import Sized, Sequence, Iterator, Iterable, Mapping, AbstractSet
@@ -756,7 +756,7 @@ def f(*args: str) -> str: return args[0]
756756
map(f, ['x'])
757757
map(f, [1])
758758
[out]
759-
_program.py:4: error: Argument 1 to "map" has incompatible type Callable[[StarArg(str)], str]; expected Callable[[int], str]
759+
_program.py:4: error: Argument 1 to "map" has incompatible type Callable[[VarArg(str)], str]; expected Callable[[int], str]
760760

761761
[case testMapStr]
762762
import typing

0 commit comments

Comments
 (0)