-
Notifications
You must be signed in to change notification settings - Fork 7
Issue/639 allow iteration over dict keys #9882
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
Open
Hugo-Inmanta
wants to merge
6
commits into
master
Choose a base branch
from
issue/639-allow-iteration-over-dict-keys
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−9
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| description: Add support in the Inmanta DSL to iterate over dictionary keys in for loops. | ||
| issue-nr: 639 | ||
| change-type: minor | ||
| destination-branches: [master, iso8] | ||
| sections: | ||
| minor-improvement: "{{description}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to type this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you did here, but I don't feel that we should propagate the dicts this deeply. For one thing, dicts aren't always flattenable. While in the DSL we have no nested lists, we can have dicts inside lists. In other words
[[1], [2]]is equivalent to[1, 2], but[{"a": "b"}]is not equivalent to{"a": "b"}or to["a"].I can imagine it may be difficult to understand the full implications of this, considering that this is quite an advanced method in a codebase you're only partially familiar with. The model below might help illustrate it. When compiled on master, it prints
@{'a': 1, 'b': 2}. On your branch, it prints that, preceded withaandb. The fact that it prints both is actually due to the lack of a consistency safeguard in the for loop. The list comprehension does have it. If such a safeguard where there, the compiler would raise an exception instead. Either way, this is clearly not the intention.All this said, what would be the appropriate location to handle this? I was going to say
For.execute(), which is mostly just a type check, andGradualFor.receive_result. But as I type this I realize thatGradualFor.receive_resultwill also need some way to determine whether it should or should not iterate any dict values it receives. And I don't have an immediate solution for it. I'll get back to this tomorrow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to think that this will be a major hurdle, and that we should go for the plugin after all. We can discuss it tomorrow.