@@ -90,12 +90,15 @@ def _timestamp_query_param_from_json(value, field):
9090
9191 Args:
9292 value (str): The timestamp.
93- field (.SchemaField): The field corresponding to the value.
93+
94+ field (google.cloud.bigquery.schema.SchemaField):
95+ The field corresponding to the value.
9496
9597 Returns:
96- Optional[datetime.datetime]: The parsed datetime object from
97- ``value`` if the ``field`` is not null (otherwise it is
98- :data:`None`).
98+ Optional[datetime.datetime]:
99+ The parsed datetime object from
100+ ``value`` if the ``field`` is not null (otherwise it is
101+ :data:`None`).
99102 """
100103 if _not_null (value , field ):
101104 # Canonical formats for timestamps in BigQuery are flexible. See:
@@ -125,12 +128,14 @@ def _datetime_from_json(value, field):
125128
126129 Args:
127130 value (str): The timestamp.
128- field (.SchemaField): The field corresponding to the value.
131+ field (google.cloud.bigquery.schema.SchemaField):
132+ The field corresponding to the value.
129133
130134 Returns:
131- Optional[datetime.datetime]: The parsed datetime object from
132- ``value`` if the ``field`` is not null (otherwise it is
133- :data:`None`).
135+ Optional[datetime.datetime]:
136+ The parsed datetime object from
137+ ``value`` if the ``field`` is not null (otherwise it is
138+ :data:`None`).
134139 """
135140 if _not_null (value , field ):
136141 if "." in value :
@@ -217,15 +222,12 @@ def _row_tuple_from_json(row, schema):
217222
218223 Note: ``row['f']`` and ``schema`` are presumed to be of the same length.
219224
220- :type row: dict
221- :param row: A JSON response row to be converted.
222-
223- :type schema: tuple
224- :param schema: A tuple of
225- :class:`~google.cloud.bigquery.schema.SchemaField`.
225+ Args:
226+ row (Dict): A JSON response row to be converted.
227+ schema (Tuple): A tuple of :class:`~google.cloud.bigquery.schema.SchemaField`.
226228
227- :rtype: tuple
228- :returns : A tuple of data converted to native types.
229+ Returns:
230+ Tuple : A tuple of data converted to native types.
229231 """
230232 row_data = []
231233 for field , cell in zip (schema , row ["f" ]):
@@ -344,16 +346,13 @@ def _scalar_field_to_json(field, row_value):
344346 """Maps a field and value to a JSON-safe value.
345347
346348 Args:
347- field ( \
348- :class:`~google.cloud.bigquery.schema.SchemaField`, \
349- ):
349+ field (google.cloud.bigquery.schema.SchemaField):
350350 The SchemaField to use for type conversion and field name.
351- row_value (any ):
351+ row_value (Any ):
352352 Value to be converted, based on the field's type.
353353
354354 Returns:
355- any:
356- A JSON-serializable object.
355+ Any: A JSON-serializable object.
357356 """
358357 converter = _SCALAR_VALUE_TO_JSON_ROW .get (field .field_type )
359358 if converter is None : # STRING doesn't need converting
@@ -365,17 +364,14 @@ def _repeated_field_to_json(field, row_value):
365364 """Convert a repeated/array field to its JSON representation.
366365
367366 Args:
368- field ( \
369- :class:`~google.cloud.bigquery.schema.SchemaField`, \
370- ):
367+ field (google.cloud.bigquery.schema.SchemaField):
371368 The SchemaField to use for type conversion and field name. The
372369 field mode must equal ``REPEATED``.
373- row_value (Sequence[any ]):
370+ row_value (Sequence[Any ]):
374371 A sequence of values to convert to JSON-serializable values.
375372
376373 Returns:
377- List[any]:
378- A list of JSON-serializable objects.
374+ List[Any]: A list of JSON-serializable objects.
379375 """
380376 # Remove the REPEATED, but keep the other fields. This allows us to process
381377 # each item as if it were a top-level field.
@@ -391,17 +387,14 @@ def _record_field_to_json(fields, row_value):
391387 """Convert a record/struct field to its JSON representation.
392388
393389 Args:
394- fields ( \
395- Sequence[:class:`~google.cloud.bigquery.schema.SchemaField`], \
396- ):
390+ fields (Sequence[google.cloud.bigquery.schema.SchemaField]):
397391 The :class:`~google.cloud.bigquery.schema.SchemaField`s of the
398392 record's subfields to use for type conversion and field names.
399393 row_value (Union[Tuple[Any], Mapping[str, Any]):
400394 A tuple or dictionary to convert to JSON-serializable values.
401395
402396 Returns:
403- Mapping[str, any]:
404- A JSON-serializable dictionary.
397+ Mapping[str, Any]: A JSON-serializable dictionary.
405398 """
406399 record = {}
407400 isdict = isinstance (row_value , dict )
@@ -420,22 +413,16 @@ def _field_to_json(field, row_value):
420413 """Convert a field into JSON-serializable values.
421414
422415 Args:
423- field ( \
424- :class:`~google.cloud.bigquery.schema.SchemaField`, \
425- ):
416+ field (google.cloud.bigquery.schema.SchemaField):
426417 The SchemaField to use for type conversion and field name.
427418
428- row_value (Union[ \
429- Sequence[list], \
430- any, \
431- ]):
419+ row_value (Union[Sequence[List], Any]):
432420 Row data to be inserted. If the SchemaField's mode is
433421 REPEATED, assume this is a list. If not, the type
434422 is inferred from the SchemaField's field_type.
435423
436424 Returns:
437- any:
438- A JSON-serializable object.
425+ Any: A JSON-serializable object.
439426 """
440427 if row_value is None :
441428 return None
@@ -461,9 +448,9 @@ def _get_sub_prop(container, keys, default=None):
461448 This method works like ``dict.get(key)``, but for nested values.
462449
463450 Arguments:
464- container (dict ):
451+ container (Dict ):
465452 A dictionary which may contain other dictionaries as values.
466- keys (iterable ):
453+ keys (Iterable ):
467454 A sequence of keys to attempt to get the value for. Each item in
468455 the sequence represents a deeper nesting. The first key is for
469456 the top level. If there is a dictionary there, the second key
@@ -504,9 +491,9 @@ def _set_sub_prop(container, keys, value):
504491 """Set a nested value in a dictionary.
505492
506493 Arguments:
507- container (dict ):
494+ container (Dict ):
508495 A dictionary which may contain other dictionaries as values.
509- keys (iterable ):
496+ keys (Iterable ):
510497 A sequence of keys to attempt to set the value for. Each item in
511498 the sequence represents a deeper nesting. The first key is for
512499 the top level. If there is a dictionary there, the second key
@@ -547,9 +534,9 @@ def _del_sub_prop(container, keys):
547534 """Remove a nested key fro a dictionary.
548535
549536 Arguments:
550- container (dict ):
537+ container (Dict ):
551538 A dictionary which may contain other dictionaries as values.
552- keys (iterable ):
539+ keys (Iterable ):
553540 A sequence of keys to attempt to clear the value for. Each item in
554541 the sequence represents a deeper nesting. The first key is for
555542 the top level. If there is a dictionary there, the second key
0 commit comments