Skip to content

Commit

Permalink
Remove dead branch when analysing type aliases (#14566)
Browse files Browse the repository at this point in the history
Clean up from #14159
  • Loading branch information
hauntsaninja authored Jan 31, 2023
1 parent 28c67cb commit 1a781e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3373,7 +3373,7 @@ def analyze_alias(
tvar_def = self.tvar_scope.bind_new(name, tvar_expr)
tvar_defs.append(tvar_def)

res = analyze_type_alias(
analyzed, depends_on = analyze_type_alias(
typ,
self,
self.tvar_scope,
Expand All @@ -3385,13 +3385,8 @@ def analyze_alias(
global_scope=global_scope,
allowed_alias_tvars=tvar_defs,
)
analyzed: Type | None = None
if res:
analyzed, depends_on = res
qualified_tvars = [node.fullname for (name, node) in found_type_vars]
else:
depends_on = set()
qualified_tvars = []

qualified_tvars = [node.fullname for _name, node in found_type_vars]
return analyzed, tvar_defs, depends_on, qualified_tvars

def is_pep_613(self, s: AssignmentStmt) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ def analyze_type_alias(
in_dynamic_func: bool = False,
global_scope: bool = True,
allowed_alias_tvars: list[TypeVarLikeType] | None = None,
) -> tuple[Type, set[str]] | None:
) -> tuple[Type, set[str]]:
"""Analyze r.h.s. of a (potential) type alias definition.
If `node` is valid as a type alias rvalue, return the resulting type and a set of
full names of type aliases it depends on (directly or indirectly).
Return None otherwise. 'node' must have been semantically analyzed.
'node' must have been semantically analyzed.
"""
analyzer = TypeAnalyser(
api,
Expand Down

0 comments on commit 1a781e7

Please sign in to comment.