Skip to content

Commit 1b0ce1d

Browse files
authored
docs: fix docstring types and typos (#259)
* docs: fix docstring types * docs: fix typos * docs: correctly reference logging.Logger type * docs: fix pool bind parameter docstring Co-authored-by: larkee <[email protected]>
1 parent 0d7722b commit 1b0ce1d

13 files changed

+68
-65
lines changed

google/cloud/spanner_v1/_helpers.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ def _merge_query_options(base, merge):
5353
"""Merge higher precedence QueryOptions with current QueryOptions.
5454
5555
:type base:
56-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
56+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
5757
or :class:`dict` or None
5858
:param base: The current QueryOptions that is intended for use.
5959
6060
:type merge:
61-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
61+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
6262
or :class:`dict` or None
6363
:param merge:
6464
The QueryOptions that have a higher priority than base. These options
6565
should overwrite the fields in base.
6666
6767
:rtype:
68-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
68+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
6969
or None
7070
:returns:
7171
QueryOptions object formed by merging the two given QueryOptions.
@@ -167,7 +167,7 @@ def _parse_value_pb(value_pb, field_type):
167167
:type value_pb: :class:`~google.protobuf.struct_pb2.Value`
168168
:param value_pb: protobuf to convert
169169
170-
:type field_type: :class:`~google.cloud.spanner_v1.Type`
170+
:type field_type: :class:`~google.cloud.spanner_v1.types.Type`
171171
:param field_type: type code for the value
172172
173173
:rtype: varies on field_type
@@ -220,7 +220,7 @@ def _parse_list_value_pbs(rows, row_type):
220220
:type rows: list of :class:`~google.protobuf.struct_pb2.ListValue`
221221
:param rows: row data returned from a read/query
222222
223-
:type row_type: :class:`~google.cloud.spanner_v1.StructType`
223+
:type row_type: :class:`~google.cloud.spanner_v1.types.StructType`
224224
:param row_type: row schema specification
225225
226226
:rtype: list of list of cell data

google/cloud/spanner_v1/backup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def size_bytes(self):
141141
def state(self):
142142
"""State of this backup.
143143
144-
:rtype: :class:`~google.cloud.spanner_admin_database_v1.Backup.State`
144+
:rtype: :class:`~google.cloud.spanner_admin_database_v1.types.Backup.State`
145145
:returns: an enum describing the state of the backup
146146
"""
147147
return self._state
@@ -160,7 +160,7 @@ def referencing_databases(self):
160160
def from_pb(cls, backup_pb, instance):
161161
"""Create an instance of this class from a protobuf message.
162162
163-
:type backup_pb: :class:`~google.spanner.admin.database.v1.Backup`
163+
:type backup_pb: :class:`~google.cloud.spanner_admin_database_v1.types.Backup`
164164
:param backup_pb: A backup protobuf object.
165165
166166
:type instance: :class:`~google.cloud.spanner_v1.instance.Instance`

google/cloud/spanner_v1/batch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
179179

180180

181181
def _make_write_pb(table, columns, values):
182-
"""Helper for :meth:`Batch.insert` et aliae.
182+
"""Helper for :meth:`Batch.insert` et al.
183183
184184
:type table: str
185185
:param table: Name of the table to be modified.
@@ -190,7 +190,7 @@ def _make_write_pb(table, columns, values):
190190
:type values: list of lists
191191
:param values: Values to be modified.
192192
193-
:rtype: :class:`google.cloud.spanner_v1.Mutation.Write`
193+
:rtype: :class:`google.cloud.spanner_v1.types.Mutation.Write`
194194
:returns: Write protobuf
195195
"""
196196
return Mutation.Write(

google/cloud/spanner_v1/client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ class Client(ClientWithProject):
108108
on the client. API Endpoint should be set through client_options.
109109
110110
:type query_options:
111-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
111+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
112112
or :class:`dict`
113113
:param query_options:
114114
(Optional) Query optimizer configuration to use for the given query.
115115
If a dict is provided, it must be of the same form as the protobuf
116-
message :class:`~google.cloud.spanner_v1.QueryOptions`
116+
message :class:`~google.cloud.spanner_v1.types.QueryOptions`
117117
118118
:raises: :class:`ValueError <exceptions.ValueError>` if both ``read_only``
119119
and ``admin`` are :data:`True`
@@ -348,7 +348,7 @@ def list_instances(self, filter_="", page_size=None):
348348
349349
:rtype: :class:`~google.api_core.page_iterator.Iterator`
350350
:returns:
351-
Iterator of :class:`~google.cloud.spanner_v1.instance.Instance`
351+
Iterator of :class:`~google.cloud.spanner_admin_instance_v1.types.Instance`
352352
resources within the client's project.
353353
"""
354354
metadata = _metadata_with_prefix(self.project_name)

google/cloud/spanner_v1/database.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Database(object):
103103
passed, the database will construct an instance of
104104
:class:`~google.cloud.spanner_v1.pool.BurstyPool`.
105105
106-
:type logger: `logging.Logger`
106+
:type logger: :class:`logging.Logger`
107107
:param logger: (Optional) a custom logger that is used if `log_commit_stats`
108108
is `True` to log commit statistics. If not passed, a logger
109109
will be created when needed that will log the commit statistics
@@ -138,7 +138,7 @@ def from_pb(cls, database_pb, instance, pool=None):
138138
"""Creates an instance of this class from a protobuf.
139139
140140
:type database_pb:
141-
:class:`~google.cloud.spanner_admin_instance_v1.Instance`
141+
:class:`~google.cloud.spanner_admin_instance_v1.types.Instance`
142142
:param database_pb: A instance protobuf object.
143143
144144
:type instance: :class:`~google.cloud.spanner_v1.instance.Instance`
@@ -199,7 +199,7 @@ def name(self):
199199
def state(self):
200200
"""State of this database.
201201
202-
:rtype: :class:`~google.cloud.spanner_admin_database_v1.Database.State`
202+
:rtype: :class:`~google.cloud.spanner_admin_database_v1.types.Database.State`
203203
:returns: an enum describing the state of the database
204204
"""
205205
return self._state
@@ -218,7 +218,7 @@ def create_time(self):
218218
def restore_info(self):
219219
"""Restore info for this database.
220220
221-
:rtype: :class:`~google.cloud.spanner_v1.database.RestoreInfo`
221+
:rtype: :class:`~google.cloud.spanner_v1.types.RestoreInfo`
222222
:returns: an object representing the restore info for this database
223223
"""
224224
return self._restore_info
@@ -310,7 +310,7 @@ def __ne__(self, other):
310310
def create(self):
311311
"""Create this database within its instance
312312
313-
Inclues any configured schema assigned to :attr:`ddl_statements`.
313+
Includes any configured schema assigned to :attr:`ddl_statements`.
314314
315315
See
316316
https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase
@@ -429,12 +429,12 @@ def execute_partitioned_dml(
429429
required if parameters are passed.
430430
431431
:type query_options:
432-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
432+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
433433
or :class:`dict`
434434
:param query_options:
435435
(Optional) Query optimizer configuration to use for the given query.
436436
If a dict is provided, it must be of the same form as the protobuf
437-
message :class:`~google.cloud.spanner_v1.QueryOptions`
437+
message :class:`~google.cloud.spanner_v1.types.QueryOptions`
438438
439439
:rtype: int
440440
:returns: Count of rows affected by the DML statement.
@@ -568,7 +568,7 @@ def run_in_transaction(self, func, *args, **kw):
568568
:returns: The return value of ``func``.
569569
570570
:raises Exception:
571-
reraises any non-ABORT execptions raised by ``func``.
571+
reraises any non-ABORT exceptions raised by ``func``.
572572
"""
573573
# Sanity check: Is there a transaction already running?
574574
# If there is, then raise a red flag. Otherwise, mark that this one
@@ -895,7 +895,7 @@ def generate_read_batches(
895895
896896
:rtype: iterable of dict
897897
:returns:
898-
mappings of information used peform actual partitioned reads via
898+
mappings of information used perform actual partitioned reads via
899899
:meth:`process_read_batch`.
900900
"""
901901
partitions = self._get_snapshot().partition_read(
@@ -945,7 +945,7 @@ def generate_query_batches(
945945
946946
Uses the ``PartitionQuery`` API request to start a partitioned
947947
query operation. Returns a list of batch information needed to
948-
peform the actual queries.
948+
perform the actual queries.
949949
950950
:type sql: str
951951
:param sql: SQL query statement
@@ -976,16 +976,16 @@ def generate_query_batches(
976976
differ.
977977
978978
:type query_options:
979-
:class:`~google.cloud.spanner_v1.ExecuteSqlRequest.QueryOptions`
979+
:class:`~google.cloud.spanner_v1.types.ExecuteSqlRequest.QueryOptions`
980980
or :class:`dict`
981981
:param query_options:
982982
(Optional) Query optimizer configuration to use for the given query.
983983
If a dict is provided, it must be of the same form as the protobuf
984-
message :class:`~google.cloud.spanner_v1.QueryOptions`
984+
message :class:`~google.cloud.spanner_v1.types.QueryOptions`
985985
986986
:rtype: iterable of dict
987987
:returns:
988-
mappings of information used peform actual partitioned reads via
988+
mappings of information used perform actual partitioned reads via
989989
:meth:`process_read_batch`.
990990
"""
991991
partitions = self._get_snapshot().partition_query(
@@ -1065,7 +1065,7 @@ def _check_ddl_statements(value):
10651065
https://cloud.google.com/spanner/docs/data-definition-language
10661066
10671067
:type value: list of string
1068-
:param value: DDL statements, excluding the 'CREATE DATABSE' statement
1068+
:param value: DDL statements, excluding the 'CREATE DATABASE' statement
10691069
10701070
:rtype: tuple
10711071
:returns: tuple of validated DDL statement strings.

google/cloud/spanner_v1/instance.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def delete(self):
349349
350350
Soon afterward:
351351
352-
* The instance and all databases within the instance will be deleteed.
352+
* The instance and all databases within the instance will be deleted.
353353
All data in the databases will be permanently deleted.
354354
"""
355355
api = self._client.instance_admin_api
@@ -365,13 +365,13 @@ def database(self, database_id, ddl_statements=(), pool=None, logger=None):
365365
366366
:type ddl_statements: list of string
367367
:param ddl_statements: (Optional) DDL statements, excluding the
368-
'CREATE DATABSE' statement.
368+
'CREATE DATABASE' statement.
369369
370370
:type pool: concrete subclass of
371371
:class:`~google.cloud.spanner_v1.pool.AbstractSessionPool`.
372372
:param pool: (Optional) session pool to be used by database.
373373
374-
:type logger: `logging.Logger`
374+
:type logger: :class:`logging.Logger`
375375
:param logger: (Optional) a custom logger that is used if `log_commit_stats`
376376
is `True` to log commit statistics. If not passed, a logger
377377
will be created when needed that will log the commit statistics
@@ -398,7 +398,7 @@ def list_databases(self, page_size=None):
398398
399399
:rtype: :class:`~google.api._ore.page_iterator.Iterator`
400400
:returns:
401-
Iterator of :class:`~google.cloud.spanner_v1.database.Database`
401+
Iterator of :class:`~google.cloud.spanner_admin_database_v1.types.Database`
402402
resources within the current instance.
403403
"""
404404
metadata = _metadata_with_prefix(self.name)
@@ -429,6 +429,9 @@ def backup(self, backup_id, database="", expire_time=None, version_time=None):
429429
Optional. The version time that will be used to create the externally
430430
consistent copy of the database. If not present, it is the same as
431431
the `create_time` of the backup.
432+
433+
:rtype: :class:`~google.cloud.spanner_v1.backup.Backup`
434+
:returns: a backup owned by this instance.
432435
"""
433436
try:
434437
return Backup(
@@ -462,7 +465,7 @@ def list_backups(self, filter_="", page_size=None):
462465
463466
:rtype: :class:`~google.api_core.page_iterator.Iterator`
464467
:returns:
465-
Iterator of :class:`~google.cloud.spanner_v1.backup.Backup`
468+
Iterator of :class:`~google.cloud.spanner_admin_database_v1.types.Backup`
466469
resources within the current instance.
467470
"""
468471
metadata = _metadata_with_prefix(self.name)

google/cloud/spanner_v1/keyset.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
def _to_pb(self):
6969
"""Construct a KeyRange protobuf.
7070
71-
:rtype: :class:`~google.cloud.spanner_v1.KeyRange`
71+
:rtype: :class:`~google.cloud.spanner_v1.types.KeyRange`
7272
:returns: protobuf corresponding to this instance.
7373
"""
7474
kwargs = {}
@@ -88,7 +88,7 @@ def _to_pb(self):
8888
return KeyRangePB(**kwargs)
8989

9090
def _to_dict(self):
91-
"""Return keyrange's state as a dict.
91+
"""Return the state of the keyrange as a dict.
9292
9393
:rtype: dict
9494
:returns: state of this instance.
@@ -139,7 +139,7 @@ def __init__(self, keys=(), ranges=(), all_=False):
139139
def _to_pb(self):
140140
"""Construct a KeySet protobuf.
141141
142-
:rtype: :class:`~google.cloud.spanner_v1.KeySet`
142+
:rtype: :class:`~google.cloud.spanner_v1.types.KeySet`
143143
:returns: protobuf corresponding to this instance.
144144
"""
145145
if self.all_:
@@ -155,7 +155,7 @@ def _to_pb(self):
155155
return KeySetPB(**kwargs)
156156

157157
def _to_dict(self):
158-
"""Return keyset's state as a dict.
158+
"""Return the state of the keyset as a dict.
159159
160160
The result can be used to serialize the instance and reconstitute
161161
it later using :meth:`_from_dict`.

google/cloud/spanner_v1/param_types.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
def Array(element_type): # pylint: disable=invalid-name
3434
"""Construct an array parameter type description protobuf.
3535
36-
:type element_type: :class:`~google.cloud.spanner_v1.Type`
36+
:type element_type: :class:`~google.cloud.spanner_v1.types.Type`
3737
:param element_type: the type of elements of the array
3838
39-
:rtype: :class:`google.cloud.spanner_v1.Type`
39+
:rtype: :class:`google.cloud.spanner_v1.types.Type`
4040
:returns: the appropriate array-type protobuf
4141
"""
4242
return Type(code=TypeCode.ARRAY, array_element_type=element_type)
@@ -48,10 +48,10 @@ def StructField(name, field_type): # pylint: disable=invalid-name
4848
:type name: str
4949
:param name: the name of the field
5050
51-
:type field_type: :class:`google.cloud.spanner_v1.Type`
51+
:type field_type: :class:`google.cloud.spanner_v1.types.Type`
5252
:param field_type: the type of the field
5353
54-
:rtype: :class:`google.cloud.spanner_v1.StructType.Field`
54+
:rtype: :class:`google.cloud.spanner_v1.types.StructType.Field`
5555
:returns: the appropriate struct-field-type protobuf
5656
"""
5757
return StructType.Field(name=name, type_=field_type)
@@ -60,7 +60,7 @@ def StructField(name, field_type): # pylint: disable=invalid-name
6060
def Struct(fields): # pylint: disable=invalid-name
6161
"""Construct a struct parameter type description protobuf.
6262
63-
:type fields: list of :class:`google.cloud.spanner_v1.StructType.Field`
63+
:type fields: list of :class:`google.cloud.spanner_v1.types.StructType.Field`
6464
:param fields: the fields of the struct
6565
6666
:rtype: :class:`type_pb2.Type`

google/cloud/spanner_v1/pool.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, labels=None):
4242

4343
@property
4444
def labels(self):
45-
"""User-assigned labels for sesions created by the pool.
45+
"""User-assigned labels for sessions created by the pool.
4646
4747
:rtype: dict (str -> str)
4848
:returns: labels assigned by the user
@@ -53,7 +53,7 @@ def bind(self, database):
5353
"""Associate the pool with a database.
5454
5555
:type database: :class:`~google.cloud.spanner_v1.database.Database`
56-
:param database: database used by the pool: used to create sessions
56+
:param database: database used by the pool to create sessions
5757
when needed.
5858
5959
Concrete implementations of this method may pre-fill the pool
@@ -162,7 +162,7 @@ def bind(self, database):
162162
"""Associate the pool with a database.
163163
164164
:type database: :class:`~google.cloud.spanner_v1.database.Database`
165-
:param database: database used by the pool: used to create sessions
165+
:param database: database used by the pool to used to create sessions
166166
when needed.
167167
"""
168168
self._database = database
@@ -256,7 +256,7 @@ def bind(self, database):
256256
"""Associate the pool with a database.
257257
258258
:type database: :class:`~google.cloud.spanner_v1.database.Database`
259-
:param database: database used by the pool: used to create sessions
259+
:param database: database used by the pool to create sessions
260260
when needed.
261261
"""
262262
self._database = database
@@ -354,7 +354,7 @@ def bind(self, database):
354354
"""Associate the pool with a database.
355355
356356
:type database: :class:`~google.cloud.spanner_v1.database.Database`
357-
:param database: database used by the pool: used to create sessions
357+
:param database: database used by the pool to create sessions
358358
when needed.
359359
"""
360360
self._database = database
@@ -486,7 +486,7 @@ def bind(self, database):
486486
"""Associate the pool with a database.
487487
488488
:type database: :class:`~google.cloud.spanner_v1.database.Database`
489-
:param database: database used by the pool: used to create sessions
489+
:param database: database used by the pool to create sessions
490490
when needed.
491491
"""
492492
super(TransactionPingingPool, self).bind(database)

0 commit comments

Comments
 (0)