Skip to content

Check tuples of abstract types#15366

Merged
sobolevn merged 5 commits into
masterfrom
issue-15264
Jul 12, 2023
Merged

Check tuples of abstract types#15366
sobolevn merged 5 commits into
masterfrom
issue-15264

Conversation

@sobolevn

@sobolevn sobolevn commented Jun 4, 2023

Copy link
Copy Markdown
Member

The PR is quite simple (and I would like to keep it this way):

  • Before we were only checking type[] type
  • Now we also check tuple[type[], ...] type

There might be other types that we want to add in the future here: TypedDictType, etc?
But, let's do it one by one, because smaller PRs are easier to merge :)

Closes #15264

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@sobolevn
sobolevn requested a review from hauntsaninja June 4, 2023 11:05
@ikonst

ikonst commented Jun 12, 2023

Copy link
Copy Markdown
Contributor

First impression: shouldn't there be something else that recurses into a tuple already to validate types of items, so we could avoid teaching has_abstract_type_part about TupleType (and then about TypedDictType etc.) ?

@sobolevn

Copy link
Copy Markdown
Member Author

I don't see a clean way to do that.

@JukkaL

JukkaL commented Jul 12, 2023

Copy link
Copy Markdown
Collaborator

I don't see a clean way to do that.

What about just leaving a TODO comment about this, in case somebody figures out a good way to do that?

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Even if this doesn't fully solve the issue, this seems like a reasonably incremental improvement, though it would be good to add a comment explaining that this is incomplete (and perhaps why), as I mentioned in my other comment.

Comment thread mypy/checkexpr.py
@sobolevn

Copy link
Copy Markdown
Member Author

@JukkaL thanks for the review! I've left a TODO note for future work :)
I will merge it once CI passes.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sobolevn
sobolevn merged commit edb41e0 into master Jul 12, 2023
@sobolevn
sobolevn deleted the issue-15264 branch July 12, 2023 15:27
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.

False-negative type-abstract in dictionary initialization

3 participants