@@ -398,7 +398,7 @@ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool)
398398 an_args = self .pack_paramspec_args (an_args )
399399
400400 disallow_any = self .options .disallow_any_generics and not self .is_typeshed_stub
401- res = expand_type_alias (
401+ res = instantiate_type_alias (
402402 node ,
403403 an_args ,
404404 self .fail ,
@@ -408,7 +408,7 @@ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool)
408408 unexpanded_type = t ,
409409 disallow_any = disallow_any ,
410410 )
411- # The only case where expand_type_alias () can return an incorrect instance is
411+ # The only case where instantiate_type_alias () can return an incorrect instance is
412412 # when it is top-level instance, so no need to recurse.
413413 if (
414414 isinstance (res , Instance ) # type: ignore[misc]
@@ -714,7 +714,7 @@ def analyze_type_with_type_info(
714714 # The class has a Tuple[...] base class so it will be
715715 # represented as a tuple type.
716716 if info .special_alias :
717- return expand_type_alias (
717+ return instantiate_type_alias (
718718 info .special_alias ,
719719 # TODO: should we allow NamedTuples generic in ParamSpec?
720720 self .anal_array (args ),
@@ -730,7 +730,7 @@ def analyze_type_with_type_info(
730730 # The class has a TypedDict[...] base class so it will be
731731 # represented as a typeddict type.
732732 if info .special_alias :
733- return expand_type_alias (
733+ return instantiate_type_alias (
734734 info .special_alias ,
735735 # TODO: should we allow TypedDicts generic in ParamSpec?
736736 self .anal_array (args ),
@@ -1713,7 +1713,7 @@ def fix_instance(
17131713 t .invalid = True
17141714
17151715
1716- def expand_type_alias (
1716+ def instantiate_type_alias (
17171717 node : TypeAlias ,
17181718 args : list [Type ],
17191719 fail : MsgCallback ,
@@ -1725,11 +1725,13 @@ def expand_type_alias(
17251725 disallow_any : bool = False ,
17261726 use_standard_error : bool = False ,
17271727) -> Type :
1728- """Expand a (generic) type alias target following the rules outlined in TypeAlias docstring .
1728+ """Create an instance of a (generic) type alias from alias node and type arguments .
17291729
1730+ We are following the rules outlined in TypeAlias docstring.
17301731 Here:
1731- target: original target type
1732- args: types to be substituted in place of type variables
1732+ node: type alias node (definition)
1733+ args: type arguments (types to be substituted in place of type variables
1734+ when expanding the alias)
17331735 fail: error reporter callback
17341736 no_args: whether original definition used a bare generic `A = List`
17351737 ctx: context where expansion happens
0 commit comments