Skip to content

Commit 17afa71

Browse files
committed
Set explicit pattern for 'no-docstring-rgx'.
Leaving it unset disabled the 'missing-docstring' check. Add missing docstrings uncovered thereby. Closes googleapis#1800.
1 parent 830e419 commit 17afa71

6 files changed

Lines changed: 24 additions & 1 deletion

File tree

gcloud/bigquery/_helpers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,37 @@
1818

1919

2020
def _not_null(value, field):
21+
"""Check whether 'value' should be coerced to 'field' type."""
2122
return value is not None or field.mode != 'NULLABLE'
2223

2324

2425
def _int_from_json(value, field):
26+
"""Coerce 'value' to an int, if set or not nullable."""
2527
if _not_null(value, field):
2628
return int(value)
2729

2830

2931
def _float_from_json(value, field):
32+
"""Coerce 'value' to a float, if set or not nullable."""
3033
if _not_null(value, field):
3134
return float(value)
3235

3336

3437
def _bool_from_json(value, field):
38+
"""Coerce 'value' to a bool, if set or not nullable."""
3539
if _not_null(value, field):
3640
return value.lower() in ['t', 'true', '1']
3741

3842

3943
def _datetime_from_json(value, field):
44+
"""Coerce 'value' to a datetime, if set or not nullable."""
4045
if _not_null(value, field):
4146
# value will be a float in seconds, to microsecond precision, in UTC.
4247
return _datetime_from_microseconds(1e6 * float(value))
4348

4449

4550
def _record_from_json(value, field):
51+
"""Coerce 'value' to a mapping, if set or not nullable."""
4652
if _not_null(value, field):
4753
record = {}
4854
for subfield, cell in zip(field.fields, value['f']):
@@ -56,6 +62,7 @@ def _record_from_json(value, field):
5662

5763

5864
def _string_from_json(value, _):
65+
"""NOOP string -> string coercion"""
5966
return value
6067

6168

@@ -70,6 +77,7 @@ def _string_from_json(value, _):
7077

7178

7279
def _rows_from_json(rows, schema):
80+
"""Convert JSON row data to rows w/ appropriate types."""
7381
rows_data = []
7482
for row in rows:
7583
row_data = []
@@ -132,6 +140,10 @@ def __init__(self, name, property_type):
132140
self.property_type = property_type
133141

134142
def _validate(self, value):
143+
"""Ensure that 'value' is of the appropriate type.
144+
145+
:raises: ValueError on a type mismatch.
146+
"""
135147
if not isinstance(value, self.property_type):
136148
raise ValueError('Required type: %s' % (self.property_type,))
137149

gcloud/bigquery/job.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,11 @@ def __init__(self, name, query, client):
933933
"""
934934

935935
def _destination_table_resource(self):
936+
"""Create a JSON resource for the destination table.
937+
938+
Helper for :meth:`_populate_config_resource` and
939+
:meth:`_scrub_local_properties`
940+
"""
936941
if self.destination is not None:
937942
return {
938943
'projectId': self.destination.project,

gcloud/bigtable/cluster.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ def table(self, table_id):
241241
return Table(table_id, self)
242242

243243
def _update_from_pb(self, cluster_pb):
244+
"""Refresh self from the server-provided protobuf.
245+
246+
Helper for :meth:`from_pb` and :meth:`reload`.
247+
"""
244248
if not cluster_pb.display_name: # Simple field (string)
245249
raise ValueError('Cluster protobuf does not contain display_name')
246250
if not cluster_pb.serve_nodes: # Simple field (int32)

gcloud/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def __init__(self, project=None):
150150

151151
@staticmethod
152152
def _determine_default(project):
153+
"""Helper: use default project detection."""
153154
return _determine_default_project(project)
154155

155156

gcloud/datastore/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def __init__(self, project=None, namespace=None,
174174

175175
@staticmethod
176176
def _determine_default(project):
177+
"""Helper: override default project detection."""
177178
return _determine_default_project(project)
178179

179180
def _push_batch(self, batch):

scripts/pylintrc_default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ method-rgx=[a-z_][a-z0-9_]{2,35}$
299299

300300
# Regular expression which should only match function or class names that do
301301
# not require a docstring.
302-
# DEFAULT: no-docstring-rgx=__.*__
302+
no-docstring-rgx=__.*__
303303

304304
# Minimum line length for functions/classes that require docstrings, shorter
305305
# ones are exempt.

0 commit comments

Comments
 (0)