8000 Don't always infer unions for conditional expressions by JukkaL · Pull Request #5095 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Don't always infer unions for conditional expressions #5095

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

Merged
merged 2 commits into from
May 24, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Update comment
  • Loading branch information
JukkaL committed May 22, 2018
commit 0280a6494b8c5831ae4131074284f62a1970fda8
4 changes: 2 additions & 2 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2357,8 +2357,8 @@ def visit_conditional_expr(self, e: ConditionalExpr) -> Type:
# branch's type.
else_type = self.analyze_cond_branch(else_map, e.else_expr, context=if_type)

# Only create a union type if the type context is a union to be mostly
# compatibile with older mypy versions where always did a join.
# Only create a union type if the type context is a union, to be mostly
# compatible with older mypy versions where we always did a join.
#
# TODO: Always create a union or at least in more cases?
if isinstance(self.type_context[-1], UnionType):
Expand Down
0