diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7e08e05a3..87dd00611 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fff7ddb0..f3970bfd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ [1]: https://pypi.org/project/google-cloud-bigquery/#history +### [2.34.3](https://github.com/googleapis/python-bigquery/compare/v2.34.2...v2.34.3) (2022-03-29) + + +### Bug Fixes + +* update content-type header ([#1171](https://github.com/googleapis/python-bigquery/issues/1171)) ([921b440](https://github.com/googleapis/python-bigquery/commit/921b440fdd151e88ee5b3e0d9fb90177877dc11a)) + ### [2.34.2](https://github.com/googleapis/python-bigquery/compare/v2.34.1...v2.34.2) (2022-03-05) diff --git a/docs/conf.py b/docs/conf.py index bb16445ca..296eac02a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -362,7 +362,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/bigquery/_pandas_helpers.py b/google/cloud/bigquery/_pandas_helpers.py index 263a1a9cf..da7c999bd 100644 --- a/google/cloud/bigquery/_pandas_helpers.py +++ b/google/cloud/bigquery/_pandas_helpers.py @@ -585,7 +585,10 @@ def dataframe_to_parquet( bq_schema = schema._to_schema_fields(bq_schema) arrow_table = dataframe_to_arrow(dataframe, bq_schema) pyarrow.parquet.write_table( - arrow_table, filepath, compression=parquet_compression, **kwargs, + arrow_table, + filepath, + compression=parquet_compression, + **kwargs, ) diff --git a/google/cloud/bigquery/_tqdm_helpers.py b/google/cloud/bigquery/_tqdm_helpers.py index 632f70f87..f2355ab3b 100644 --- a/google/cloud/bigquery/_tqdm_helpers.py +++ b/google/cloud/bigquery/_tqdm_helpers.py @@ -95,7 +95,9 @@ def wait_for_query( progress_bar.total = len(query_job.query_plan) progress_bar.set_description( "Query executing stage {} and status {} : {:0.2f}s".format( - current_stage.name, current_stage.status, time.time() - start_time, + current_stage.name, + current_stage.status, + time.time() - start_time, ), ) try: diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index a5f3d5419..a99e8fcb4 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -1894,9 +1894,7 @@ def _get_query_results( def job_from_resource( self, resource: dict - ) -> Union[ - job.CopyJob, job.ExtractJob, job.LoadJob, job.QueryJob, job.UnknownJob, - ]: + ) -> Union[job.CopyJob, job.ExtractJob, job.LoadJob, job.QueryJob, job.UnknownJob]: """Detect correct job type from resource and instantiate. Args: @@ -1978,8 +1976,8 @@ def create_job( timeout=timeout, ) elif "extract" in job_config: - extract_job_config = google.cloud.bigquery.job.ExtractJobConfig.from_api_repr( - job_config + extract_job_config = ( + google.cloud.bigquery.job.ExtractJobConfig.from_api_repr(job_config) ) source = _get_sub_prop(job_config, ["extract", "sourceTable"]) if source: @@ -2152,7 +2150,8 @@ def cancel_job( job_instance = self.job_from_resource(resource["job"]) # never an UnknownJob return typing.cast( - Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob], job_instance, + Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob], + job_instance, ) def list_jobs( @@ -4127,7 +4126,7 @@ def _get_upload_headers(user_agent): "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "User-Agent": user_agent, - "content-type": "application/json", + "content-type": "application/json; charset=UTF-8", } diff --git a/google/cloud/bigquery/dataset.py b/google/cloud/bigquery/dataset.py index 499072de2..cf317024f 100644 --- a/google/cloud/bigquery/dataset.py +++ b/google/cloud/bigquery/dataset.py @@ -191,7 +191,7 @@ def __repr__(self): ) def _key(self): - """ A tuple key that uniquely describes this field. + """A tuple key that uniquely describes this field. Used to compute this instance's hashcode and evaluate equality. Returns: Tuple: The contents of this :class:`~google.cloud.bigquery.dataset.AccessEntry`. diff --git a/google/cloud/bigquery/dbapi/_helpers.py b/google/cloud/bigquery/dbapi/_helpers.py index e5c7ef7ec..30f40ea07 100644 --- a/google/cloud/bigquery/dbapi/_helpers.py +++ b/google/cloud/bigquery/dbapi/_helpers.py @@ -486,8 +486,7 @@ def raise_on_closed( """Make public instance methods raise an error if the instance is closed.""" def _raise_on_closed(method): - """Make a non-static method raise an error if its containing instance is closed. - """ + """Make a non-static method raise an error if its containing instance is closed.""" def with_closed_check(self, *args, **kwargs): if getattr(self, closed_attr_name): @@ -498,8 +497,7 @@ def with_closed_check(self, *args, **kwargs): return with_closed_check def decorate_public_methods(klass): - """Apply ``_raise_on_closed()`` decorator to public instance methods. - """ + """Apply ``_raise_on_closed()`` decorator to public instance methods.""" for name in dir(klass): if name.startswith("_") and name != "__iter__": continue diff --git a/google/cloud/bigquery/external_config.py b/google/cloud/bigquery/external_config.py index e6f6a97c3..847049809 100644 --- a/google/cloud/bigquery/external_config.py +++ b/google/cloud/bigquery/external_config.py @@ -289,8 +289,7 @@ def from_api_repr(cls, resource: dict) -> "BigtableColumnFamily": class BigtableOptions(object): - """Options that describe how to treat Bigtable tables as BigQuery tables. - """ + """Options that describe how to treat Bigtable tables as BigQuery tables.""" _SOURCE_FORMAT = "BIGTABLE" _RESOURCE_NAME = "bigtableOptions" @@ -557,7 +556,11 @@ def from_api_repr(cls, resource: dict) -> "GoogleSheetsOptions": ) OptionsType = Union[ - AvroOptions, BigtableOptions, CSVOptions, GoogleSheetsOptions, ParquetOptions, + AvroOptions, + BigtableOptions, + CSVOptions, + GoogleSheetsOptions, + ParquetOptions, ] diff --git a/google/cloud/bigquery/job/query.py b/google/cloud/bigquery/job/query.py index 2fd7afb76..54f950a66 100644 --- a/google/cloud/bigquery/job/query.py +++ b/google/cloud/bigquery/job/query.py @@ -324,7 +324,8 @@ def connection_properties(self) -> List[ConnectionProperty]: @connection_properties.setter def connection_properties(self, value: Iterable[ConnectionProperty]): self._set_sub_prop( - "connectionProperties", [prop.to_api_repr() for prop in value], + "connectionProperties", + [prop.to_api_repr() for prop in value], ) @property diff --git a/google/cloud/bigquery/magics/magics.py b/google/cloud/bigquery/magics/magics.py index 7b4d584fb..a5941158e 100644 --- a/google/cloud/bigquery/magics/magics.py +++ b/google/cloud/bigquery/magics/magics.py @@ -586,7 +586,9 @@ def _cell_magic(line, query): bqstorage_client_options.api_endpoint = args.bqstorage_api_endpoint bqstorage_client = _make_bqstorage_client( - client, use_bqstorage_api, bqstorage_client_options, + client, + use_bqstorage_api, + bqstorage_client_options, ) close_transports = functools.partial(_close_transports, client, bqstorage_client) @@ -637,7 +639,8 @@ def _cell_magic(line, query): return result = rows.to_dataframe( - bqstorage_client=bqstorage_client, create_bqstorage_client=False, + bqstorage_client=bqstorage_client, + create_bqstorage_client=False, ) if args.destination_var: IPython.get_ipython().push({args.destination_var: result}) diff --git a/google/cloud/bigquery/opentelemetry_tracing.py b/google/cloud/bigquery/opentelemetry_tracing.py index 748f2136d..adecea121 100644 --- a/google/cloud/bigquery/opentelemetry_tracing.py +++ b/google/cloud/bigquery/opentelemetry_tracing.py @@ -37,28 +37,28 @@ @contextmanager def create_span(name, attributes=None, client=None, job_ref=None): """Creates a ContextManager for a Span to be exported to the configured exporter. - If no configuration exists yields None. - - Args: - name (str): Name that will be set for the span being created - attributes (Optional[dict]): - Additional attributes that pertain to - the specific API call (i.e. not a default attribute) - client (Optional[google.cloud.bigquery.client.Client]): - Pass in a Client object to extract any attributes that may be - relevant to it and add them to the created spans. - job_ref (Optional[google.cloud.bigquery.job._AsyncJob]) - Pass in a _AsyncJob object to extract any attributes that may be - relevant to it and add them to the created spans. - - Yields: - opentelemetry.trace.Span: Yields the newly created Span. - - Raises: - google.api_core.exceptions.GoogleAPICallError: - Raised if a span could not be yielded or issue with call to - OpenTelemetry. - """ + If no configuration exists yields None. + + Args: + name (str): Name that will be set for the span being created + attributes (Optional[dict]): + Additional attributes that pertain to + the specific API call (i.e. not a default attribute) + client (Optional[google.cloud.bigquery.client.Client]): + Pass in a Client object to extract any attributes that may be + relevant to it and add them to the created spans. + job_ref (Optional[google.cloud.bigquery.job._AsyncJob]) + Pass in a _AsyncJob object to extract any attributes that may be + relevant to it and add them to the created spans. + + Yields: + opentelemetry.trace.Span: Yields the newly created Span. + + Raises: + google.api_core.exceptions.GoogleAPICallError: + Raised if a span could not be yielded or issue with call to + OpenTelemetry. + """ global _warned_telemetry final_attributes = _get_final_span_attributes(attributes, client, job_ref) if not HAS_OPENTELEMETRY: diff --git a/google/cloud/bigquery/query.py b/google/cloud/bigquery/query.py index 637be62be..0b90b6954 100644 --- a/google/cloud/bigquery/query.py +++ b/google/cloud/bigquery/query.py @@ -363,8 +363,7 @@ def __repr__(self): class _AbstractQueryParameter(object): - """Base class for named / positional query parameters. - """ + """Base class for named / positional query parameters.""" @classmethod def from_api_repr(cls, resource: dict) -> "_AbstractQueryParameter": diff --git a/google/cloud/bigquery/schema.py b/google/cloud/bigquery/schema.py index 2af61b672..84272228f 100644 --- a/google/cloud/bigquery/schema.py +++ b/google/cloud/bigquery/schema.py @@ -417,8 +417,7 @@ def __init__(self, names: Iterable[str] = ()): @property def names(self): - """Tuple[str]: Policy tags associated with this definition. - """ + """Tuple[str]: Policy tags associated with this definition.""" return self._properties.get("names", ()) def _key(self): diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index a0696f83f..f39945fe4 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -213,7 +213,9 @@ def __init__(self, dataset_ref: "DatasetReference", table_id: str): dataset_ref.dataset_id, ) _helpers._set_sub_prop( - self._properties, self._PROPERTY_TO_API_FIELD["table_id"], table_id, + self._properties, + self._PROPERTY_TO_API_FIELD["table_id"], + table_id, ) @classmethod @@ -886,7 +888,9 @@ def mview_refresh_interval(self, value): api_field = self._PROPERTY_TO_API_FIELD["mview_refresh_interval"] _helpers._set_sub_prop( - self._properties, [api_field, "refreshIntervalMs"], refresh_interval_ms, + self._properties, + [api_field, "refreshIntervalMs"], + refresh_interval_ms, ) @property @@ -1598,7 +1602,8 @@ def total_rows(self): return self._total_rows def _maybe_warn_max_results( - self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"], + self, + bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"], ): """Issue a warning if BQ Storage client is not ``None`` with ``max_results`` set. diff --git a/google/cloud/bigquery/version.py b/google/cloud/bigquery/version.py index 66368e2cd..385cb3c75 100644 --- a/google/cloud/bigquery/version.py +++ b/google/cloud/bigquery/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.34.2" +__version__ = "2.34.3" diff --git a/google/cloud/bigquery_v2/types/encryption_config.py b/google/cloud/bigquery_v2/types/encryption_config.py index d300a417c..9f57acb7c 100644 --- a/google/cloud/bigquery_v2/types/encryption_config.py +++ b/google/cloud/bigquery_v2/types/encryption_config.py @@ -19,7 +19,10 @@ __protobuf__ = proto.module( - package="google.cloud.bigquery.v2", manifest={"EncryptionConfiguration",}, + package="google.cloud.bigquery.v2", + manifest={ + "EncryptionConfiguration", + }, ) @@ -36,7 +39,9 @@ class EncryptionConfiguration(proto.Message): """ kms_key_name = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.StringValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.StringValue, ) diff --git a/google/cloud/bigquery_v2/types/model.py b/google/cloud/bigquery_v2/types/model.py index f2c031715..7786d8ea4 100644 --- a/google/cloud/bigquery_v2/types/model.py +++ b/google/cloud/bigquery_v2/types/model.py @@ -252,8 +252,7 @@ class FeedbackType(proto.Enum): EXPLICIT = 2 class SeasonalPeriod(proto.Message): - r""" - """ + r""" """ class SeasonalPeriodType(proto.Enum): r"""""" @@ -266,8 +265,7 @@ class SeasonalPeriodType(proto.Enum): YEARLY = 6 class KmeansEnums(proto.Message): - r""" - """ + r""" """ class KmeansInitializationMethod(proto.Enum): r"""Indicates the method used to initialize the centroids for @@ -296,19 +294,29 @@ class RegressionMetrics(proto.Message): """ mean_absolute_error = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, ) mean_squared_error = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) mean_squared_log_error = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=3, + message=wrappers_pb2.DoubleValue, ) median_absolute_error = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=4, + message=wrappers_pb2.DoubleValue, ) r_squared = proto.Field( - proto.MESSAGE, number=5, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=5, + message=wrappers_pb2.DoubleValue, ) class AggregateClassificationMetrics(proto.Message): @@ -352,23 +360,39 @@ class AggregateClassificationMetrics(proto.Message): """ precision = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, + ) + recall = proto.Field( + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) - recall = proto.Field(proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue,) accuracy = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=3, + message=wrappers_pb2.DoubleValue, ) threshold = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=4, + message=wrappers_pb2.DoubleValue, ) f1_score = proto.Field( - proto.MESSAGE, number=5, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=5, + message=wrappers_pb2.DoubleValue, ) log_loss = proto.Field( - proto.MESSAGE, number=6, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, ) roc_auc = proto.Field( - proto.MESSAGE, number=7, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=7, + message=wrappers_pb2.DoubleValue, ) class BinaryClassificationMetrics(proto.Message): @@ -417,43 +441,69 @@ class BinaryConfusionMatrix(proto.Message): """ positive_class_threshold = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, ) true_positives = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=2, + message=wrappers_pb2.Int64Value, ) false_positives = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=3, + message=wrappers_pb2.Int64Value, ) true_negatives = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=4, + message=wrappers_pb2.Int64Value, ) false_negatives = proto.Field( - proto.MESSAGE, number=5, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=5, + message=wrappers_pb2.Int64Value, ) precision = proto.Field( - proto.MESSAGE, number=6, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, ) recall = proto.Field( - proto.MESSAGE, number=7, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=7, + message=wrappers_pb2.DoubleValue, ) f1_score = proto.Field( - proto.MESSAGE, number=8, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=8, + message=wrappers_pb2.DoubleValue, ) accuracy = proto.Field( - proto.MESSAGE, number=9, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=9, + message=wrappers_pb2.DoubleValue, ) aggregate_classification_metrics = proto.Field( - proto.MESSAGE, number=1, message="Model.AggregateClassificationMetrics", + proto.MESSAGE, + number=1, + message="Model.AggregateClassificationMetrics", ) binary_confusion_matrix_list = proto.RepeatedField( proto.MESSAGE, number=2, message="Model.BinaryClassificationMetrics.BinaryConfusionMatrix", ) - positive_label = proto.Field(proto.STRING, number=3,) - negative_label = proto.Field(proto.STRING, number=4,) + positive_label = proto.Field( + proto.STRING, + number=3, + ) + negative_label = proto.Field( + proto.STRING, + number=4, + ) class MultiClassClassificationMetrics(proto.Message): r"""Evaluation metrics for multi-class classification/classifier @@ -490,9 +540,14 @@ class Entry(proto.Message): label. """ - predicted_label = proto.Field(proto.STRING, number=1,) + predicted_label = proto.Field( + proto.STRING, + number=1, + ) item_count = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=2, + message=wrappers_pb2.Int64Value, ) class Row(proto.Message): @@ -505,7 +560,10 @@ class Row(proto.Message): Info describing predicted label distribution. """ - actual_label = proto.Field(proto.STRING, number=1,) + actual_label = proto.Field( + proto.STRING, + number=1, + ) entries = proto.RepeatedField( proto.MESSAGE, number=2, @@ -513,7 +571,9 @@ class Row(proto.Message): ) confidence_threshold = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, ) rows = proto.RepeatedField( proto.MESSAGE, @@ -522,7 +582,9 @@ class Row(proto.Message): ) aggregate_classification_metrics = proto.Field( - proto.MESSAGE, number=1, message="Model.AggregateClassificationMetrics", + proto.MESSAGE, + number=1, + message="Model.AggregateClassificationMetrics", ) confusion_matrix_list = proto.RepeatedField( proto.MESSAGE, @@ -604,9 +666,14 @@ class CategoryCount(proto.Message): category within the cluster. """ - category = proto.Field(proto.STRING, number=1,) + category = proto.Field( + proto.STRING, + number=1, + ) count = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=2, + message=wrappers_pb2.Int64Value, ) category_counts = proto.RepeatedField( @@ -615,7 +682,10 @@ class CategoryCount(proto.Message): message="Model.ClusteringMetrics.Cluster.FeatureValue.CategoricalValue.CategoryCount", ) - feature_column = proto.Field(proto.STRING, number=1,) + feature_column = proto.Field( + proto.STRING, + number=1, + ) numerical_value = proto.Field( proto.MESSAGE, number=2, @@ -629,24 +699,35 @@ class CategoryCount(proto.Message): message="Model.ClusteringMetrics.Cluster.FeatureValue.CategoricalValue", ) - centroid_id = proto.Field(proto.INT64, number=1,) + centroid_id = proto.Field( + proto.INT64, + number=1, + ) feature_values = proto.RepeatedField( proto.MESSAGE, number=2, message="Model.ClusteringMetrics.Cluster.FeatureValue", ) count = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=3, + message=wrappers_pb2.Int64Value, ) davies_bouldin_index = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, ) mean_squared_distance = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) clusters = proto.RepeatedField( - proto.MESSAGE, number=3, message="Model.ClusteringMetrics.Cluster", + proto.MESSAGE, + number=3, + message="Model.ClusteringMetrics.Cluster", ) class RankingMetrics(proto.Message): @@ -677,16 +758,24 @@ class RankingMetrics(proto.Message): """ mean_average_precision = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=1, + message=wrappers_pb2.DoubleValue, ) mean_squared_error = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) normalized_discounted_cumulative_gain = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=3, + message=wrappers_pb2.DoubleValue, ) average_rank = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=4, + message=wrappers_pb2.DoubleValue, ) class ArimaForecastingMetrics(proto.Message): @@ -751,38 +840,71 @@ class ArimaSingleModelForecastingMetrics(proto.Message): """ non_seasonal_order = proto.Field( - proto.MESSAGE, number=1, message="Model.ArimaOrder", + proto.MESSAGE, + number=1, + message="Model.ArimaOrder", ) arima_fitting_metrics = proto.Field( - proto.MESSAGE, number=2, message="Model.ArimaFittingMetrics", + proto.MESSAGE, + number=2, + message="Model.ArimaFittingMetrics", + ) + has_drift = proto.Field( + proto.BOOL, + number=3, + ) + time_series_id = proto.Field( + proto.STRING, + number=4, + ) + time_series_ids = proto.RepeatedField( + proto.STRING, + number=9, ) - has_drift = proto.Field(proto.BOOL, number=3,) - time_series_id = proto.Field(proto.STRING, number=4,) - time_series_ids = proto.RepeatedField(proto.STRING, number=9,) seasonal_periods = proto.RepeatedField( - proto.ENUM, number=5, enum="Model.SeasonalPeriod.SeasonalPeriodType", + proto.ENUM, + number=5, + enum="Model.SeasonalPeriod.SeasonalPeriodType", ) has_holiday_effect = proto.Field( - proto.MESSAGE, number=6, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=6, + message=wrappers_pb2.BoolValue, ) has_spikes_and_dips = proto.Field( - proto.MESSAGE, number=7, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=7, + message=wrappers_pb2.BoolValue, ) has_step_changes = proto.Field( - proto.MESSAGE, number=8, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=8, + message=wrappers_pb2.BoolValue, ) non_seasonal_order = proto.RepeatedField( - proto.MESSAGE, number=1, message="Model.ArimaOrder", + proto.MESSAGE, + number=1, + message="Model.ArimaOrder", ) arima_fitting_metrics = proto.RepeatedField( - proto.MESSAGE, number=2, message="Model.ArimaFittingMetrics", + proto.MESSAGE, + number=2, + message="Model.ArimaFittingMetrics", ) seasonal_periods = proto.RepeatedField( - proto.ENUM, number=3, enum="Model.SeasonalPeriod.SeasonalPeriodType", + proto.ENUM, + number=3, + enum="Model.SeasonalPeriod.SeasonalPeriodType", + ) + has_drift = proto.RepeatedField( + proto.BOOL, + number=4, + ) + time_series_id = proto.RepeatedField( + proto.STRING, + number=5, ) - has_drift = proto.RepeatedField(proto.BOOL, number=4,) - time_series_id = proto.RepeatedField(proto.STRING, number=5,) arima_single_model_forecasting_metrics = proto.RepeatedField( proto.MESSAGE, number=6, @@ -834,7 +956,10 @@ class EvaluationMetrics(proto.Message): """ regression_metrics = proto.Field( - proto.MESSAGE, number=1, oneof="metrics", message="Model.RegressionMetrics", + proto.MESSAGE, + number=1, + oneof="metrics", + message="Model.RegressionMetrics", ) binary_classification_metrics = proto.Field( proto.MESSAGE, @@ -849,10 +974,16 @@ class EvaluationMetrics(proto.Message): message="Model.MultiClassClassificationMetrics", ) clustering_metrics = proto.Field( - proto.MESSAGE, number=4, oneof="metrics", message="Model.ClusteringMetrics", + proto.MESSAGE, + number=4, + oneof="metrics", + message="Model.ClusteringMetrics", ) ranking_metrics = proto.Field( - proto.MESSAGE, number=5, oneof="metrics", message="Model.RankingMetrics", + proto.MESSAGE, + number=5, + oneof="metrics", + message="Model.RankingMetrics", ) arima_forecasting_metrics = proto.Field( proto.MESSAGE, @@ -875,10 +1006,14 @@ class DataSplitResult(proto.Message): """ training_table = proto.Field( - proto.MESSAGE, number=1, message=table_reference.TableReference, + proto.MESSAGE, + number=1, + message=table_reference.TableReference, ) evaluation_table = proto.Field( - proto.MESSAGE, number=2, message=table_reference.TableReference, + proto.MESSAGE, + number=2, + message=table_reference.TableReference, ) class ArimaOrder(proto.Message): @@ -894,9 +1029,18 @@ class ArimaOrder(proto.Message): Order of the moving-average part. """ - p = proto.Field(proto.INT64, number=1,) - d = proto.Field(proto.INT64, number=2,) - q = proto.Field(proto.INT64, number=3,) + p = proto.Field( + proto.INT64, + number=1, + ) + d = proto.Field( + proto.INT64, + number=2, + ) + q = proto.Field( + proto.INT64, + number=3, + ) class ArimaFittingMetrics(proto.Message): r"""ARIMA model fitting metrics. @@ -910,9 +1054,18 @@ class ArimaFittingMetrics(proto.Message): Variance. """ - log_likelihood = proto.Field(proto.DOUBLE, number=1,) - aic = proto.Field(proto.DOUBLE, number=2,) - variance = proto.Field(proto.DOUBLE, number=3,) + log_likelihood = proto.Field( + proto.DOUBLE, + number=1, + ) + aic = proto.Field( + proto.DOUBLE, + number=2, + ) + variance = proto.Field( + proto.DOUBLE, + number=3, + ) class GlobalExplanation(proto.Message): r"""Global explanations containing the top most important @@ -943,15 +1096,25 @@ class Explanation(proto.Message): Attribution of feature. """ - feature_name = proto.Field(proto.STRING, number=1,) + feature_name = proto.Field( + proto.STRING, + number=1, + ) attribution = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) explanations = proto.RepeatedField( - proto.MESSAGE, number=1, message="Model.GlobalExplanation.Explanation", + proto.MESSAGE, + number=1, + message="Model.GlobalExplanation.Explanation", + ) + class_label = proto.Field( + proto.STRING, + number=2, ) - class_label = proto.Field(proto.STRING, number=2,) class TrainingRun(proto.Message): r"""Information about a single training query run for the model. @@ -1137,94 +1300,215 @@ class TrainingOptions(proto.Message): adjustment in the input time series. """ - max_iterations = proto.Field(proto.INT64, number=1,) - loss_type = proto.Field(proto.ENUM, number=2, enum="Model.LossType",) - learn_rate = proto.Field(proto.DOUBLE, number=3,) + max_iterations = proto.Field( + proto.INT64, + number=1, + ) + loss_type = proto.Field( + proto.ENUM, + number=2, + enum="Model.LossType", + ) + learn_rate = proto.Field( + proto.DOUBLE, + number=3, + ) l1_regularization = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=4, + message=wrappers_pb2.DoubleValue, ) l2_regularization = proto.Field( - proto.MESSAGE, number=5, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=5, + message=wrappers_pb2.DoubleValue, ) min_relative_progress = proto.Field( - proto.MESSAGE, number=6, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, ) warm_start = proto.Field( - proto.MESSAGE, number=7, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=7, + message=wrappers_pb2.BoolValue, ) early_stop = proto.Field( - proto.MESSAGE, number=8, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=8, + message=wrappers_pb2.BoolValue, + ) + input_label_columns = proto.RepeatedField( + proto.STRING, + number=9, ) - input_label_columns = proto.RepeatedField(proto.STRING, number=9,) data_split_method = proto.Field( - proto.ENUM, number=10, enum="Model.DataSplitMethod", + proto.ENUM, + number=10, + enum="Model.DataSplitMethod", + ) + data_split_eval_fraction = proto.Field( + proto.DOUBLE, + number=11, + ) + data_split_column = proto.Field( + proto.STRING, + number=12, ) - data_split_eval_fraction = proto.Field(proto.DOUBLE, number=11,) - data_split_column = proto.Field(proto.STRING, number=12,) learn_rate_strategy = proto.Field( - proto.ENUM, number=13, enum="Model.LearnRateStrategy", + proto.ENUM, + number=13, + enum="Model.LearnRateStrategy", + ) + initial_learn_rate = proto.Field( + proto.DOUBLE, + number=16, + ) + label_class_weights = proto.MapField( + proto.STRING, + proto.DOUBLE, + number=17, + ) + user_column = proto.Field( + proto.STRING, + number=18, + ) + item_column = proto.Field( + proto.STRING, + number=19, ) - initial_learn_rate = proto.Field(proto.DOUBLE, number=16,) - label_class_weights = proto.MapField(proto.STRING, proto.DOUBLE, number=17,) - user_column = proto.Field(proto.STRING, number=18,) - item_column = proto.Field(proto.STRING, number=19,) distance_type = proto.Field( - proto.ENUM, number=20, enum="Model.DistanceType", + proto.ENUM, + number=20, + enum="Model.DistanceType", + ) + num_clusters = proto.Field( + proto.INT64, + number=21, + ) + model_uri = proto.Field( + proto.STRING, + number=22, ) - num_clusters = proto.Field(proto.INT64, number=21,) - model_uri = proto.Field(proto.STRING, number=22,) optimization_strategy = proto.Field( - proto.ENUM, number=23, enum="Model.OptimizationStrategy", + proto.ENUM, + number=23, + enum="Model.OptimizationStrategy", + ) + hidden_units = proto.RepeatedField( + proto.INT64, + number=24, + ) + batch_size = proto.Field( + proto.INT64, + number=25, ) - hidden_units = proto.RepeatedField(proto.INT64, number=24,) - batch_size = proto.Field(proto.INT64, number=25,) dropout = proto.Field( - proto.MESSAGE, number=26, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=26, + message=wrappers_pb2.DoubleValue, + ) + max_tree_depth = proto.Field( + proto.INT64, + number=27, + ) + subsample = proto.Field( + proto.DOUBLE, + number=28, ) - max_tree_depth = proto.Field(proto.INT64, number=27,) - subsample = proto.Field(proto.DOUBLE, number=28,) min_split_loss = proto.Field( - proto.MESSAGE, number=29, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=29, + message=wrappers_pb2.DoubleValue, + ) + num_factors = proto.Field( + proto.INT64, + number=30, ) - num_factors = proto.Field(proto.INT64, number=30,) feedback_type = proto.Field( - proto.ENUM, number=31, enum="Model.FeedbackType", + proto.ENUM, + number=31, + enum="Model.FeedbackType", ) wals_alpha = proto.Field( - proto.MESSAGE, number=32, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=32, + message=wrappers_pb2.DoubleValue, ) kmeans_initialization_method = proto.Field( proto.ENUM, number=33, enum="Model.KmeansEnums.KmeansInitializationMethod", ) - kmeans_initialization_column = proto.Field(proto.STRING, number=34,) - time_series_timestamp_column = proto.Field(proto.STRING, number=35,) - time_series_data_column = proto.Field(proto.STRING, number=36,) - auto_arima = proto.Field(proto.BOOL, number=37,) + kmeans_initialization_column = proto.Field( + proto.STRING, + number=34, + ) + time_series_timestamp_column = proto.Field( + proto.STRING, + number=35, + ) + time_series_data_column = proto.Field( + proto.STRING, + number=36, + ) + auto_arima = proto.Field( + proto.BOOL, + number=37, + ) non_seasonal_order = proto.Field( - proto.MESSAGE, number=38, message="Model.ArimaOrder", + proto.MESSAGE, + number=38, + message="Model.ArimaOrder", ) data_frequency = proto.Field( - proto.ENUM, number=39, enum="Model.DataFrequency", + proto.ENUM, + number=39, + enum="Model.DataFrequency", + ) + include_drift = proto.Field( + proto.BOOL, + number=41, ) - include_drift = proto.Field(proto.BOOL, number=41,) holiday_region = proto.Field( - proto.ENUM, number=42, enum="Model.HolidayRegion", + proto.ENUM, + number=42, + enum="Model.HolidayRegion", + ) + time_series_id_column = proto.Field( + proto.STRING, + number=43, + ) + time_series_id_columns = proto.RepeatedField( + proto.STRING, + number=51, + ) + horizon = proto.Field( + proto.INT64, + number=44, + ) + preserve_input_structs = proto.Field( + proto.BOOL, + number=45, + ) + auto_arima_max_order = proto.Field( + proto.INT64, + number=46, ) - time_series_id_column = proto.Field(proto.STRING, number=43,) - time_series_id_columns = proto.RepeatedField(proto.STRING, number=51,) - horizon = proto.Field(proto.INT64, number=44,) - preserve_input_structs = proto.Field(proto.BOOL, number=45,) - auto_arima_max_order = proto.Field(proto.INT64, number=46,) decompose_time_series = proto.Field( - proto.MESSAGE, number=50, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=50, + message=wrappers_pb2.BoolValue, ) clean_spikes_and_dips = proto.Field( - proto.MESSAGE, number=52, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=52, + message=wrappers_pb2.BoolValue, ) adjust_step_changes = proto.Field( - proto.MESSAGE, number=53, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=53, + message=wrappers_pb2.BoolValue, ) class IterationResult(proto.Message): @@ -1265,12 +1549,19 @@ class ClusterInfo(proto.Message): assigned to the cluster. """ - centroid_id = proto.Field(proto.INT64, number=1,) + centroid_id = proto.Field( + proto.INT64, + number=1, + ) cluster_radius = proto.Field( - proto.MESSAGE, number=2, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=2, + message=wrappers_pb2.DoubleValue, ) cluster_size = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=3, + message=wrappers_pb2.Int64Value, ) class ArimaResult(proto.Message): @@ -1304,12 +1595,17 @@ class ArimaCoefficients(proto.Message): """ auto_regressive_coefficients = proto.RepeatedField( - proto.DOUBLE, number=1, + proto.DOUBLE, + number=1, ) moving_average_coefficients = proto.RepeatedField( - proto.DOUBLE, number=2, + proto.DOUBLE, + number=2, + ) + intercept_coefficient = proto.Field( + proto.DOUBLE, + number=3, ) - intercept_coefficient = proto.Field(proto.DOUBLE, number=3,) class ArimaModelInfo(proto.Message): r"""Arima model information. @@ -1351,7 +1647,9 @@ class ArimaModelInfo(proto.Message): """ non_seasonal_order = proto.Field( - proto.MESSAGE, number=1, message="Model.ArimaOrder", + proto.MESSAGE, + number=1, + message="Model.ArimaOrder", ) arima_coefficients = proto.Field( proto.MESSAGE, @@ -1359,24 +1657,41 @@ class ArimaModelInfo(proto.Message): message="Model.TrainingRun.IterationResult.ArimaResult.ArimaCoefficients", ) arima_fitting_metrics = proto.Field( - proto.MESSAGE, number=3, message="Model.ArimaFittingMetrics", + proto.MESSAGE, + number=3, + message="Model.ArimaFittingMetrics", + ) + has_drift = proto.Field( + proto.BOOL, + number=4, + ) + time_series_id = proto.Field( + proto.STRING, + number=5, + ) + time_series_ids = proto.RepeatedField( + proto.STRING, + number=10, ) - has_drift = proto.Field(proto.BOOL, number=4,) - time_series_id = proto.Field(proto.STRING, number=5,) - time_series_ids = proto.RepeatedField(proto.STRING, number=10,) seasonal_periods = proto.RepeatedField( proto.ENUM, number=6, enum="Model.SeasonalPeriod.SeasonalPeriodType", ) has_holiday_effect = proto.Field( - proto.MESSAGE, number=7, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=7, + message=wrappers_pb2.BoolValue, ) has_spikes_and_dips = proto.Field( - proto.MESSAGE, number=8, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=8, + message=wrappers_pb2.BoolValue, ) has_step_changes = proto.Field( - proto.MESSAGE, number=9, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=9, + message=wrappers_pb2.BoolValue, ) arima_model_info = proto.RepeatedField( @@ -1391,18 +1706,29 @@ class ArimaModelInfo(proto.Message): ) index = proto.Field( - proto.MESSAGE, number=1, message=wrappers_pb2.Int32Value, + proto.MESSAGE, + number=1, + message=wrappers_pb2.Int32Value, ) duration_ms = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.Int64Value, + proto.MESSAGE, + number=4, + message=wrappers_pb2.Int64Value, ) training_loss = proto.Field( - proto.MESSAGE, number=5, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=5, + message=wrappers_pb2.DoubleValue, ) eval_loss = proto.Field( - proto.MESSAGE, number=6, message=wrappers_pb2.DoubleValue, + proto.MESSAGE, + number=6, + message=wrappers_pb2.DoubleValue, + ) + learn_rate = proto.Field( + proto.DOUBLE, + number=7, ) - learn_rate = proto.Field(proto.DOUBLE, number=7,) cluster_infos = proto.RepeatedField( proto.MESSAGE, number=8, @@ -1415,47 +1741,103 @@ class ArimaModelInfo(proto.Message): ) training_options = proto.Field( - proto.MESSAGE, number=1, message="Model.TrainingRun.TrainingOptions", + proto.MESSAGE, + number=1, + message="Model.TrainingRun.TrainingOptions", ) start_time = proto.Field( - proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, ) results = proto.RepeatedField( - proto.MESSAGE, number=6, message="Model.TrainingRun.IterationResult", + proto.MESSAGE, + number=6, + message="Model.TrainingRun.IterationResult", ) evaluation_metrics = proto.Field( - proto.MESSAGE, number=7, message="Model.EvaluationMetrics", + proto.MESSAGE, + number=7, + message="Model.EvaluationMetrics", ) data_split_result = proto.Field( - proto.MESSAGE, number=9, message="Model.DataSplitResult", + proto.MESSAGE, + number=9, + message="Model.DataSplitResult", ) global_explanations = proto.RepeatedField( - proto.MESSAGE, number=10, message="Model.GlobalExplanation", + proto.MESSAGE, + number=10, + message="Model.GlobalExplanation", ) - etag = proto.Field(proto.STRING, number=1,) + etag = proto.Field( + proto.STRING, + number=1, + ) model_reference = proto.Field( - proto.MESSAGE, number=2, message=gcb_model_reference.ModelReference, + proto.MESSAGE, + number=2, + message=gcb_model_reference.ModelReference, + ) + creation_time = proto.Field( + proto.INT64, + number=5, + ) + last_modified_time = proto.Field( + proto.INT64, + number=6, + ) + description = proto.Field( + proto.STRING, + number=12, + ) + friendly_name = proto.Field( + proto.STRING, + number=14, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=15, + ) + expiration_time = proto.Field( + proto.INT64, + number=16, + ) + location = proto.Field( + proto.STRING, + number=13, ) - creation_time = proto.Field(proto.INT64, number=5,) - last_modified_time = proto.Field(proto.INT64, number=6,) - description = proto.Field(proto.STRING, number=12,) - friendly_name = proto.Field(proto.STRING, number=14,) - labels = proto.MapField(proto.STRING, proto.STRING, number=15,) - expiration_time = proto.Field(proto.INT64, number=16,) - location = proto.Field(proto.STRING, number=13,) encryption_configuration = proto.Field( - proto.MESSAGE, number=17, message=encryption_config.EncryptionConfiguration, + proto.MESSAGE, + number=17, + message=encryption_config.EncryptionConfiguration, + ) + model_type = proto.Field( + proto.ENUM, + number=7, + enum=ModelType, + ) + training_runs = proto.RepeatedField( + proto.MESSAGE, + number=9, + message=TrainingRun, ) - model_type = proto.Field(proto.ENUM, number=7, enum=ModelType,) - training_runs = proto.RepeatedField(proto.MESSAGE, number=9, message=TrainingRun,) feature_columns = proto.RepeatedField( - proto.MESSAGE, number=10, message=standard_sql.StandardSqlField, + proto.MESSAGE, + number=10, + message=standard_sql.StandardSqlField, ) label_columns = proto.RepeatedField( - proto.MESSAGE, number=11, message=standard_sql.StandardSqlField, + proto.MESSAGE, + number=11, + message=standard_sql.StandardSqlField, + ) + best_trial_id = proto.Field( + proto.INT64, + number=19, ) - best_trial_id = proto.Field(proto.INT64, number=19,) class GetModelRequest(proto.Message): @@ -1470,9 +1852,18 @@ class GetModelRequest(proto.Message): Required. Model ID of the requested model. """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) - model_id = proto.Field(proto.STRING, number=3,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) + model_id = proto.Field( + proto.STRING, + number=3, + ) class PatchModelRequest(proto.Message): @@ -1492,10 +1883,23 @@ class PatchModelRequest(proto.Message): set to default value. """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) - model_id = proto.Field(proto.STRING, number=3,) - model = proto.Field(proto.MESSAGE, number=4, message="Model",) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) + model_id = proto.Field( + proto.STRING, + number=3, + ) + model = proto.Field( + proto.MESSAGE, + number=4, + message="Model", + ) class DeleteModelRequest(proto.Message): @@ -1510,9 +1914,18 @@ class DeleteModelRequest(proto.Message): Required. Model ID of the model to delete. """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) - model_id = proto.Field(proto.STRING, number=3,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) + model_id = proto.Field( + proto.STRING, + number=3, + ) class ListModelsRequest(proto.Message): @@ -1532,12 +1945,23 @@ class ListModelsRequest(proto.Message): request the next page of results """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) max_results = proto.Field( - proto.MESSAGE, number=3, message=wrappers_pb2.UInt32Value, + proto.MESSAGE, + number=3, + message=wrappers_pb2.UInt32Value, + ) + page_token = proto.Field( + proto.STRING, + number=4, ) - page_token = proto.Field(proto.STRING, number=4,) class ListModelsResponse(proto.Message): @@ -1556,8 +1980,15 @@ class ListModelsResponse(proto.Message): def raw_page(self): return self - models = proto.RepeatedField(proto.MESSAGE, number=1, message="Model",) - next_page_token = proto.Field(proto.STRING, number=2,) + models = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Model", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/bigquery_v2/types/model_reference.py b/google/cloud/bigquery_v2/types/model_reference.py index a4aab59f7..cde139ebe 100644 --- a/google/cloud/bigquery_v2/types/model_reference.py +++ b/google/cloud/bigquery_v2/types/model_reference.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.bigquery.v2", manifest={"ModelReference",}, + package="google.cloud.bigquery.v2", + manifest={ + "ModelReference", + }, ) @@ -37,9 +40,18 @@ class ModelReference(proto.Message): maximum length is 1,024 characters. """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) - model_id = proto.Field(proto.STRING, number=3,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) + model_id = proto.Field( + proto.STRING, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/bigquery_v2/types/standard_sql.py b/google/cloud/bigquery_v2/types/standard_sql.py index 579c3b138..3be5304fc 100644 --- a/google/cloud/bigquery_v2/types/standard_sql.py +++ b/google/cloud/bigquery_v2/types/standard_sql.py @@ -78,12 +78,22 @@ class TypeKind(proto.Enum): ARRAY = 16 STRUCT = 17 - type_kind = proto.Field(proto.ENUM, number=1, enum=TypeKind,) + type_kind = proto.Field( + proto.ENUM, + number=1, + enum=TypeKind, + ) array_element_type = proto.Field( - proto.MESSAGE, number=2, oneof="sub_type", message="StandardSqlDataType", + proto.MESSAGE, + number=2, + oneof="sub_type", + message="StandardSqlDataType", ) struct_type = proto.Field( - proto.MESSAGE, number=3, oneof="sub_type", message="StandardSqlStructType", + proto.MESSAGE, + number=3, + oneof="sub_type", + message="StandardSqlStructType", ) @@ -102,8 +112,15 @@ class StandardSqlField(proto.Message): this "type" field). """ - name = proto.Field(proto.STRING, number=1,) - type = proto.Field(proto.MESSAGE, number=2, message="StandardSqlDataType",) + name = proto.Field( + proto.STRING, + number=1, + ) + type = proto.Field( + proto.MESSAGE, + number=2, + message="StandardSqlDataType", + ) class StandardSqlStructType(proto.Message): @@ -114,7 +131,11 @@ class StandardSqlStructType(proto.Message): """ - fields = proto.RepeatedField(proto.MESSAGE, number=1, message="StandardSqlField",) + fields = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="StandardSqlField", + ) class StandardSqlTableType(proto.Message): @@ -125,7 +146,11 @@ class StandardSqlTableType(proto.Message): The columns in this table type """ - columns = proto.RepeatedField(proto.MESSAGE, number=1, message="StandardSqlField",) + columns = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="StandardSqlField", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/bigquery_v2/types/table_reference.py b/google/cloud/bigquery_v2/types/table_reference.py index aaab83e85..c02eb206f 100644 --- a/google/cloud/bigquery_v2/types/table_reference.py +++ b/google/cloud/bigquery_v2/types/table_reference.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.bigquery.v2", manifest={"TableReference",}, + package="google.cloud.bigquery.v2", + manifest={ + "TableReference", + }, ) @@ -48,12 +51,30 @@ class TableReference(proto.Message): to translate the received data to the project_id field. """ - project_id = proto.Field(proto.STRING, number=1,) - dataset_id = proto.Field(proto.STRING, number=2,) - table_id = proto.Field(proto.STRING, number=3,) - project_id_alternative = proto.RepeatedField(proto.STRING, number=4,) - dataset_id_alternative = proto.RepeatedField(proto.STRING, number=5,) - table_id_alternative = proto.RepeatedField(proto.STRING, number=6,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + dataset_id = proto.Field( + proto.STRING, + number=2, + ) + table_id = proto.Field( + proto.STRING, + number=3, + ) + project_id_alternative = proto.RepeatedField( + proto.STRING, + number=4, + ) + dataset_id_alternative = proto.RepeatedField( + proto.STRING, + number=5, + ) + table_id_alternative = proto.RepeatedField( + proto.STRING, + number=6, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 6304747d1..8d1cb056c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ MYPY_VERSION = "mypy==0.910" PYTYPE_VERSION = "pytype==2021.4.9" -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ("docs", "google", "samples", "tests", "noxfile.py", "setup.py") DEFAULT_PYTHON_VERSION = "3.8" @@ -122,7 +122,10 @@ def mypy(session): # Just install the dependencies' type info directly, since "mypy --install-types" # might require an additional pass. session.install( - "types-protobuf", "types-python-dateutil", "types-requests", "types-setuptools", + "types-protobuf", + "types-python-dateutil", + "types-requests", + "types-setuptools", ) session.run("mypy", "google/cloud") diff --git a/samples/geography/noxfile.py b/samples/geography/noxfile.py index 85f5836db..25f87a215 100644 --- a/samples/geography/noxfile.py +++ b/samples/geography/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/geography/requirements.txt b/samples/geography/requirements.txt index 4c566cfb3..41f3849ce 100644 --- a/samples/geography/requirements.txt +++ b/samples/geography/requirements.txt @@ -5,16 +5,14 @@ charset-normalizer==2.0.12 click==8.0.4 click-plugins==1.1.1 cligj==0.7.2 -dataclasses==0.8; python_version < '3.7' Fiona==1.8.21 geojson==2.5.0 -geopandas==0.9.0; python_version < '3.7' -geopandas==0.10.2; python_version >= '3.7' -google-api-core==2.6.0 +geopandas==0.10.2 +google-api-core==2.6.1 google-auth==2.6.0 -google-cloud-bigquery==2.34.1 +google-cloud-bigquery==2.34.2 google-cloud-bigquery-storage==2.12.0 -google-cloud-core==2.2.2 +google-cloud-core==2.2.3 google-crc32c==1.3.0 google-resumable-media==2.3.1 googleapis-common-protos==1.55.0 @@ -24,7 +22,6 @@ libcst==0.4.1 munch==2.5.0 mypy-extensions==0.4.3 packaging==21.3 -pandas==1.1.5; python_version < '3.7' pandas==1.3.5; python_version == '3.7' pandas==1.4.1; python_version >= '3.8' proto-plus==1.20.3 diff --git a/samples/load_table_dataframe.py b/samples/load_table_dataframe.py index 91dd6e9f0..b75224d11 100644 --- a/samples/load_table_dataframe.py +++ b/samples/load_table_dataframe.py @@ -30,7 +30,7 @@ def load_table_dataframe(table_id): records = [ { - "title": u"The Meaning of Life", + "title": "The Meaning of Life", "release_year": 1983, "length_minutes": 112.5, "release_date": pytz.timezone("Europe/Paris") @@ -40,7 +40,7 @@ def load_table_dataframe(table_id): "dvd_release": datetime.datetime(2002, 1, 22, 7, 0, 0), }, { - "title": u"Monty Python and the Holy Grail", + "title": "Monty Python and the Holy Grail", "release_year": 1975, "length_minutes": 91.5, "release_date": pytz.timezone("Europe/London") @@ -49,7 +49,7 @@ def load_table_dataframe(table_id): "dvd_release": datetime.datetime(2002, 7, 16, 9, 0, 0), }, { - "title": u"Life of Brian", + "title": "Life of Brian", "release_year": 1979, "length_minutes": 94.25, "release_date": pytz.timezone("America/New_York") @@ -58,7 +58,7 @@ def load_table_dataframe(table_id): "dvd_release": datetime.datetime(2008, 1, 14, 8, 0, 0), }, { - "title": u"And Now for Something Completely Different", + "title": "And Now for Something Completely Different", "release_year": 1971, "length_minutes": 88.0, "release_date": pytz.timezone("Europe/London") @@ -81,7 +81,7 @@ def load_table_dataframe(table_id): # Optionally, set a named index, which can also be written to the # BigQuery table. index=pandas.Index( - [u"Q24980", u"Q25043", u"Q24953", u"Q16403"], name="wikidata_id" + ["Q24980", "Q25043", "Q24953", "Q16403"], name="wikidata_id" ), ) job_config = bigquery.LoadJobConfig( diff --git a/samples/load_table_file.py b/samples/load_table_file.py index b7e45dac3..41f0bf984 100644 --- a/samples/load_table_file.py +++ b/samples/load_table_file.py @@ -25,7 +25,9 @@ def load_table_file(file_path, table_id): # table_id = "your-project.your_dataset.your_table_name" job_config = bigquery.LoadJobConfig( - source_format=bigquery.SourceFormat.CSV, skip_leading_rows=1, autodetect=True, + source_format=bigquery.SourceFormat.CSV, + skip_leading_rows=1, + autodetect=True, ) with open(file_path, "rb") as source_file: diff --git a/samples/load_table_uri_parquet.py b/samples/load_table_uri_parquet.py index 3dce5e8ef..9df2ab1e7 100644 --- a/samples/load_table_uri_parquet.py +++ b/samples/load_table_uri_parquet.py @@ -23,7 +23,9 @@ def load_table_uri_parquet(table_id): # TODO(developer): Set table_id to the ID of the table to create. # table_id = "your-project.your_dataset.your_table_name" - job_config = bigquery.LoadJobConfig(source_format=bigquery.SourceFormat.PARQUET,) + job_config = bigquery.LoadJobConfig( + source_format=bigquery.SourceFormat.PARQUET, + ) uri = "gs://cloud-samples-data/bigquery/us-states/us-states.parquet" load_job = client.load_table_from_uri( diff --git a/samples/magics/noxfile.py b/samples/magics/noxfile.py index 85f5836db..25f87a215 100644 --- a/samples/magics/noxfile.py +++ b/samples/magics/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/magics/requirements.txt b/samples/magics/requirements.txt index ba873ed3a..f047c46b6 100644 --- a/samples/magics/requirements.txt +++ b/samples/magics/requirements.txt @@ -1,13 +1,10 @@ google-cloud-bigquery-storage==2.12.0 google-auth-oauthlib==0.5.0 grpcio==1.44.0 -ipython==7.16.3; python_version < '3.7' ipython==7.31.1; python_version == '3.7' ipython==8.0.1; python_version == '3.8' ipython==8.1.1; python_version >= '3.9' -matplotlib==3.5.1; python_version < '3.7' -matplotlib==3.5.1; python_version >= '3.7' -pandas==1.1.5; python_version < '3.7' +matplotlib==3.5.1 pandas==1.3.5; python_version == '3.7' pandas==1.4.1; python_version >= '3.8' pyarrow==7.0.0 diff --git a/samples/snippets/authenticate_service_account.py b/samples/snippets/authenticate_service_account.py index c07848bee..fa3c53cda 100644 --- a/samples/snippets/authenticate_service_account.py +++ b/samples/snippets/authenticate_service_account.py @@ -27,7 +27,8 @@ def main(): # key_path = "path/to/service_account.json" credentials = service_account.Credentials.from_service_account_file( - key_path, scopes=["https://www.googleapis.com/auth/cloud-platform"], + key_path, + scopes=["https://www.googleapis.com/auth/cloud-platform"], ) # Alternatively, use service_account.Credentials.from_service_account_info() @@ -35,7 +36,10 @@ def main(): # TODO(developer): Set key_json to the content of the service account key file. # credentials = service_account.Credentials.from_service_account_info(key_json) - client = bigquery.Client(credentials=credentials, project=credentials.project_id,) + client = bigquery.Client( + credentials=credentials, + project=credentials.project_id, + ) # [END bigquery_client_json_credentials] return client diff --git a/samples/snippets/create_table_external_hive_partitioned_test.py b/samples/snippets/create_table_external_hive_partitioned_test.py index c3cdddb55..fccc2d408 100644 --- a/samples/snippets/create_table_external_hive_partitioned_test.py +++ b/samples/snippets/create_table_external_hive_partitioned_test.py @@ -16,8 +16,10 @@ def test_create_table_external_hive_partitioned(capsys, random_table_id): - table = create_table_external_hive_partitioned.create_table_external_hive_partitioned( - random_table_id + table = ( + create_table_external_hive_partitioned.create_table_external_hive_partitioned( + random_table_id + ) ) out, _ = capsys.readouterr() diff --git a/samples/snippets/delete_job_test.py b/samples/snippets/delete_job_test.py index c9baa817d..fb407ab4b 100644 --- a/samples/snippets/delete_job_test.py +++ b/samples/snippets/delete_job_test.py @@ -21,7 +21,8 @@ def test_delete_job_metadata( capsys, bigquery_client: bigquery.Client, table_id_us_east1: str ): query_job: bigquery.QueryJob = bigquery_client.query( - f"SELECT COUNT(*) FROM `{table_id_us_east1}`", location="us-east1", + f"SELECT COUNT(*) FROM `{table_id_us_east1}`", + location="us-east1", ) query_job.result() assert query_job.job_id is not None diff --git a/samples/snippets/manage_job_cancel.py b/samples/snippets/manage_job_cancel.py index 3e0fc5218..c08a32add 100644 --- a/samples/snippets/manage_job_cancel.py +++ b/samples/snippets/manage_job_cancel.py @@ -17,7 +17,9 @@ def cancel_job( - client: bigquery.Client, location: str = "us", job_id: str = "abcd-efgh-ijkl-mnop", + client: bigquery.Client, + location: str = "us", + job_id: str = "abcd-efgh-ijkl-mnop", ): job = client.cancel_job(job_id, location=location) print(f"{job.location}:{job.job_id} cancelled") diff --git a/samples/snippets/manage_job_get.py b/samples/snippets/manage_job_get.py index 256d79e5b..cb54fd7bb 100644 --- a/samples/snippets/manage_job_get.py +++ b/samples/snippets/manage_job_get.py @@ -17,7 +17,9 @@ def get_job( - client: bigquery.Client, location: str = "us", job_id: str = "abcd-efgh-ijkl-mnop", + client: bigquery.Client, + location: str = "us", + job_id: str = "abcd-efgh-ijkl-mnop", ): job = client.get_job(job_id, location=location) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 85f5836db..25f87a215 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index ba873ed3a..f047c46b6 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,13 +1,10 @@ google-cloud-bigquery-storage==2.12.0 google-auth-oauthlib==0.5.0 grpcio==1.44.0 -ipython==7.16.3; python_version < '3.7' ipython==7.31.1; python_version == '3.7' ipython==8.0.1; python_version == '3.8' ipython==8.1.1; python_version >= '3.9' -matplotlib==3.5.1; python_version < '3.7' -matplotlib==3.5.1; python_version >= '3.7' -pandas==1.1.5; python_version < '3.7' +matplotlib==3.5.1 pandas==1.3.5; python_version == '3.7' pandas==1.4.1; python_version >= '3.8' pyarrow==7.0.0 diff --git a/samples/snippets/update_dataset_access.py b/samples/snippets/update_dataset_access.py index 1448213a6..a606a2d56 100644 --- a/samples/snippets/update_dataset_access.py +++ b/samples/snippets/update_dataset_access.py @@ -59,7 +59,11 @@ def update_dataset_access(dataset_id: str, entity_id: str): entries = list(dataset.access_entries) entries.append( - bigquery.AccessEntry(role=role, entity_type=entity_type, entity_id=entity_id,) + bigquery.AccessEntry( + role=role, + entity_type=entity_type, + entity_id=entity_id, + ) ) dataset.access_entries = entries diff --git a/samples/table_insert_rows.py b/samples/table_insert_rows.py index 24d739871..80048b411 100644 --- a/samples/table_insert_rows.py +++ b/samples/table_insert_rows.py @@ -25,8 +25,8 @@ def table_insert_rows(table_id): # table_id = "your-project.your_dataset.your_table" rows_to_insert = [ - {u"full_name": u"Phred Phlyntstone", u"age": 32}, - {u"full_name": u"Wylma Phlyntstone", u"age": 29}, + {"full_name": "Phred Phlyntstone", "age": 32}, + {"full_name": "Wylma Phlyntstone", "age": 29}, ] errors = client.insert_rows_json(table_id, rows_to_insert) # Make an API request. diff --git a/samples/table_insert_rows_explicit_none_insert_ids.py b/samples/table_insert_rows_explicit_none_insert_ids.py index d91792b82..202064bda 100644 --- a/samples/table_insert_rows_explicit_none_insert_ids.py +++ b/samples/table_insert_rows_explicit_none_insert_ids.py @@ -25,8 +25,8 @@ def table_insert_rows_explicit_none_insert_ids(table_id): # table_id = "your-project.your_dataset.your_table" rows_to_insert = [ - {u"full_name": u"Phred Phlyntstone", u"age": 32}, - {u"full_name": u"Wylma Phlyntstone", u"age": 29}, + {"full_name": "Phred Phlyntstone", "age": 32}, + {"full_name": "Wylma Phlyntstone", "age": 29}, ] errors = client.insert_rows_json( diff --git a/samples/tests/test_client_query.py b/samples/tests/test_client_query.py index 810c46a17..673ed2b66 100644 --- a/samples/tests/test_client_query.py +++ b/samples/tests/test_client_query.py @@ -15,7 +15,9 @@ from .. import client_query -def test_client_query(capsys,): +def test_client_query( + capsys, +): client_query.client_query() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_batch.py b/samples/tests/test_client_query_batch.py index c5e19985d..3335950ad 100644 --- a/samples/tests/test_client_query_batch.py +++ b/samples/tests/test_client_query_batch.py @@ -15,7 +15,9 @@ from .. import client_query_batch -def test_client_query_batch(capsys,): +def test_client_query_batch( + capsys, +): job = client_query_batch.client_query_batch() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_dry_run.py b/samples/tests/test_client_query_dry_run.py index 5cbf2e3fa..2141435f2 100644 --- a/samples/tests/test_client_query_dry_run.py +++ b/samples/tests/test_client_query_dry_run.py @@ -15,7 +15,9 @@ from .. import client_query_dry_run -def test_client_query_dry_run(capsys,): +def test_client_query_dry_run( + capsys, +): query_job = client_query_dry_run.client_query_dry_run() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_legacy_sql.py b/samples/tests/test_client_query_legacy_sql.py index ab240fad1..9d3f8ab99 100644 --- a/samples/tests/test_client_query_legacy_sql.py +++ b/samples/tests/test_client_query_legacy_sql.py @@ -17,7 +17,9 @@ from .. import client_query_legacy_sql -def test_client_query_legacy_sql(capsys,): +def test_client_query_legacy_sql( + capsys, +): client_query_legacy_sql.client_query_legacy_sql() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_w_array_params.py b/samples/tests/test_client_query_w_array_params.py index 07e0294e9..6608ff0a4 100644 --- a/samples/tests/test_client_query_w_array_params.py +++ b/samples/tests/test_client_query_w_array_params.py @@ -15,7 +15,9 @@ from .. import client_query_w_array_params -def test_client_query_w_array_params(capsys,): +def test_client_query_w_array_params( + capsys, +): client_query_w_array_params.client_query_w_array_params() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_w_named_params.py b/samples/tests/test_client_query_w_named_params.py index 2970dfdc4..f53f72fdf 100644 --- a/samples/tests/test_client_query_w_named_params.py +++ b/samples/tests/test_client_query_w_named_params.py @@ -15,7 +15,9 @@ from .. import client_query_w_named_params -def test_client_query_w_named_params(capsys,): +def test_client_query_w_named_params( + capsys, +): client_query_w_named_params.client_query_w_named_params() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_w_positional_params.py b/samples/tests/test_client_query_w_positional_params.py index e41ffa825..c91b10f21 100644 --- a/samples/tests/test_client_query_w_positional_params.py +++ b/samples/tests/test_client_query_w_positional_params.py @@ -15,7 +15,9 @@ from .. import client_query_w_positional_params -def test_client_query_w_positional_params(capsys,): +def test_client_query_w_positional_params( + capsys, +): client_query_w_positional_params.client_query_w_positional_params() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_w_struct_params.py b/samples/tests/test_client_query_w_struct_params.py index 03083a3a7..dfb86fb65 100644 --- a/samples/tests/test_client_query_w_struct_params.py +++ b/samples/tests/test_client_query_w_struct_params.py @@ -15,7 +15,9 @@ from .. import client_query_w_struct_params -def test_client_query_w_struct_params(capsys,): +def test_client_query_w_struct_params( + capsys, +): client_query_w_struct_params.client_query_w_struct_params() out, err = capsys.readouterr() diff --git a/samples/tests/test_client_query_w_timestamp_params.py b/samples/tests/test_client_query_w_timestamp_params.py index 9dddcb9a0..51dfa1296 100644 --- a/samples/tests/test_client_query_w_timestamp_params.py +++ b/samples/tests/test_client_query_w_timestamp_params.py @@ -15,7 +15,9 @@ from .. import client_query_w_timestamp_params -def test_client_query_w_timestamp_params(capsys,): +def test_client_query_w_timestamp_params( + capsys, +): client_query_w_timestamp_params.client_query_w_timestamp_params() out, err = capsys.readouterr() diff --git a/samples/tests/test_load_table_dataframe.py b/samples/tests/test_load_table_dataframe.py index 228666046..6528edc98 100644 --- a/samples/tests/test_load_table_dataframe.py +++ b/samples/tests/test_load_table_dataframe.py @@ -50,10 +50,10 @@ def test_load_table_dataframe(capsys, client, random_table_id): df = client.list_rows(table).to_dataframe() df.sort_values("release_year", inplace=True) assert df["title"].tolist() == [ - u"And Now for Something Completely Different", - u"Monty Python and the Holy Grail", - u"Life of Brian", - u"The Meaning of Life", + "And Now for Something Completely Different", + "Monty Python and the Holy Grail", + "Life of Brian", + "The Meaning of Life", ] assert df["release_year"].tolist() == [1971, 1975, 1979, 1983] assert df["length_minutes"].tolist() == [88.0, 91.5, 94.25, 112.5] @@ -69,4 +69,4 @@ def test_load_table_dataframe(capsys, client, random_table_id): pandas.Timestamp("2008-01-14T08:00:00+00:00"), pandas.Timestamp("2002-01-22T07:00:00+00:00"), ] - assert df["wikidata_id"].tolist() == [u"Q16403", u"Q25043", u"Q24953", u"Q24980"] + assert df["wikidata_id"].tolist() == ["Q16403", "Q25043", "Q24953", "Q24980"] diff --git a/samples/tests/test_query_external_gcs_temporary_table.py b/samples/tests/test_query_external_gcs_temporary_table.py index 022b327be..e6a825233 100644 --- a/samples/tests/test_query_external_gcs_temporary_table.py +++ b/samples/tests/test_query_external_gcs_temporary_table.py @@ -15,7 +15,9 @@ from .. import query_external_gcs_temporary_table -def test_query_external_gcs_temporary_table(capsys,): +def test_query_external_gcs_temporary_table( + capsys, +): query_external_gcs_temporary_table.query_external_gcs_temporary_table() out, err = capsys.readouterr() diff --git a/samples/tests/test_query_no_cache.py b/samples/tests/test_query_no_cache.py index df17d0d0b..f72bee3f7 100644 --- a/samples/tests/test_query_no_cache.py +++ b/samples/tests/test_query_no_cache.py @@ -17,7 +17,9 @@ from .. import query_no_cache -def test_query_no_cache(capsys,): +def test_query_no_cache( + capsys, +): query_no_cache.query_no_cache() out, err = capsys.readouterr() diff --git a/samples/tests/test_query_pagination.py b/samples/tests/test_query_pagination.py index 7ab049c8c..eb1ca4b2c 100644 --- a/samples/tests/test_query_pagination.py +++ b/samples/tests/test_query_pagination.py @@ -15,7 +15,9 @@ from .. import query_pagination -def test_query_pagination(capsys,): +def test_query_pagination( + capsys, +): query_pagination.query_pagination() out, _ = capsys.readouterr() diff --git a/samples/tests/test_query_script.py b/samples/tests/test_query_script.py index 037664d36..2c7547873 100644 --- a/samples/tests/test_query_script.py +++ b/samples/tests/test_query_script.py @@ -15,7 +15,9 @@ from .. import query_script -def test_query_script(capsys,): +def test_query_script( + capsys, +): query_script.query_script() out, _ = capsys.readouterr() diff --git a/samples/tests/test_query_to_arrow.py b/samples/tests/test_query_to_arrow.py index f14ce5561..9511def58 100644 --- a/samples/tests/test_query_to_arrow.py +++ b/samples/tests/test_query_to_arrow.py @@ -19,7 +19,9 @@ pyarrow = pytest.importorskip("pyarrow") -def test_query_to_arrow(capsys,): +def test_query_to_arrow( + capsys, +): arrow_table = query_to_arrow.query_to_arrow() out, err = capsys.readouterr() diff --git a/tests/system/helpers.py b/tests/system/helpers.py index 76e609345..721f55040 100644 --- a/tests/system/helpers.py +++ b/tests/system/helpers.py @@ -39,9 +39,15 @@ ('SELECT "ABC"', "ABC"), ('SELECT CAST("foo" AS BYTES)', b"foo"), ('SELECT TIMESTAMP "%s"' % (_stamp,), _zoned), - ('SELECT TIMESTAMP "%s"' % (_stamp_microseconds,), _zoned_microseconds,), + ( + 'SELECT TIMESTAMP "%s"' % (_stamp_microseconds,), + _zoned_microseconds, + ), ('SELECT DATETIME(TIMESTAMP "%s")' % (_stamp,), _naive), - ('SELECT DATETIME(TIMESTAMP "%s")' % (_stamp_microseconds,), _naive_microseconds,), + ( + 'SELECT DATETIME(TIMESTAMP "%s")' % (_stamp_microseconds,), + _naive_microseconds, + ), ('SELECT DATE(TIMESTAMP "%s")' % (_stamp,), _naive.date()), ('SELECT TIME(TIMESTAMP "%s")' % (_stamp,), _naive.time()), ('SELECT NUMERIC "%s"' % (_numeric,), _numeric), @@ -90,5 +96,6 @@ def _rate_limit_exceeded(forbidden): # they return instead of the more appropriate 429. # See https://cloud.google.com/bigquery/quota-policy retry_403 = test_utils.retry.RetryErrors( - google.api_core.exceptions.Forbidden, error_predicate=_rate_limit_exceeded, + google.api_core.exceptions.Forbidden, + error_predicate=_rate_limit_exceeded, ) diff --git a/tests/system/test_arrow.py b/tests/system/test_arrow.py index 96f9dea25..cc090ba26 100644 --- a/tests/system/test_arrow.py +++ b/tests/system/test_arrow.py @@ -65,7 +65,9 @@ def test_list_rows_nullable_scalars_dtypes( ] arrow_table = bigquery_client.list_rows( - table_id, max_results=max_results, selected_fields=schema, + table_id, + max_results=max_results, + selected_fields=schema, ).to_arrow() schema = arrow_table.schema diff --git a/tests/system/test_client.py b/tests/system/test_client.py index 077bb2886..1e328e2e1 100644 --- a/tests/system/test_client.py +++ b/tests/system/test_client.py @@ -2257,17 +2257,20 @@ def test_create_tvf_routine(self): return_table_type = StandardSqlTableType( columns=[ StandardSqlField( - name="int_col", type=StandardSqlDataType(type_kind=INT64), + name="int_col", + type=StandardSqlDataType(type_kind=INT64), ), StandardSqlField( - name="str_col", type=StandardSqlDataType(type_kind=STRING), + name="str_col", + type=StandardSqlDataType(type_kind=STRING), ), ] ) routine_args = [ RoutineArgument( - name="threshold", data_type=StandardSqlDataType(type_kind=INT64), + name="threshold", + data_type=StandardSqlDataType(type_kind=INT64), ) ] diff --git a/tests/system/test_pandas.py b/tests/system/test_pandas.py index f3534cd19..ab0fb03f4 100644 --- a/tests/system/test_pandas.py +++ b/tests/system/test_pandas.py @@ -522,7 +522,10 @@ def test_load_table_from_dataframe_w_explicit_schema_source_format_csv( [ ("bool_col", [True, None, False]), ("bytes_col", ["abc", None, "def"]), - ("date_col", [datetime.date(1, 1, 1), None, datetime.date(9999, 12, 31)],), + ( + "date_col", + [datetime.date(1, 1, 1), None, datetime.date(9999, 12, 31)], + ), ( "dt_col", [ diff --git a/tests/system/test_query.py b/tests/system/test_query.py index 649120a7e..c402f66ba 100644 --- a/tests/system/test_query.py +++ b/tests/system/test_query.py @@ -20,7 +20,10 @@ def test_dry_run(bigquery_client: bigquery.Client, scalars_table: str): query_config.dry_run = True query_string = f"SELECT * FROM {scalars_table}" - query_job = bigquery_client.query(query_string, job_config=query_config,) + query_job = bigquery_client.query( + query_string, + job_config=query_config, + ) # Note: `query_job.result()` is not necessary on a dry run query. All # necessary information is returned in the initial response. diff --git a/tests/system/test_structs.py b/tests/system/test_structs.py index 20740f614..1812b6fde 100644 --- a/tests/system/test_structs.py +++ b/tests/system/test_structs.py @@ -23,7 +23,8 @@ def test_structs(bigquery_client, dataset_id, person_type_decl, table_id): ], ) cursor.execute( - f"insert into {table_id} (person) values (%(v:{person_type})s)", dict(v=data), + f"insert into {table_id} (person) values (%(v:{person_type})s)", + dict(v=data), ) cursor.execute(f"select * from {table_id}") diff --git a/tests/unit/_helpers/__init__.py b/tests/unit/_helpers/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/helpers/test_from_json.py b/tests/unit/_helpers/test_from_json.py similarity index 100% rename from tests/unit/helpers/test_from_json.py rename to tests/unit/_helpers/test_from_json.py diff --git a/tests/unit/job/test_base.py b/tests/unit/job/test_base.py index 250be83bb..f0525c22a 100644 --- a/tests/unit/job/test_base.py +++ b/tests/unit/job/test_base.py @@ -991,7 +991,10 @@ def test_result_w_retry_wo_state(self): custom_predicate = mock.Mock() custom_predicate.return_value = True custom_retry = google.api_core.retry.Retry( - predicate=custom_predicate, initial=0.001, maximum=0.001, deadline=0.1, + predicate=custom_predicate, + initial=0.001, + maximum=0.001, + deadline=0.1, ) self.assertIs(job.result(retry=custom_retry), job) diff --git a/tests/unit/job/test_query_pandas.py b/tests/unit/job/test_query_pandas.py index 1b44f65d3..775c5a302 100644 --- a/tests/unit/job/test_query_pandas.py +++ b/tests/unit/job/test_query_pandas.py @@ -146,8 +146,10 @@ def test_to_dataframe_bqstorage_preserve_order(query, table_read_options_kwarg): job.to_dataframe(bqstorage_client=bqstorage_client) - destination_table = "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( - **job_resource["configuration"]["query"]["destinationTable"] + destination_table = ( + "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( + **job_resource["configuration"]["query"]["destinationTable"] + ) ) expected_session = bigquery_storage.ReadSession( table=destination_table, @@ -272,7 +274,8 @@ def test_to_arrow_max_results_no_progress_bar(): row_iterator = table.RowIterator(client, api_request, path, schema) result_patch = mock.patch( - "google.cloud.bigquery.job.QueryJob.result", return_value=row_iterator, + "google.cloud.bigquery.job.QueryJob.result", + return_value=row_iterator, ) with result_patch as result_patch_tqdm: tbl = job.to_arrow(create_bqstorage_client=False, max_results=123) @@ -535,8 +538,10 @@ def test_to_dataframe_bqstorage(table_read_options_kwarg): job.to_dataframe(bqstorage_client=bqstorage_client) - destination_table = "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( - **resource["configuration"]["query"]["destinationTable"] + destination_table = ( + "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( + **resource["configuration"]["query"]["destinationTable"] + ) ) expected_session = bigquery_storage.ReadSession( table=destination_table, @@ -583,11 +588,14 @@ def test_to_dataframe_bqstorage_no_pyarrow_compression(): ): job.to_dataframe(bqstorage_client=bqstorage_client) - destination_table = "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( - **resource["configuration"]["query"]["destinationTable"] + destination_table = ( + "projects/{projectId}/datasets/{datasetId}/tables/{tableId}".format( + **resource["configuration"]["query"]["destinationTable"] + ) ) expected_session = bigquery_storage.ReadSession( - table=destination_table, data_format=bigquery_storage.DataFormat.ARROW, + table=destination_table, + data_format=bigquery_storage.DataFormat.ARROW, ) bqstorage_client.create_read_session.assert_called_once_with( parent=f"projects/{client.project}", @@ -705,7 +713,11 @@ def test_to_dataframe_with_progress_bar(tqdm_mock): done_resource = copy.deepcopy(begun_resource) done_resource["status"] = {"state": "DONE"} connection = make_connection( - begun_resource, query_resource, done_resource, query_resource, query_resource, + begun_resource, + query_resource, + done_resource, + query_resource, + query_resource, ) client = _make_client(connection=connection) job = target_class.from_api_repr(begun_resource, client) diff --git a/tests/unit/model/test_model.py b/tests/unit/model/test_model.py index 8f0bf58d5..4790b858b 100644 --- a/tests/unit/model/test_model.py +++ b/tests/unit/model/test_model.py @@ -79,7 +79,7 @@ def test_from_api_repr(target_class): "description": "A friendly description.", "friendlyName": "A friendly name.", "modelType": "LOGISTIC_REGRESSION", - "labels": {"greeting": u"こんにちは"}, + "labels": {"greeting": "こんにちは"}, "trainingRuns": [ { "trainingOptions": {"initialLearnRate": 1.0}, @@ -115,10 +115,10 @@ def test_from_api_repr(target_class): assert got.created == creation_time assert got.modified == modified_time assert got.expires == expiration_time - assert got.description == u"A friendly description." - assert got.friendly_name == u"A friendly name." + assert got.description == "A friendly description." + assert got.friendly_name == "A friendly name." assert got.model_type == types.Model.ModelType.LOGISTIC_REGRESSION - assert got.labels == {"greeting": u"こんにちは"} + assert got.labels == {"greeting": "こんにちは"} assert got.encryption_configuration.kms_key_name == KMS_KEY_NAME assert got.training_runs[0].training_options.initial_learn_rate == 1.0 assert ( diff --git a/tests/unit/test__helpers.py b/tests/unit/test__helpers.py index 94e63fd63..0dd1c2736 100644 --- a/tests/unit/test__helpers.py +++ b/tests/unit/test__helpers.py @@ -1150,7 +1150,8 @@ def test_w_dict_unknown_fields(self): # Unknown fields should be included (if not None), but converted as strings. self.assertEqual( - converted, {"whoami": "2020-07-20", "one": "111", "two": "222"}, + converted, + {"whoami": "2020-07-20", "one": "111", "two": "222"}, ) @@ -1327,8 +1328,7 @@ def __init__(self, mode, name="unknown", field_type="UNKNOWN", fields=()): def _field_isinstance_patcher(): - """A patcher thank makes _Field instances seem like SchemaField instances. - """ + """A patcher thank makes _Field instances seem like SchemaField instances.""" from google.cloud.bigquery.schema import SchemaField def fake_isinstance(instance, target_class): diff --git a/tests/unit/test__pandas_helpers.py b/tests/unit/test__pandas_helpers.py index ef8c80c81..c849461fd 100644 --- a/tests/unit/test__pandas_helpers.py +++ b/tests/unit/test__pandas_helpers.py @@ -1510,7 +1510,8 @@ def test__download_table_bqstorage( bqstorage_client.create_read_session.return_value = fake_session table_ref = table.TableReference( - dataset.DatasetReference("project-x", "dataset-y"), "table-z", + dataset.DatasetReference("project-x", "dataset-y"), + "table-z", ) def fake_download_stream( @@ -1692,7 +1693,8 @@ def test_bq_to_arrow_field_type_override(module_under_test): assert ( module_under_test.bq_to_arrow_field( - schema.SchemaField("g", "GEOGRAPHY"), pyarrow.binary(), + schema.SchemaField("g", "GEOGRAPHY"), + pyarrow.binary(), ).type == pyarrow.binary() ) diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 9c93765e8..92ecb72de 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -246,7 +246,9 @@ def test__call_api_applying_custom_retry_on_timeout(self): client = self._make_one(project=self.PROJECT, credentials=creds) api_request_patcher = mock.patch.object( - client._connection, "api_request", side_effect=[TimeoutError, "result"], + client._connection, + "api_request", + side_effect=[TimeoutError, "result"], ) retry = DEFAULT_RETRY.with_deadline(1).with_predicate( lambda exc: isinstance(exc, TimeoutError) @@ -269,7 +271,9 @@ def test__call_api_span_creator_not_called(self): client = self._make_one(project=self.PROJECT, credentials=creds) api_request_patcher = mock.patch.object( - client._connection, "api_request", side_effect=[TimeoutError, "result"], + client._connection, + "api_request", + side_effect=[TimeoutError, "result"], ) retry = DEFAULT_RETRY.with_deadline(1).with_predicate( lambda exc: isinstance(exc, TimeoutError) @@ -291,7 +295,9 @@ def test__call_api_span_creator_called(self): client = self._make_one(project=self.PROJECT, credentials=creds) api_request_patcher = mock.patch.object( - client._connection, "api_request", side_effect=[TimeoutError, "result"], + client._connection, + "api_request", + side_effect=[TimeoutError, "result"], ) retry = DEFAULT_RETRY.with_deadline(1).with_predicate( lambda exc: isinstance(exc, TimeoutError) @@ -456,7 +462,9 @@ def test_get_service_account_email_w_custom_retry(self): "email": "bq-123@bigquery-encryption.iam.gserviceaccount.com", } api_request_patcher = mock.patch.object( - client._connection, "api_request", side_effect=[ValueError, resource], + client._connection, + "api_request", + side_effect=[ValueError, resource], ) retry = DEFAULT_RETRY.with_deadline(1).with_predicate( @@ -749,7 +757,10 @@ def test_create_routine_w_minimal_resource(self): final_attributes.assert_called_once_with({"path": path}, client, None) conn.api_request.assert_called_once_with( - method="POST", path=path, data=resource, timeout=7.5, + method="POST", + path=path, + data=resource, + timeout=7.5, ) self.assertEqual( actual_routine.reference, RoutineReference.from_string(full_routine_id) @@ -783,7 +794,10 @@ def test_create_routine_w_conflict(self): } } conn.api_request.assert_called_once_with( - method="POST", path=path, data=resource, timeout=DEFAULT_TIMEOUT, + method="POST", + path=path, + data=resource, + timeout=DEFAULT_TIMEOUT, ) @unittest.skipIf(opentelemetry is None, "Requires `opentelemetry`") @@ -822,7 +836,10 @@ def test_span_status_is_set(self): } } conn.api_request.assert_called_once_with( - method="POST", path=path, data=resource, timeout=DEFAULT_TIMEOUT, + method="POST", + path=path, + data=resource, + timeout=DEFAULT_TIMEOUT, ) def test_create_routine_w_conflict_exists_ok(self): @@ -859,7 +876,10 @@ def test_create_routine_w_conflict_exists_ok(self): conn.api_request.assert_has_calls( [ mock.call( - method="POST", path=path, data=resource, timeout=DEFAULT_TIMEOUT, + method="POST", + path=path, + data=resource, + timeout=DEFAULT_TIMEOUT, ), mock.call( method="GET", @@ -1259,7 +1279,9 @@ def test_create_table_alreadyexists_w_exists_ok_false(self): client.create_table("{}.{}".format(self.DS_ID, self.TABLE_ID)) final_attributes.assert_called_with( - {"path": post_path, "dataset_id": self.TABLE_REF.dataset_id}, client, None, + {"path": post_path, "dataset_id": self.TABLE_REF.dataset_id}, + client, + None, ) conn.api_request.assert_called_once_with( @@ -1429,7 +1451,9 @@ def test_get_routine(self): final_attributes.assert_called_once_with({"path": path}, client, None) conn.api_request.assert_called_once_with( - method="GET", path=path, timeout=7.5, + method="GET", + path=path, + timeout=7.5, ) self.assertEqual( actual_routine.reference, @@ -1511,7 +1535,9 @@ def test_get_iam_policy(self): from google.api_core.iam import Policy PATH = "/projects/{}/datasets/{}/tables/{}:getIamPolicy".format( - self.PROJECT, self.DS_ID, self.TABLE_ID, + self.PROJECT, + self.DS_ID, + self.TABLE_ID, ) BODY = {"options": {"requestedPolicyVersion": 1}} ETAG = "CARDI" @@ -1562,7 +1588,9 @@ def test_get_iam_policy_w_invalid_table(self): client = self._make_one(project=self.PROJECT, credentials=creds, _http=http) table_resource_string = "projects/{}/datasets/{}/tables/{}".format( - self.PROJECT, self.DS_ID, self.TABLE_ID, + self.PROJECT, + self.DS_ID, + self.TABLE_ID, ) with self.assertRaises(ValueError): @@ -1782,7 +1810,11 @@ def test_update_dataset(self): with mock.patch( "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes" ) as final_attributes: - ds2 = client.update_dataset(ds, fields=fields, timeout=7.5,) + ds2 = client.update_dataset( + ds, + fields=fields, + timeout=7.5, + ) final_attributes.assert_called_once_with( {"path": "/%s" % PATH, "fields": fields}, client, None @@ -1959,7 +1991,11 @@ def test_update_routine(self): with mock.patch( "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes" ) as final_attributes: - actual_routine = client.update_routine(routine, fields, timeout=7.5,) + actual_routine = client.update_routine( + routine, + fields, + timeout=7.5, + ) final_attributes.assert_called_once_with( {"path": routine.path, "fields": fields}, client, None @@ -2129,7 +2165,9 @@ def test_update_table_w_custom_property(self): updated_table = client.update_table(table, ["newAlphaProperty"]) final_attributes.assert_called_once_with( - {"path": "/%s" % path, "fields": ["newAlphaProperty"]}, client, None, + {"path": "/%s" % path, "fields": ["newAlphaProperty"]}, + client, + None, ) conn.api_request.assert_called_once_with( @@ -2163,7 +2201,9 @@ def test_update_table_only_use_legacy_sql(self): updated_table = client.update_table(table, ["view_use_legacy_sql"]) final_attributes.assert_called_once_with( - {"path": "/%s" % path, "fields": ["view_use_legacy_sql"]}, client, None, + {"path": "/%s" % path, "fields": ["view_use_legacy_sql"]}, + client, + None, ) conn.api_request.assert_called_once_with( @@ -2243,7 +2283,9 @@ def test_update_table_w_query(self): updated_table = client.update_table(table, updated_properties) final_attributes.assert_called_once_with( - {"path": "/%s" % path, "fields": updated_properties}, client, None, + {"path": "/%s" % path, "fields": updated_properties}, + client, + None, ) self.assertEqual(updated_table.schema, table.schema) @@ -2535,7 +2577,9 @@ def test_delete_routine(self): final_attributes.assert_called_once_with({"path": path}, client, None) conn.api_request.assert_called_with( - method="DELETE", path=path, timeout=7.5, + method="DELETE", + path=path, + timeout=7.5, ) def test_delete_routine_w_wrong_type(self): @@ -2562,7 +2606,9 @@ def test_delete_routine_w_not_found_ok_false(self): final_attributes.assert_called_once_with({"path": path}, client, None) conn.api_request.assert_called_with( - method="DELETE", path=path, timeout=DEFAULT_TIMEOUT, + method="DELETE", + path=path, + timeout=DEFAULT_TIMEOUT, ) def test_delete_routine_w_not_found_ok_true(self): @@ -2584,7 +2630,9 @@ def test_delete_routine_w_not_found_ok_true(self): final_attributes.assert_called_once_with({"path": path}, client, None) conn.api_request.assert_called_with( - method="DELETE", path=path, timeout=DEFAULT_TIMEOUT, + method="DELETE", + path=path, + timeout=DEFAULT_TIMEOUT, ) def test_delete_table(self): @@ -3727,7 +3775,10 @@ def test_extract_table(self): # Check that extract_table actually starts the job. conn.api_request.assert_called_once_with( - method="POST", path="/projects/PROJECT/jobs", data=RESOURCE, timeout=7.5, + method="POST", + path="/projects/PROJECT/jobs", + data=RESOURCE, + timeout=7.5, ) # Check the job resource. @@ -3969,7 +4020,10 @@ def test_extract_table_for_source_type_model(self): # Check that extract_table actually starts the job. conn.api_request.assert_called_once_with( - method="POST", path="/projects/PROJECT/jobs", data=RESOURCE, timeout=7.5, + method="POST", + path="/projects/PROJECT/jobs", + data=RESOURCE, + timeout=7.5, ) # Check the job resource. @@ -4012,7 +4066,10 @@ def test_extract_table_for_source_type_model_w_string_model_id(self): # Check that extract_table actually starts the job. conn.api_request.assert_called_once_with( - method="POST", path="/projects/PROJECT/jobs", data=RESOURCE, timeout=7.5, + method="POST", + path="/projects/PROJECT/jobs", + data=RESOURCE, + timeout=7.5, ) def test_extract_table_for_source_type_model_w_model_object(self): @@ -4051,7 +4108,10 @@ def test_extract_table_for_source_type_model_w_model_object(self): # Check that extract_table actually starts the job. conn.api_request.assert_called_once_with( - method="POST", path="/projects/PROJECT/jobs", data=RESOURCE, timeout=7.5, + method="POST", + path="/projects/PROJECT/jobs", + data=RESOURCE, + timeout=7.5, ) def test_extract_table_for_invalid_source_type_model(self): @@ -4240,7 +4300,11 @@ def test_query_preserving_explicit_job_config(self): from google.cloud.bigquery import QueryJobConfig - client = self._make_one(project=self.PROJECT, credentials=creds, _http=http,) + client = self._make_one( + project=self.PROJECT, + credentials=creds, + _http=http, + ) conn = client._connection = make_connection(resource) job_config = QueryJobConfig() @@ -5099,7 +5163,10 @@ def test_insert_rows_w_repeated_fields(self): self.assertEqual(len(errors), 0) conn.api_request.assert_called_once_with( - method="POST", path="/%s" % PATH, data=SENT, timeout=DEFAULT_TIMEOUT, + method="POST", + path="/%s" % PATH, + data=SENT, + timeout=DEFAULT_TIMEOUT, ) def test_insert_rows_w_record_schema(self): @@ -5173,7 +5240,9 @@ def test_insert_rows_w_explicit_none_insert_ids(self): from google.cloud.bigquery.table import Table PATH = "projects/{}/datasets/{}/tables/{}/insertAll".format( - self.PROJECT, self.DS_ID, self.TABLE_ID, + self.PROJECT, + self.DS_ID, + self.TABLE_ID, ) creds = _make_credentials() http = object() @@ -5199,7 +5268,10 @@ def _row_data(row): self.assertEqual(len(errors), 0) conn.api_request.assert_called_once_with( - method="POST", path="/{}".format(PATH), data=SENT, timeout=DEFAULT_TIMEOUT, + method="POST", + path="/{}".format(PATH), + data=SENT, + timeout=DEFAULT_TIMEOUT, ) def test_insert_rows_errors(self): @@ -5581,7 +5653,10 @@ def test_insert_rows_json_default_behavior(self): self.assertEqual(len(errors), 0) conn.api_request.assert_called_once_with( - method="POST", path="/%s" % PATH, data=SENT, timeout=7.5, + method="POST", + path="/%s" % PATH, + data=SENT, + timeout=7.5, ) def test_insert_rows_json_w_explicitly_requested_autogenerated_insert_ids(self): @@ -5629,7 +5704,9 @@ def test_insert_rows_json_w_explicitly_disabled_insert_ids(self): conn = client._connection = make_connection({}) errors = client.insert_rows_json( - "proj.dset.tbl", rows, row_ids=AutoRowIDs.DISABLED, + "proj.dset.tbl", + rows, + row_ids=AutoRowIDs.DISABLED, ) self.assertEqual(len(errors), 0) @@ -5715,7 +5792,9 @@ def test_insert_rows_json_w_explicit_none_insert_ids(self): conn = client._connection = make_connection({}) errors = client.insert_rows_json( - "proj.dset.tbl", rows, row_ids=[None] * len(rows), + "proj.dset.tbl", + rows, + row_ids=[None] * len(rows), ) self.assertEqual(len(errors), 0) @@ -6420,7 +6499,10 @@ def test_load_table_from_file_resumable(self): ) with do_upload_patch as do_upload: client.load_table_from_file( - file_obj, self.TABLE_REF, job_id="job_id", job_config=job_config, + file_obj, + self.TABLE_REF, + job_id="job_id", + job_config=job_config, ) do_upload.assert_called_once_with( @@ -6738,7 +6820,10 @@ def test_load_table_from_dataframe(self): policy_tags=PolicyTagList(names=("baz",)), ), "accounts": SchemaField( - "accounts", "INTEGER", mode="REPEATED", description="array column", + "accounts", + "INTEGER", + mode="REPEATED", + description="array column", ), } get_table_schema = [ @@ -7498,7 +7583,11 @@ def test_load_table_from_dataframe_array_fields(self): schema = [ SchemaField("float_column", "FLOAT"), - SchemaField("array_column", "INTEGER", mode="REPEATED",), + SchemaField( + "array_column", + "INTEGER", + mode="REPEATED", + ), ] job_config = job.LoadJobConfig(schema=schema) @@ -7559,7 +7648,11 @@ def test_load_table_from_dataframe_array_fields_w_auto_schema(self): expected_schema = [ SchemaField("float_column", "FLOAT"), - SchemaField("array_column", "INT64", mode="REPEATED",), + SchemaField( + "array_column", + "INT64", + mode="REPEATED", + ), ] load_patch = mock.patch( @@ -7574,7 +7667,9 @@ def test_load_table_from_dataframe_array_fields_w_auto_schema(self): with load_patch as load_table_from_file, get_table_patch: client.load_table_from_dataframe( - dataframe, self.TABLE_REF, location=self.LOCATION, + dataframe, + self.TABLE_REF, + location=self.LOCATION, ) load_table_from_file.assert_called_once_with( @@ -7863,7 +7958,9 @@ def test_load_table_from_dataframe_w_bad_pyarrow_issues_warning(self): with load_patch, get_table_patch, pyarrow_version_patch: with warnings.catch_warnings(record=True) as warned: client.load_table_from_dataframe( - dataframe, self.TABLE_REF, location=self.LOCATION, + dataframe, + self.TABLE_REF, + location=self.LOCATION, ) expected_warnings = [ @@ -8206,7 +8303,11 @@ def test__do_resumable_upload_custom_project(self): client = self._make_client(transport) result = client._do_resumable_upload( - file_obj, self.EXPECTED_CONFIGURATION, None, None, project="custom-project", + file_obj, + self.EXPECTED_CONFIGURATION, + None, + None, + project="custom-project", ) content = result.content.decode("utf-8") diff --git a/tests/unit/test_dbapi__helpers.py b/tests/unit/test_dbapi__helpers.py index 5965a4817..3c1673f4f 100644 --- a/tests/unit/test_dbapi__helpers.py +++ b/tests/unit/test_dbapi__helpers.py @@ -603,7 +603,8 @@ def test_complex_query_parameter_type_errors(type_, value, expect): from google.cloud.bigquery.dbapi import exceptions with pytest.raises( - exceptions.ProgrammingError, match=_expected_error_match(expect), + exceptions.ProgrammingError, + match=_expected_error_match(expect), ): complex_query_parameter("test", value, type_) diff --git a/tests/unit/test_dbapi_connection.py b/tests/unit/test_dbapi_connection.py index 11a268c68..d9d098212 100644 --- a/tests/unit/test_dbapi_connection.py +++ b/tests/unit/test_dbapi_connection.py @@ -69,7 +69,8 @@ def test_ctor_w_bqstorage_client(self): mock_client._ensure_bqstorage_client.return_value = mock_bqstorage_client connection = self._make_one( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) mock_client._ensure_bqstorage_client.assert_called_once_with( @@ -119,7 +120,8 @@ def test_connect_w_both_clients(self): mock_client._ensure_bqstorage_client.return_value = mock_bqstorage_client connection = connect( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) mock_client._ensure_bqstorage_client.assert_called_once_with( @@ -154,7 +156,9 @@ def test_close_closes_all_created_bigquery_clients(self): return_value=client, ) bqstorage_client_patcher = mock.patch.object( - client, "_ensure_bqstorage_client", return_value=bqstorage_client, + client, + "_ensure_bqstorage_client", + return_value=bqstorage_client, ) with client_patcher, bqstorage_client_patcher: diff --git a/tests/unit/test_dbapi_cursor.py b/tests/unit/test_dbapi_cursor.py index cb55da889..8ad62f75f 100644 --- a/tests/unit/test_dbapi_cursor.py +++ b/tests/unit/test_dbapi_cursor.py @@ -309,12 +309,14 @@ def test_fetchall_w_bqstorage_client_fetch_success(self): mock_client = self._mock_client(rows=row_data) mock_bqstorage_client = self._mock_bqstorage_client( - stream_count=1, rows=bqstorage_streamed_rows, + stream_count=1, + rows=bqstorage_streamed_rows, ) mock_client._ensure_bqstorage_client.return_value = mock_bqstorage_client connection = dbapi.connect( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) cursor = connection.cursor() cursor.execute("SELECT foo, bar FROM some_table") @@ -345,7 +347,8 @@ def test_fetchall_w_bqstorage_client_fetch_no_rows(self): mock_client._ensure_bqstorage_client.return_value = mock_bqstorage_client connection = dbapi.connect( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) cursor = connection.cursor() cursor.execute("SELECT foo, bar FROM some_table") @@ -373,13 +376,15 @@ def fake_ensure_bqstorage_client(bqstorage_client=None, **kwargs): mock_client = self._mock_client(rows=row_data) mock_client._ensure_bqstorage_client.side_effect = fake_ensure_bqstorage_client mock_bqstorage_client = self._mock_bqstorage_client( - stream_count=1, rows=row_data, + stream_count=1, + rows=row_data, ) no_access_error = exceptions.Forbidden("invalid credentials") mock_bqstorage_client.create_read_session.side_effect = no_access_error connection = dbapi.connect( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) cursor = connection.cursor() cursor.execute("SELECT foo, bar FROM some_table") @@ -408,11 +413,13 @@ def fake_ensure_bqstorage_client(bqstorage_client=None, **kwargs): mock_client = self._mock_client(rows=row_data) mock_client._ensure_bqstorage_client.side_effect = fake_ensure_bqstorage_client mock_bqstorage_client = self._mock_bqstorage_client( - stream_count=1, rows=bqstorage_streamed_rows, + stream_count=1, + rows=bqstorage_streamed_rows, ) connection = dbapi.connect( - client=mock_client, bqstorage_client=mock_bqstorage_client, + client=mock_client, + bqstorage_client=mock_bqstorage_client, ) cursor = connection.cursor() cursor.execute("SELECT foo, bar FROM some_table") diff --git a/tests/unit/test_dbapi_types.py b/tests/unit/test_dbapi_types.py index cf282c68b..7319aa016 100644 --- a/tests/unit/test_dbapi_types.py +++ b/tests/unit/test_dbapi_types.py @@ -48,8 +48,8 @@ def __bytes__(self): @pytest.mark.parametrize( "raw,expected", [ - (u"hello", b"hello"), - (u"\u1f60", u"\u1f60".encode("utf-8")), + ("hello", b"hello"), + ("\u1f60", "\u1f60".encode("utf-8")), (b"hello", b"hello"), (bytearray(b"hello"), b"hello"), (memoryview(b"hello"), b"hello"), diff --git a/tests/unit/test_list_jobs.py b/tests/unit/test_list_jobs.py index 1fb40d446..1db6b5668 100644 --- a/tests/unit/test_list_jobs.py +++ b/tests/unit/test_list_jobs.py @@ -258,7 +258,7 @@ def test_list_jobs_w_time_filter(client, PROJECT): start_time = datetime.datetime(1970, 1, 1, 0, 0, 0, 1000) # One millisecond after the the 2038 31-bit signed int rollover end_time = datetime.datetime(2038, 1, 19, 3, 14, 7, 1000) - end_time_millis = (((2 ** 31) - 1) * 1000) + 1 + end_time_millis = (((2**31) - 1) * 1000) + 1 list(client.list_jobs(min_creation_time=start_time, max_creation_time=end_time)) diff --git a/tests/unit/test_list_models.py b/tests/unit/test_list_models.py index b14852338..04932d357 100644 --- a/tests/unit/test_list_models.py +++ b/tests/unit/test_list_models.py @@ -40,7 +40,13 @@ def test_list_models_empty_w_timeout(client, PROJECT, DS_ID): ) @dataset_polymorphic def test_list_models_defaults( - make_dataset, get_reference, client, PROJECT, DS_ID, extra, query, + make_dataset, + get_reference, + client, + PROJECT, + DS_ID, + extra, + query, ): from google.cloud.bigquery.model import Model diff --git a/tests/unit/test_magics.py b/tests/unit/test_magics.py index a4214f32f..72ae4af21 100644 --- a/tests/unit/test_magics.py +++ b/tests/unit/test_magics.py @@ -571,7 +571,8 @@ def test_bigquery_magic_does_not_clear_display_in_verbose_mode(): ) clear_patch = mock.patch( - "google.cloud.bigquery.magics.magics.display.clear_output", autospec=True, + "google.cloud.bigquery.magics.magics.display.clear_output", + autospec=True, ) run_query_patch = mock.patch( "google.cloud.bigquery.magics.magics._run_query", autospec=True @@ -591,7 +592,8 @@ def test_bigquery_magic_clears_display_in_non_verbose_mode(): ) clear_patch = mock.patch( - "google.cloud.bigquery.magics.magics.display.clear_output", autospec=True, + "google.cloud.bigquery.magics.magics.display.clear_output", + autospec=True, ) run_query_patch = mock.patch( "google.cloud.bigquery.magics.magics._run_query", autospec=True @@ -785,7 +787,8 @@ def test_bigquery_magic_w_max_results_query_job_results_fails(): "google.cloud.bigquery.client.Client.query", autospec=True ) close_transports_patch = mock.patch( - "google.cloud.bigquery.magics.magics._close_transports", autospec=True, + "google.cloud.bigquery.magics.magics._close_transports", + autospec=True, ) sql = "SELECT 17 AS num" @@ -938,7 +941,8 @@ def test_bigquery_magic_w_table_id_and_bqstorage_client(): ip.run_cell_magic("bigquery", "--max_results=5", table_id) row_iterator_mock.to_dataframe.assert_called_once_with( - bqstorage_client=bqstorage_instance_mock, create_bqstorage_client=mock.ANY, + bqstorage_client=bqstorage_instance_mock, + create_bqstorage_client=mock.ANY, ) @@ -2023,7 +2027,8 @@ def test_bigquery_magic_create_dataset_fails(): side_effect=OSError, ) close_transports_patch = mock.patch( - "google.cloud.bigquery.magics.magics._close_transports", autospec=True, + "google.cloud.bigquery.magics.magics._close_transports", + autospec=True, ) with pytest.raises( diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index 69a6772e5..a966b88b1 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -825,7 +825,8 @@ def test_to_api_repr_array_type_as_type_instance(self): } klass = self._get_target_class() param = klass.positional( - array_type=ScalarQueryParameterType("BOOLEAN"), values=[True, False], + array_type=ScalarQueryParameterType("BOOLEAN"), + values=[True, False], ) self.assertEqual(param.to_api_repr(), EXPECTED) diff --git a/tests/unit/test_schema.py b/tests/unit/test_schema.py index 03ff837c0..a0b1b5d11 100644 --- a/tests/unit/test_schema.py +++ b/tests/unit/test_schema.py @@ -96,7 +96,8 @@ def test_to_api_repr(self): policy = PolicyTagList(names=("foo", "bar")) self.assertEqual( - policy.to_api_repr(), {"names": ["foo", "bar"]}, + policy.to_api_repr(), + {"names": ["foo", "bar"]}, ) field = self._make_one( @@ -525,7 +526,11 @@ def test___repr__evaluable_no_policy_tags(self): def test___repr__evaluable_with_policy_tags(self): policy_tags = PolicyTagList(names=["foo", "bar"]) field = self._make_one( - "field1", "STRING", "REQUIRED", "Description", policy_tags=policy_tags, + "field1", + "STRING", + "REQUIRED", + "Description", + policy_tags=policy_tags, ) field_repr = repr(field) SchemaField = self._get_target_class() # needed for eval # noqa @@ -609,10 +614,12 @@ def test_defaults(self): resource = self._call_fut([full_name, age]) self.assertEqual(len(resource), 2) self.assertEqual( - resource[0], {"name": "full_name", "type": "STRING", "mode": "REQUIRED"}, + resource[0], + {"name": "full_name", "type": "STRING", "mode": "REQUIRED"}, ) self.assertEqual( - resource[1], {"name": "age", "type": "INTEGER", "mode": "REQUIRED"}, + resource[1], + {"name": "age", "type": "INTEGER", "mode": "REQUIRED"}, ) def test_w_description(self): @@ -662,7 +669,8 @@ def test_w_subfields(self): resource = self._call_fut([full_name, phone]) self.assertEqual(len(resource), 2) self.assertEqual( - resource[0], {"name": "full_name", "type": "STRING", "mode": "REQUIRED"}, + resource[0], + {"name": "full_name", "type": "STRING", "mode": "REQUIRED"}, ) self.assertEqual( resource[1], @@ -775,11 +783,13 @@ def test_from_api_repr(self): def test_to_api_repr(self): taglist = self._make_one(names=["foo", "bar"]) self.assertEqual( - taglist.to_api_repr(), {"names": ["foo", "bar"]}, + taglist.to_api_repr(), + {"names": ["foo", "bar"]}, ) taglist2 = self._make_one(names=("foo", "bar")) self.assertEqual( - taglist2.to_api_repr(), {"names": ["foo", "bar"]}, + taglist2.to_api_repr(), + {"names": ["foo", "bar"]}, ) def test___eq___wrong_type(self): @@ -916,11 +926,22 @@ def test_from_api_repr_parameterized(api, expect, key2): ), ( dict(name="n", field_type="NUMERIC", precision=9), - dict(name="n", type="NUMERIC", mode="NULLABLE", precision=9,), + dict( + name="n", + type="NUMERIC", + mode="NULLABLE", + precision=9, + ), ), ( dict(name="n", field_type="NUMERIC", precision=9, scale=2), - dict(name="n", type="NUMERIC", mode="NULLABLE", precision=9, scale=2,), + dict( + name="n", + type="NUMERIC", + mode="NULLABLE", + precision=9, + scale=2, + ), ), ( dict(name="n", field_type="BIGNUMERIC"), @@ -928,11 +949,22 @@ def test_from_api_repr_parameterized(api, expect, key2): ), ( dict(name="n", field_type="BIGNUMERIC", precision=40), - dict(name="n", type="BIGNUMERIC", mode="NULLABLE", precision=40,), + dict( + name="n", + type="BIGNUMERIC", + mode="NULLABLE", + precision=40, + ), ), ( dict(name="n", field_type="BIGNUMERIC", precision=40, scale=2), - dict(name="n", type="BIGNUMERIC", mode="NULLABLE", precision=40, scale=2,), + dict( + name="n", + type="BIGNUMERIC", + mode="NULLABLE", + precision=40, + scale=2, + ), ), ( dict(name="n", field_type="STRING"), @@ -940,7 +972,12 @@ def test_from_api_repr_parameterized(api, expect, key2): ), ( dict(name="n", field_type="STRING", max_length=9), - dict(name="n", type="STRING", mode="NULLABLE", maxLength=9,), + dict( + name="n", + type="STRING", + mode="NULLABLE", + maxLength=9, + ), ), ( dict(name="n", field_type="BYTES"), @@ -948,7 +985,12 @@ def test_from_api_repr_parameterized(api, expect, key2): ), ( dict(name="n", field_type="BYTES", max_length=9), - dict(name="n", type="BYTES", mode="NULLABLE", maxLength=9,), + dict( + name="n", + type="BYTES", + mode="NULLABLE", + maxLength=9, + ), ), ], ) diff --git a/tests/unit/test_table.py b/tests/unit/test_table.py index 4f45eac3d..23c7a8461 100644 --- a/tests/unit/test_table.py +++ b/tests/unit/test_table.py @@ -2859,7 +2859,8 @@ def test_to_arrow_progress_bar(self, tqdm_mock, tqdm_notebook_mock, tqdm_gui_moc for progress_bar_type, progress_bar_mock in progress_bars: row_iterator = self._make_one(_mock_client(), api_request, path, schema) tbl = row_iterator.to_arrow( - progress_bar_type=progress_bar_type, create_bqstorage_client=False, + progress_bar_type=progress_bar_type, + create_bqstorage_client=False, ) progress_bar_mock.assert_called() @@ -3218,7 +3219,8 @@ def test_to_dataframe_progress_bar( for progress_bar_type, progress_bar_mock in progress_bars: row_iterator = self._make_one(_mock_client(), api_request, path, schema) df = row_iterator.to_dataframe( - progress_bar_type=progress_bar_type, create_bqstorage_client=False, + progress_bar_type=progress_bar_type, + create_bqstorage_client=False, ) progress_bar_mock.assert_called() @@ -3275,7 +3277,8 @@ def test_to_dataframe_no_tqdm(self): with warnings.catch_warnings(record=True) as warned: df = row_iterator.to_dataframe( - progress_bar_type="tqdm", create_bqstorage_client=False, + progress_bar_type="tqdm", + create_bqstorage_client=False, ) user_warnings = [ @@ -3313,7 +3316,8 @@ def test_to_dataframe_tqdm_error(self): with warnings.catch_warnings(record=True) as warned: df = row_iterator.to_dataframe( - progress_bar_type=progress_bar_type, create_bqstorage_client=False, + progress_bar_type=progress_bar_type, + create_bqstorage_client=False, ) self.assertEqual(len(df), 4) # all should be well @@ -3355,9 +3359,9 @@ def test_to_dataframe_w_various_types_nullable(self): ] row_data = [ [None, None, None, None, None, None], - ["1433836800000000", "420", "1.1", u"Cash", "true", "1999-12-01"], - ["1387811700000000", "2580", "17.7", u"Cash", "false", "1953-06-14"], - ["1385565300000000", "2280", "4.4", u"Credit", "true", "1981-11-04"], + ["1433836800000000", "420", "1.1", "Cash", "true", "1999-12-01"], + ["1387811700000000", "2580", "17.7", "Cash", "false", "1953-06-14"], + ["1385565300000000", "2280", "4.4", "Credit", "true", "1981-11-04"], ] rows = [{"f": [{"v": field} for field in row]} for row in row_data] path = "/foo" @@ -3395,17 +3399,17 @@ def test_to_dataframe_column_dtypes(self): SchemaField("date", "DATE"), ] row_data = [ - ["1433836800000000", "420", "1.1", "1.77", u"Cash", "true", "1999-12-01"], + ["1433836800000000", "420", "1.1", "1.77", "Cash", "true", "1999-12-01"], [ "1387811700000000", "2580", "17.7", "28.5", - u"Cash", + "Cash", "false", "1953-06-14", ], - ["1385565300000000", "2280", "4.4", "7.1", u"Credit", "true", "1981-11-04"], + ["1385565300000000", "2280", "4.4", "7.1", "Credit", "true", "1981-11-04"], ] rows = [{"f": [{"v": field} for field in row]} for row in row_data] path = "/foo" @@ -3413,7 +3417,8 @@ def test_to_dataframe_column_dtypes(self): row_iterator = self._make_one(_mock_client(), api_request, path, schema) df = row_iterator.to_dataframe( - dtypes={"km": "float16"}, create_bqstorage_client=False, + dtypes={"km": "float16"}, + create_bqstorage_client=False, ) self.assertIsInstance(df, pandas.DataFrame) @@ -4037,7 +4042,8 @@ def test_to_dataframe_tabledata_list_w_multiple_pages_return_unique_index(self): ) df = row_iterator.to_dataframe( - bqstorage_client=None, create_bqstorage_client=False, + bqstorage_client=None, + create_bqstorage_client=False, ) self.assertIsInstance(df, pandas.DataFrame) @@ -4054,8 +4060,10 @@ def test_to_dataframe_w_bqstorage_raises_auth_error(self): from google.cloud.bigquery import table as mut bqstorage_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) - bqstorage_client.create_read_session.side_effect = google.api_core.exceptions.Forbidden( - "TEST BigQuery Storage API not enabled. TEST" + bqstorage_client.create_read_session.side_effect = ( + google.api_core.exceptions.Forbidden( + "TEST BigQuery Storage API not enabled. TEST" + ) ) path = "/foo" api_request = mock.Mock(return_value={"rows": []}) @@ -4185,7 +4193,8 @@ def test_to_dataframe_concat_categorical_dtype_w_pyarrow(self): bqstorage_client=bqstorage_client, dtypes={ "col_category": pandas.core.dtypes.dtypes.CategoricalDtype( - categories=["low", "medium", "high"], ordered=False, + categories=["low", "medium", "high"], + ordered=False, ), }, ) @@ -4203,7 +4212,8 @@ def test_to_dataframe_concat_categorical_dtype_w_pyarrow(self): expected_dtypes = [ pandas.core.dtypes.dtypes.np.dtype("O"), # the default for string data pandas.core.dtypes.dtypes.CategoricalDtype( - categories=["low", "medium", "high"], ordered=False, + categories=["low", "medium", "high"], + ordered=False, ), ] self.assertEqual(list(got.dtypes), expected_dtypes) @@ -4228,7 +4238,8 @@ def test_to_dataframe_geography_as_object(self): ), ) df = row_iterator.to_dataframe( - create_bqstorage_client=False, geography_as_object=True, + create_bqstorage_client=False, + geography_as_object=True, ) self.assertIsInstance(df, pandas.DataFrame) self.assertEqual(len(df), 3) # verify the number of rows @@ -4395,7 +4406,10 @@ def test_rowiterator_to_geodataframe_delegation(self, to_dataframe): geography_column = "g" to_dataframe.return_value = pandas.DataFrame( - dict(name=["foo"], g=[wkt.loads("point(0 0)")],) + dict( + name=["foo"], + g=[wkt.loads("point(0 0)")], + ) ) df = row_iterator.to_geodataframe(