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

[REF-2682] Foreach over dict uses Tuple arg value #3160

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Apr 24, 2024

When iterating over a Var with _var_type dict, the resulting arg value _var_type should be Tuple[key, value] so it can be correctly used with other var operations.

Fix #3157


Additionally: Correct _var_type for iteration over Tuple of multiple types

The arg value when iterating over a tuple could be any of the possible values mentioned in the annotation.

When only one type is used, the Union collapses to the base type


The type ignore comments are there because pyright doesn't like the fact that i'm passing an unknown tuple to Tuple and Union __getitem__, but this is essentially identical to writing a literal tuple inside the square brackets.

When iterating over a Var with _var_type dict, the resulting arg value
_var_type should be Tuple[key, value] so it can be correctly used with other
var operations.

Fix #3157
The arg value when iterating over a tuple could be any of the possible values
mentioned in the annotation.

When only one type is used, the Union collapses to the base type, at least in py3.11
Copy link

linear bot commented Apr 24, 2024

picklelo
picklelo previously approved these changes Apr 24, 2024
@masenf masenf merged commit 0a8aaea into main Apr 25, 2024
46 checks passed
@masenf masenf deleted the masenf/dict-iterable-var-type branch April 25, 2024 16:11
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.

[REF-2682] Foreach over dict gets incorrect arg type
2 participants