-
Notifications
You must be signed in to change notification settings - Fork 316
refactor: extract common logic to TableBase class #956
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
Conversation
google/cloud/bigquery/table.py
Outdated
@@ -126,45 +127,93 @@ def _view_use_legacy_sql_getter(table): | |||
return True | |||
|
|||
|
|||
class TableReference(object): | |||
"""TableReferences are pointers to tables. | |||
class TableBase: |
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.
Let's either make this private (_TableBase
) or document it + update relevant types in the client
module.
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 don't see the end users using TableBase
directly, it just serves as a central place where we keep the common functionality. An implementation detail, in other words.
Let's mark it as private.
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.
The contrarian point is that parameter types might use a public TableBase
to signal the minimal contract that their arguments require, which is more focused than Union[Table, TableRef, ...]
. I don't see any case where TableBase
as a return type make sense.
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.
After some thought I'm leaning towards keeping the base class private if the main reason for making it public is cleaner type annotations. I view type annotations more as an optional helper, and not as an end goal that would require adjusting the code just for the annotations' sake. As a bonus we still have an option to define our own TableType
alias if we don't like Union[Table, ...]
.
Or does anybody have a strong contrary opinion here?
* refactor: extract common logic to TableBase class * Adress pytype's missing attribute false warning * Mark TableBase class as private * Simplify TableReference.to_api_repr() logic * Avoid get/set subproperty helper gotcha * Test _TableBase class directly
Closes #871.
PR checklist: