Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead branch when analysing type aliases #14566

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3334,7 +3334,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 @@ -3346,13 +3346,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