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

feat: refactor AccessEntry to use _properties pattern #1125

Merged
merged 51 commits into from
Apr 8, 2022

Conversation

steffnay
Copy link
Contributor

@steffnay steffnay commented Jan 31, 2022

  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1077 🦕

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Jan 31, 2022
@steffnay steffnay marked this pull request as ready for review February 5, 2022 21:21
@steffnay steffnay requested a review from a team February 5, 2022 21:21
@steffnay steffnay requested a review from a team as a code owner February 5, 2022 21:21
@steffnay steffnay requested review from tswast and removed request for stephaniewang526 February 5, 2022 21:55
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Looking pretty good! I made a few suggestions to use get(...), _get_sub_prop, and _set_sub_prop.

I think we'll need some more unit tests that exercise getting the various properties when they aren't set. Make sure they get None (or whatever the desired default is) instead of raising a KeyError.

google/cloud/bigquery/dataset.py Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
@steffnay steffnay requested a review from tswast February 16, 2022 16:35
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Much better! A few small things

google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
Co-authored-by: Tim Swast <swast@google.com>
@steffnay steffnay requested a review from tswast March 18, 2022 20:12
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Sweet! I think the behavior is right now. Just a nit re: what we're storing in _properties. I'd like us to stay consistent with the other resource classes.

def dataset(self) -> Optional[DatasetReference]:
"""API resource representation of a dataset reference."""
return typing.cast(
Optional[DatasetReference],
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd actually like to see _properties store the REST API version and the property getter call from_api_repr. Same for the other properties.

@steffnay steffnay requested a review from tswast March 29, 2022 17:52
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Looking really good! I'll approve, but there are a few edge cases you'll want to handle before merging.

google/cloud/bigquery/dataset.py Outdated Show resolved Hide resolved
google/cloud/bigquery/dataset.py Show resolved Hide resolved
google/cloud/bigquery/dataset.py Show resolved Hide resolved
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Apr 7, 2022
@steffnay steffnay merged commit acd5612 into googleapis:main Apr 8, 2022
@steffnay steffnay deleted the access-entry-refactor branch April 8, 2022 19:52
waltaskew pushed a commit to waltaskew/python-bigquery that referenced this pull request Jul 20, 2022
* add view, dataset, routine properties

* add properties and unit tests

* lint

* add properties and tests

* remove unused imports

* update test

* add tests

* add tests

* add tests

* add more tests

* update return type

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* refactor to use get() and remove self._entity_id

* delete unnecessary file

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* add types, remove unnecessary checks

* fix types

* types

* add type casting

* refactor AccessEntry repr

* update to return DatasetReference

* update to use RoutineRef and TableRef

* add table test

* update to use api_repr

* lint

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* update tests

* remove repeat type import

Co-authored-by: Tim Swast <swast@google.com>
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
* add view, dataset, routine properties

* add properties and unit tests

* lint

* add properties and tests

* remove unused imports

* update test

* add tests

* add tests

* add tests

* add more tests

* update return type

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* refactor to use get() and remove self._entity_id

* delete unnecessary file

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* add types, remove unnecessary checks

* fix types

* types

* add type casting

* refactor AccessEntry repr

* update to return DatasetReference

* update to use RoutineRef and TableRef

* add table test

* update to use api_repr

* lint

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* Update google/cloud/bigquery/dataset.py

Co-authored-by: Tim Swast <swast@google.com>

* update tests

* remove repeat type import

Co-authored-by: Tim Swast <swast@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor AccessEntry to use _properties pattern
2 participants