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

Don't always infer unions for conditional expressions #5095

Merged
merged 2 commits into from
May 24, 2018

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 22, 2018

Use a join for type of a conditional expression unless the type context
is a union type.

A recent change (#5041) modified the type to always use a union, but this
caused many problems in internal Dropbox repos that we aren't ready to
fix yet.

Use a join for type of a conditional expression unless the type context
is a union type.

A recent change (#5041) modified the type to always use a union, but this
caused many problems in internal Dropbox repos that we aren't ready to
fix yet.
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comma in a comment.

@@ -2357,7 +2357,14 @@ 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)

res = UnionType.make_simplified_union([if_type, else_type])
# Only create a union type if the type context is a union to be mostly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comma before "to be mostly"

@msullivan
Copy link
Collaborator

Merging this, though I'd like to revert it at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants