Skip to content

Commit 49d95cf

Browse files
authored
Don't add fictional parameters to NamedTuple._make() (#15578)
1 parent 5e4d097 commit 49d95cf

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

mypy/semanal_namedtuple.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,11 @@ def make_init_arg(var: Var) -> Argument:
605605

606606
add_method("__new__", ret=selftype, args=[make_init_arg(var) for var in vars], is_new=True)
607607
add_method("_asdict", args=[], ret=ordereddictype)
608-
special_form_any = AnyType(TypeOfAny.special_form)
609608
add_method(
610609
"_make",
611610
ret=selftype,
612611
is_classmethod=True,
613-
args=[
614-
Argument(Var("iterable", iterable_type), iterable_type, None, ARG_POS),
615-
Argument(Var("new"), special_form_any, EllipsisExpr(), ARG_NAMED_OPT),
616-
Argument(Var("len"), special_form_any, EllipsisExpr(), ARG_NAMED_OPT),
617-
],
612+
args=[Argument(Var("iterable", iterable_type), iterable_type, None, ARG_POS)],
618613
)
619614

620615
self_tvar_expr = TypeVarExpr(

test-data/unit/check-newsemanal.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ class SubO(Out): pass
992992

993993
o: SubO
994994

995-
reveal_type(SubO._make) # N: Revealed type is "def (iterable: typing.Iterable[Any], *, new: Any =, len: Any =) -> Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.SubO]"
995+
reveal_type(SubO._make) # N: Revealed type is "def (iterable: typing.Iterable[Any]) -> Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.SubO]"
996996
reveal_type(o._replace(y=Other())) # N: Revealed type is "Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.SubO]"
997997
[builtins fixtures/tuple.pyi]
998998

@@ -1009,7 +1009,7 @@ o: Out
10091009
reveal_type(o) # N: Revealed type is "Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.Out]"
10101010
reveal_type(o.x) # N: Revealed type is "Tuple[builtins.str, __main__.Other, fallback=__main__.In]"
10111011
reveal_type(o.x.t) # N: Revealed type is "__main__.Other"
1012-
reveal_type(Out._make) # N: Revealed type is "def (iterable: typing.Iterable[Any], *, new: Any =, len: Any =) -> Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.Out]"
1012+
reveal_type(Out._make) # N: Revealed type is "def (iterable: typing.Iterable[Any]) -> Tuple[Tuple[builtins.str, __main__.Other, fallback=__main__.In], __main__.Other, fallback=__main__.Out]"
10131013
[builtins fixtures/tuple.pyi]
10141014

10151015
[case testNewAnalyzerIncompleteRefShadowsBuiltin1]

0 commit comments

Comments
 (0)