def def_alias_2(self, base: Instance) -> Tuple[TypeAliasType, Type]: A = TypeAliasType(None, []) target = UnionType([base, Instance(self.std_tuplei, [A])]) # A = Union[base, Tuple[A, ...]] AN = TypeAlias(target, '__main__.A', -1, -1) A.alias = AN return A, target
def visit_type_alias_type(self, t: TypeAliasType) -> None: type_ref = t.type_ref if type_ref is None: return # We've already been here. t.type_ref = None t.alias = lookup_qualified_alias(self.modules, type_ref, self.allow_missing) for a in t.args: a.accept(self)
def non_rec_alias(self, target: Type) -> TypeAliasType: AN = TypeAlias(target, '__main__.A', -1, -1) return TypeAliasType(AN, [])
def visit_type_alias_type(self, t: TypeAliasType) -> Type: return t.copy_modified(args=[a.accept(self) for a in t.args])
def visit_type_alias_type(self, t: TypeAliasType) -> Type: exp_t = get_proper_type(t) if isinstance(exp_t, Instance) and exp_t.type.fullname == 'builtins.str': return self.text_type return t.copy_modified(args=[a.accept(self) for a in t.args])
def visit_type_alias_type(self, typ: TypeAliasType) -> None: assert typ.alias is not None typ.alias = self.fixup(typ.alias) for arg in typ.args: arg.accept(self)
def visit_type_alias_type(self, t: TypeAliasType) -> Type: # Target of the type alias cannot contain type variables, # so we just expand the arguments. return t.copy_modified(args=self.expand_types(t.args))
def visit_type_alias_type(self, t: TypeAliasType) -> Type: # Type alias target can't contain bound type variables, so # it is safe to just erase the arguments. return t.copy_modified(args=[a.accept(self) for a in t.args])