GeezerVison is showing github.com — fix: save empty IAM policy bindings by busunkim96 · Pull Request #155 · googleapis/python-api-core
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Conversation
busunkim96
commented
Mar 22, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #154
__getitem__ currently returns an empty set() for items not in the bindings. If someone adds to the set returned by __getitem__ the changes will not be reflected on the actual policy object.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+35
to
+36
|
|
assert len(policy) == 0
|
|
|
assert dict(policy) == {}
|
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.
Accessing policy.owners, policy.editors results in __getitem__ being called, which adds empty entries to the dictionary. I moved these empty dict asserts up as a result.
An alternative is to keep them in their previous location and check that the three roles with empty bindings were added
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gcf-merge-on-green Bot
pushed a commit
that referenced
this pull request
Mar 25, 2021
Exclude empty policy bindings (bindings with no members) in
`Policy.__iter__()` and `Policy.__len__()`
Follow up to #155
This was referenced May 30, 2025
Reviewers
frankyn
Awaiting requested review from frankyn
1 more reviewer
parthea
parthea approved these changes
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
cla: yes
This human has signed the Contributor License Agreement.
Milestone
No milestone
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.