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

[suggest] Support refining existing type annotations #7838

Merged
merged 10 commits into from
Nov 2, 2019
Merged

Conversation

msullivan
Copy link
Collaborator

No description provided.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Thanks! I have some comments here.

mypy/suggestions.py Outdated Show resolved Hide resolved
test-data/unit/fine-grained-suggest.test Outdated Show resolved Hide resolved
test-data/unit/fine-grained-suggest.test Show resolved Hide resolved
@msullivan
Copy link
Collaborator Author

I've rewritten the merge logic completely to not use either meet or join

@msullivan
Copy link
Collaborator Author

Oh wow this one that is failing only under mypyc is going to be exciting. That is frankly super rare!

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Looks great! I like the new logic.

mypy/suggestions.py Show resolved Hide resolved
new_items.append(lhs)

# We don't ever want to drop None while making these things and
# make_simplified_union calls join which cases
Copy link
Member

Choose a reason for hiding this comment

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

It looks like something is wrong with grammar here.

if isinstance(t, UnionType):
return refine_union(t, s)

return t
Copy link
Member

Choose a reason for hiding this comment

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

I would add couple special cases (not important however) for type and tuple. These two are represented by instances, but can be refined by Type[C] and Tuple[X, Y, ...].

@msullivan
Copy link
Collaborator Author

The failure with mypyc is due to #7854

@msullivan msullivan merged commit a4f4ffe into master Nov 2, 2019
@msullivan msullivan deleted the suggest-refine branch November 2, 2019 04:42
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.

2 participants