Skip to content

Commit

Permalink
Merge pull request #2584 from tswast/nonetype-to-optional
Browse files Browse the repository at this point in the history
Remove None & NoneType from parameter types in docstrings.
  • Loading branch information
dhermes authored Oct 21, 2016
2 parents e458665 + 1b12b2d commit 448bb70
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def _build_dataframe(time_series_iterable,
:param time_series_iterable:
An iterable (e.g., a query object) yielding time series.
:type label: str or None
:type label: str
:param label:
The label name to use for the dataframe header. This can be the name
of a resource label or metric label (e.g., ``"instance_name"``), or
the string ``"resource_type"``.
(Optional) The label name to use for the dataframe header. This can be
the name of a resource label or metric label (e.g.,
``"instance_name"``), or the string ``"resource_type"``.
:type labels: list of strings, or None
:param labels:
Expand Down
46 changes: 24 additions & 22 deletions packages/google-cloud-monitoring/google/cloud/monitoring/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def query(self,
demonstration purposes and is subject to change. See the
`supported metrics`_.
:type end_time: :class:`datetime.datetime` or None
:param end_time: The end time (inclusive) of the time interval
:type end_time: :class:`datetime.datetime`
:param end_time:
(Optional) The end time (inclusive) of the time interval
for which results should be returned, as a datetime object.
The default is the start of the current minute.
Expand Down Expand Up @@ -362,15 +363,16 @@ def list_metric_descriptors(self, filter_string=None, type_prefix=None):
... type_prefix='custom.'):
... print(descriptor.type)
:type filter_string: str or None
:type filter_string: str
:param filter_string:
An optional filter expression describing the metric descriptors
to be returned. See the `filter documentation`_.
(Optional) An optional filter expression describing the metric
descriptors to be returned. See the `filter documentation`_.
:type type_prefix: str or None
:param type_prefix: An optional prefix constraining the selected
metric types. This adds ``metric.type = starts_with("<prefix>")``
to the filter.
:type type_prefix: str
:param type_prefix:
(Optional) An optional prefix constraining the selected metric
types. This adds ``metric.type = starts_with("<prefix>")`` to the
filter.
:rtype:
list of :class:`~google.cloud.monitoring.metric.MetricDescriptor`
Expand Down Expand Up @@ -408,10 +410,10 @@ def list_resource_descriptors(self, filter_string=None):
>>> for descriptor in client.list_resource_descriptors():
... print(descriptor.type)
:type filter_string: str or None
:type filter_string: str
:param filter_string:
An optional filter expression describing the resource descriptors
to be returned. See the `filter documentation`_.
(Optional) An optional filter expression describing the resource
descriptors to be returned. See the `filter documentation`_.
:rtype: list of
:class:`~google.cloud.monitoring.resource.ResourceDescriptor`
Expand All @@ -430,22 +432,22 @@ def group(self, group_id=None, display_name=None, parent_id=None,
This will not make an HTTP request; it simply instantiates
a group object owned by this client.
:type group_id: str or None
:param group_id: The ID of the group.
:type group_id: str
:param group_id: (Optional) The ID of the group.
:type display_name: str or None
:type display_name: str
:param display_name:
A user-assigned name for this group, used only for display
purposes.
(Optional) A user-assigned name for this group, used only for
display purposes.
:type parent_id: str or None
:type parent_id: str
:param parent_id:
The ID of the group's parent, if it has one.
(Optional) The ID of the group's parent, if it has one.
:type filter_string: str or None
:type filter_string: str
:param filter_string:
The filter string used to determine which monitored resources
belong to this group.
(Optional) The filter string used to determine which monitored
resources belong to this group.
:type is_cluster: bool
:param is_cluster:
Expand Down
67 changes: 35 additions & 32 deletions packages/google-cloud-monitoring/google/cloud/monitoring/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def _group_id_from_name(path, project=None):
:type path: str
:param path: URI path for a group API request.
:type project: str or None
:param project: The project associated with the request. It is
:type project: str
:param project: (Optional) The project associated with the request. It is
included for validation purposes.
:rtype: str
Expand Down Expand Up @@ -76,21 +76,22 @@ class Group(object):
:type client: :class:`google.cloud.monitoring.client.Client`
:param client: A client for operating on the metric descriptor.
:type group_id: str or None
:param group_id: The ID of the group.
:type group_id: str
:param group_id: (Optional) The ID of the group.
:type display_name: str or None
:type display_name: str
:param display_name:
A user-assigned name for this group, used only for display purposes.
(Optional) A user-assigned name for this group, used only for display
purposes.
:type parent_id: str or None
:type parent_id: str
:param parent_id:
The ID of the group's parent, if it has one.
(Optional) The ID of the group's parent, if it has one.
:type filter_string: str or None
:type filter_string: str
:param filter_string:
The filter string used to determine which monitored resources belong to
this group.
(Optional) The filter string used to determine which monitored
resources belong to this group.
:type is_cluster: bool
:param is_cluster:
Expand Down Expand Up @@ -296,22 +297,23 @@ def list_members(self, filter_string=None, end_time=None, start_time=None):
... print(member)
:type filter_string: str or None
:type filter_string: str
:param filter_string:
An optional list filter describing the members to be returned. The
filter may reference the type, labels, and metadata of monitored
resources that comprise the group. See the `filter documentation`_.
(Optional) An optional list filter describing the members to be
returned. The filter may reference the type, labels, and metadata
of monitored resources that comprise the group. See the `filter
documentation`_.
:type end_time: :class:`datetime.datetime` or None
:type end_time: :class:`datetime.datetime`
:param end_time:
The end time (inclusive) of the time interval for which results
should be returned, as a datetime object. If ``start_time`` is
specified, then this must also be specified.
(Optional) The end time (inclusive) of the time interval for which
results should be returned, as a datetime object. If ``start_time``
is specified, then this must also be specified.
:type start_time: :class:`datetime.datetime` or None
:type start_time: :class:`datetime.datetime`
:param start_time:
The start time (exclusive) of the time interval for which results
should be returned, as a datetime object.
(Optional) The start time (exclusive) of the time interval for
which results should be returned, as a datetime object.
:rtype: list of :class:`~google.cloud.monitoring.resource.Resource`
:returns: A list of resource instances.
Expand Down Expand Up @@ -386,21 +388,22 @@ def _list(cls, client, children_of_group=None, ancestors_of_group=None,
:type client: :class:`google.cloud.monitoring.client.Client`
:param client: The client to use.
:type children_of_group: str or None
:type children_of_group: str
:param children_of_group:
Returns groups whose parent_name field contains the group name. If
no groups have this parent, the results are empty.
(Optional) Returns groups whose parent_name field contains the
group name. If no groups have this parent, the results are empty.
:type ancestors_of_group: str or None
:type ancestors_of_group: str
:param ancestors_of_group:
Returns groups that are ancestors of the specified group. If the
specified group has no immediate parent, the results are empty.
(Optional) Returns groups that are ancestors of the specified
group. If the specified group has no immediate parent, the results
are empty.
:type descendants_of_group: str or None
:type descendants_of_group: str
:param descendants_of_group:
Returns the descendants of the specified group. This is a superset
of the results returned by the children_of_group filter, and
includes children-of-children, and so forth.
(Optional) Returns the descendants of the specified group. This is
a superset of the results returned by the children_of_group filter,
and includes children-of-children, and so forth.
:rtype: list of :class:`~google.cloud.monitoring.group.Group`
:returns: A list of group instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class MetricDescriptor(object):
:type display_name: str
:param display_name: An optional concise name for the metric.
:type name: str or None
:type name: str
:param name:
The "resource name" of the metric descriptor. For example:
(Optional) The "resource name" of the metric descriptor. For example:
``"projects/<project_id>/metricDescriptors/<type>"``. As
retrieved from the service, this will always be specified.
You can and should omit it when constructing an instance for
Expand Down Expand Up @@ -198,15 +198,15 @@ def _list(cls, client, filter_string=None, type_prefix=None):
:type client: :class:`google.cloud.monitoring.client.Client`
:param client: The client to use.
:type filter_string: str or None
:type filter_string: str
:param filter_string:
An optional filter expression describing the metric descriptors
to be returned. See the `filter documentation`_.
(Optional) Filter expression describing the metric descriptors to
be returned. See the `filter documentation`_.
:type type_prefix: str or None
:param type_prefix: An optional prefix constraining the selected
metric types. This adds ``metric.type = starts_with("<prefix>")``
to the filter.
:type type_prefix: str
:param type_prefix:
(Optional) Prefix constraining the selected metric types. This adds
``metric.type = starts_with("<prefix>")`` to the filter.
:rtype: list of :class:`MetricDescriptor`
:returns: A list of metric descriptor instances.
Expand Down
31 changes: 17 additions & 14 deletions packages/google-cloud-monitoring/google/cloud/monitoring/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class Query(object):
demonstration purposes and is subject to change. See the
`supported metrics`_.
:type end_time: :class:`datetime.datetime` or None
:param end_time: The end time (inclusive) of the time interval
:type end_time: :class:`datetime.datetime`
:param end_time: (Optional) The end time (inclusive) of the time interval
for which results should be returned, as a datetime object.
The default is the start of the current minute.
Expand Down Expand Up @@ -179,8 +179,9 @@ def select_interval(self, end_time, start_time=None):
:param end_time: The end time (inclusive) of the time interval
for which results should be returned, as a datetime object.
:type start_time: :class:`datetime.datetime` or None
:param start_time: The start time (exclusive) of the time interval
:type start_time: :class:`datetime.datetime`
:param start_time:
(Optional) The start time (exclusive) of the time interval
for which results should be returned, as a datetime object.
If not specified, the interval is a point in time.
Expand Down Expand Up @@ -446,11 +447,11 @@ def iter(self, headers_only=False, page_size=None):
:param headers_only:
Whether to omit the point data from the time series objects.
:type page_size: int or None
:type page_size: int
:param page_size:
An optional positive number specifying the maximum number of
points to return per page. This can be used to control how far
the iterator reads ahead.
(Optional) Positive number specifying the maximum number of points
to return per page. This can be used to control how far the
iterator reads ahead.
:raises: :exc:`ValueError` if the query time interval has not been
specified.
Expand Down Expand Up @@ -510,11 +511,12 @@ def _build_query_params(self, headers_only=False,
Whether to omit the point data from the
:class:`~google.cloud.monitoring.timeseries.TimeSeries` objects.
:type page_size: int or None
:param page_size: A limit on the number of points to return per page.
:type page_size: int
:param page_size:
(Optional) A limit on the number of points to return per page.
:type page_token: str or None
:param page_token: A token to continue the retrieval.
:type page_token: str
:param page_token: (Optional) A token to continue the retrieval.
"""
yield 'filter', self.filter

Expand Down Expand Up @@ -575,8 +577,9 @@ def as_dataframe(self, label=None, labels=None):
dataframe = query.as_dataframe(
labels=['resource_type', 'instance_id'])
:type label: str or None
:param label: The label name to use for the dataframe header.
:type label: str
:param label:
(Optional) The label name to use for the dataframe header.
This can be the name of a resource label or metric label
(e.g., ``"instance_name"``), or the string ``"resource_type"``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ def _list(cls, client, filter_string=None):
:type client: :class:`google.cloud.monitoring.client.Client`
:param client: The client to use.
:type filter_string: str or None
:type filter_string: str
:param filter_string:
An optional filter expression describing the resource descriptors
to be returned. See the `filter documentation`_.
(Optional) An optional filter expression describing the resource
descriptors to be returned. See the `filter documentation`_.
:rtype: list of :class:`ResourceDescriptor`
:returns: A list of resource descriptor instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class Point(collections.namedtuple('Point', 'end_time start_time value')):
:type end_time: str
:param end_time: The end time in RFC3339 UTC "Zulu" format.
:type start_time: str or None
:param start_time: An optional start time in RFC3339 UTC "Zulu" format.
:type start_time: str
:param start_time: (Optional) The start time in RFC3339 UTC "Zulu" format.
:type value: object
:param value: The metric value. This can be a scalar or a distribution.
Expand Down

0 comments on commit 448bb70

Please sign in to comment.