@@ -398,7 +398,7 @@ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool)
398
398
an_args = self .pack_paramspec_args (an_args )
399
399
400
400
disallow_any = self .options .disallow_any_generics and not self .is_typeshed_stub
401
- res = expand_type_alias (
401
+ res = instantiate_type_alias (
402
402
node ,
403
403
an_args ,
404
404
self .fail ,
@@ -408,7 +408,7 @@ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool)
408
408
unexpanded_type = t ,
409
409
disallow_any = disallow_any ,
410
410
)
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
412
412
# when it is top-level instance, so no need to recurse.
413
413
if (
414
414
isinstance (res , Instance ) # type: ignore[misc]
@@ -714,7 +714,7 @@ def analyze_type_with_type_info(
714
714
# The class has a Tuple[...] base class so it will be
715
715
# represented as a tuple type.
716
716
if info .special_alias :
717
- return expand_type_alias (
717
+ return instantiate_type_alias (
718
718
info .special_alias ,
719
719
# TODO: should we allow NamedTuples generic in ParamSpec?
720
720
self .anal_array (args ),
@@ -730,7 +730,7 @@ def analyze_type_with_type_info(
730
730
# The class has a TypedDict[...] base class so it will be
731
731
# represented as a typeddict type.
732
732
if info .special_alias :
733
- return expand_type_alias (
733
+ return instantiate_type_alias (
734
734
info .special_alias ,
735
735
# TODO: should we allow TypedDicts generic in ParamSpec?
736
736
self .anal_array (args ),
@@ -1713,7 +1713,7 @@ def fix_instance(
1713
1713
t .invalid = True
1714
1714
1715
1715
1716
- def expand_type_alias (
1716
+ def instantiate_type_alias (
1717
1717
node : TypeAlias ,
1718
1718
args : list [Type ],
1719
1719
fail : MsgCallback ,
@@ -1725,11 +1725,13 @@ def expand_type_alias(
1725
1725
disallow_any : bool = False ,
1726
1726
use_standard_error : bool = False ,
1727
1727
) -> 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 .
1729
1729
1730
+ We are following the rules outlined in TypeAlias docstring.
1730
1731
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)
1733
1735
fail: error reporter callback
1734
1736
no_args: whether original definition used a bare generic `A = List`
1735
1737
ctx: context where expansion happens
0 commit comments