Skip to content

Remove 'Bucket.__iter__' and 'Bucket.__contains__'. - #877

Merged
tseaver merged 2 commits into
googleapis:masterfrom
tseaver:storage-remove_bucket___iter___and___contains__
May 14, 2015
Merged

Remove 'Bucket.__iter__' and 'Bucket.__contains__'.#877
tseaver merged 2 commits into
googleapis:masterfrom
tseaver:storage-remove_bucket___iter___and___contains__

Conversation

@tseaver

Copy link
Copy Markdown
Contributor

Both are "sugar" over other methods, but do not allow passing an explicit connection.

In addition, Bucket.__iter__ has scaling issues, which cannot be mitigated using the filtering parameters accepted by Bucket.list_blobs.

Moved to a new PR from #876.

@tseavertseaver added the api: storage Issues related to the Cloud Storage API. label May 13, 2015
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label May 13, 2015
@dhermes

Copy link
Copy Markdown
Contributor

Big time test failure here. Do you know why?

@tseaver

Copy link
Copy Markdown
ContributorAuthor

I ran the tests in a different shell, which I closed accidentally before committing. :(

I will rebase / fix after merging #876.

@tseaver

Copy link
Copy Markdown
ContributorAuthor

@dhermes rebased.

Comment threadgcloud/storage/bucket.py Outdated

This comment was marked as spam.

This comment was marked as spam.

@dhermes

Copy link
Copy Markdown
Contributor

So the reason I asked you to peel this off from #876 was really so we could discuss if this should happen.

I have never really liked the methods, but some may like them. So let's discuss?

@tseaver

Copy link
Copy Markdown
ContributorAuthor

To clarify what we are discussiing: first, we are removing:

ifblob_nameinbucket:
do_something()

which is a syntactic alias for:

blob=Blob(blob_name, bucket)
ifblob.exists():
do_something()

Note that do_something() likely needs to construct the Blob anyway, which makes the second a lot more natural. The second form also allows us to override the connection used by the exists() call, if desired.

Second, we are removing:

forblobinbucket:
do_something(blob)

which is a syntactic alias for:

forblobinbucket.list_blobs():
do_something(blob)

Here, the list_blobs() form allows us to override the connection used, if desired, as well as providing filtering parameters to minimize the set of returned blobs: the latter could be crucial for dealing with very large buckets.

@tseavertseaver added the type: question Request for information or clarification. Not an issue. label May 14, 2015
Both are 'sugar' over other methods, but do not allow passing an explicit
connection.
In addition, 'Bucket.__iter__' has scaling issues, which cannot be mitigated
using the filtering parameters accepted by 'Bucket.list_blobs'.
@dhermes

Copy link
Copy Markdown
Contributor

@jgeewax Are you OK with us removing this?

I am on-board with this change.

@jgeewax

Copy link
Copy Markdown
Contributor

I'm down with removing the methods, but we need to update the docs in the same PR, right? (https://googlecloudplatform.github.io/gcloud-python/latest/storage-buckets.html refers to for blob in bucket and print 'blob' in bucket.)

@dhermes

Copy link
Copy Markdown
Contributor

+1

@tseaver

Copy link
Copy Markdown
ContributorAuthor

@jgeewax3a3edb4 removes the docstring examples which referred to the sugar.

tseaver added a commit that referenced this pull request May 14, 2015
…nd___contains__
Remove 'Bucket.__iter__' and 'Bucket.__contains__'.
@tseaver
tseaver merged commit fd73bcf into googleapis:masterMay 14, 2015
@tseaver
tseaver deleted the storage-remove_bucket___iter___and___contains__ branch May 14, 2015 20:11
@dhermesdhermes mentioned this pull request Jun 4, 2015
parthea pushed a commit that referenced this pull request Sep 18, 2025
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Tim Sweña (Swast) <swast@google.com>
parthea pushed a commit that referenced this pull request Nov 22, 2025
Source-Link: googleapis/synthtool@d52e638
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:4f9b3b106ad0beafc2c8a415e3f62c1a0cc23cabea115dbe841b848f581cfe99
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [click](https://palletsprojects.com/p/click/) ([changelog](https://click.palletsprojects.com/changes/)) | `==7.1.2` -> `==8.0.0` | [![age](https://badges.renovateapi.com/packages/pypi/click/8.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/click/8.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/click/8.0.0/compatibility-slim/7.1.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/click/8.0.0/confidence-slim/7.1.2)](https://docs.renovatebot.com/merge-confidence/) |
---
### Configuration
📅 **Schedule**: At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻️ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.
---
This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/gapic-generator-python).
parthea added a commit that referenced this pull request Nov 24, 2025
* chore(deps): update all dependencies
* pin importlib-resources for python 3.7
* revert urllib3
---------
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
… in Cloud Run Jobs (#877)
* fix: Added environment specific labels to client library when running in
Cloud Run Jobs
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* Removed unnecessary import
* Changed unit tests to pytest
* Renamed add_environmental_labels to add_resource_labels; cached portions of add_resource_labels
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* Updated comments and _get_environmental_labels
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 25, 2025
… in Cloud Run Jobs (#877)
* fix: Added environment specific labels to client library when running in
Cloud Run Jobs
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* Removed unnecessary import
* Changed unit tests to pytest
* Renamed add_environmental_labels to add_resource_labels; cached portions of add_resource_labels
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* Updated comments and _get_environmental_labels
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 26, 2025
While service account impersonation is uncommonly used with workforce
pool external credentials, there is a bug where the following commands
raise exceptions when impersonated workforce pools are used:
- `google.auth.default()`
- `google.auth.load_credentials_from_file()`
The issue is due to `google.auth.aws.Credentials` not supporting the
`workforce_pool_user_project` argument in the constructor, unlike
`google.auth.identity_pool.Credentials`.
This was indirectly passed here:
https://github.com/googleapis/google-auth-library-python/blob/a37ff00d7afd6c7aac2d0fab29e05708bbc068be/google/auth/external_account.py#L395
Causing a TypeError to be raised (we only catch ValueError).
Updated the credential determination logic to explicitly check the
subject token type. This is a more reliable indicator instead of a
try/catch.
Increased unit test coverage in tests/test__default.py to cover these
credentials.
parthea pushed a commit that referenced this pull request Feb 13, 2026
Require Python 3.9+
Require protobuf 4.25.8+
Simplify code accordingly.
Fixes#15019 This also required removing 3.7 and 3.8 as required checks in the repo
config, under branch protection rules.
parthea pushed a commit that referenced this pull request Mar 6, 2026
Source-Link: googleapis/synthtool@facee4c
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:9743664022bd63a8084be67f144898314c7ca12f0a03e422ac17c733c129d803
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 9, 2026
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storageIssues related to the Cloud Storage API.cla: yesThis human has signed the Contributor License Agreement.type: questionRequest for information or clarification. Not an issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@tseaver@dhermes@jgeewax@googlebot