From f9142ca5419b99822e3e813f99464d42c77a67c8 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 21 Oct 2016 09:51:22 -0700 Subject: [PATCH] Remove None from param types and add (Optional). This runs a script to remove None from the types for parameters, and added (Optional) to the description. Does not pass lint due to some too-long lines. I will clean those up manually. See: https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2580#pullrequestreview-5178193 --- google/cloud/_helpers.py | 8 ++--- google/cloud/connection.py | 12 +++---- google/cloud/streaming/buffered_stream.py | 4 +-- google/cloud/streaming/http_wrapper.py | 8 ++--- google/cloud/streaming/stream_slice.py | 4 +-- google/cloud/streaming/transfer.py | 40 +++++++++++------------ 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/google/cloud/_helpers.py b/google/cloud/_helpers.py index 1e5fd3a..4499611 100644 --- a/google/cloud/_helpers.py +++ b/google/cloud/_helpers.py @@ -366,8 +366,8 @@ def _microseconds_from_datetime(value): def _millis_from_datetime(value): """Convert non-none datetime to timestamp, assuming UTC. - :type value: :class:`datetime.datetime`, or None - :param value: the timestamp + :type value: :class:`datetime.datetime` + :param value: (Optional) the timestamp :rtype: int, or ``NoneType`` :returns: the timestamp, in milliseconds, or None @@ -554,8 +554,8 @@ def _name_from_project_path(path, project, template): :type path: str :param path: URI path containing the name. - :type project: str or NoneType - :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. If passed as None, disables validation. diff --git a/google/cloud/connection.py b/google/cloud/connection.py index 02f6b8f..a5eb2a7 100644 --- a/google/cloud/connection.py +++ b/google/cloud/connection.py @@ -214,8 +214,8 @@ def _make_request(self, method, url, data=None, content_type=None, :type headers: dict :param headers: A dictionary of HTTP headers to send with the request. - :type target_object: object or :class:`NoneType` - :param target_object: Argument to be used by library callers. + :type target_object: object + :param target_object: (Optional) Argument to be used by library callers. This can allow custom behavior, for example, to defer an HTTP request and complete initialization of the object at a later time. @@ -261,8 +261,8 @@ def _do_request(self, method, url, headers, data, :type data: str :param data: The data to send as the body of the request. - :type target_object: object or :class:`NoneType` - :param target_object: Unused ``target_object`` here but may be used + :type target_object: object + :param target_object: (Optional) Unused ``target_object`` here but may be used by a superclass. :rtype: tuple of ``response`` (a dictionary of sorts) @@ -323,8 +323,8 @@ def api_request(self, method, path, query_params=None, response as JSON and raise an exception if that cannot be done. Default is True. - :type _target_object: :class:`object` or :class:`NoneType` - :param _target_object: Protected argument to be used by library + :type _target_object: :class:`object` + :param _target_object: (Optional) Protected argument to be used by library callers. This can allow custom behavior, for example, to defer an HTTP request and complete initialization of the object at a later time. diff --git a/google/cloud/streaming/buffered_stream.py b/google/cloud/streaming/buffered_stream.py index 748aa20..83061ad 100644 --- a/google/cloud/streaming/buffered_stream.py +++ b/google/cloud/streaming/buffered_stream.py @@ -81,8 +81,8 @@ def _bytes_remaining(self): def read(self, size=None): """Read bytes from the buffer. - :type size: int or None - :param size: How many bytes to read (defaults to all remaining bytes). + :type size: int + :param size: (Optional) How many bytes to read (defaults to all remaining bytes). :rtype: str :returns: The data read from the stream. diff --git a/google/cloud/streaming/http_wrapper.py b/google/cloud/streaming/http_wrapper.py index 898d1b0..d6e58a4 100644 --- a/google/cloud/streaming/http_wrapper.py +++ b/google/cloud/streaming/http_wrapper.py @@ -80,8 +80,8 @@ def _httplib2_debug_level(http_request, level, http=None): :type level: int :param level: the debuglevel for logging. - :type http: :class:`httplib2.Http`, or ``None`` - :param http: the instance on whose connections to set the debuglevel. + :type http: :class:`httplib2.Http` + :param http: (Optional) the instance on whose connections to set the debuglevel. """ if http_request.loggable_body is None: yield @@ -115,8 +115,8 @@ class Request(object): :type http_method: str :param http_method: the HTTP method to use for the request - :type headers: mapping or None - :param headers: headers to be sent with the request + :type headers: mapping + :param headers: (Optional) headers to be sent with the request :type body: str :param body: body to be sent with the request diff --git a/google/cloud/streaming/stream_slice.py b/google/cloud/streaming/stream_slice.py index bb37a44..c33cda0 100644 --- a/google/cloud/streaming/stream_slice.py +++ b/google/cloud/streaming/stream_slice.py @@ -65,8 +65,8 @@ def read(self, size=None): slice indicates we should still be able to read more bytes, we raise :exc:`IncompleteRead`. - :type size: int or None - :param size: If provided, read no more than size bytes from the stream. + :type size: int + :param size: (Optional) If provided, read no more than size bytes from the stream. :rtype: bytes :returns: bytes read from this slice. diff --git a/google/cloud/streaming/transfer.py b/google/cloud/streaming/transfer.py index b24f411..b17f633 100644 --- a/google/cloud/streaming/transfer.py +++ b/google/cloud/streaming/transfer.py @@ -280,8 +280,8 @@ def from_stream(cls, stream, auto_transfer=True, total_size=None, **kwds): :type stream: writable file-like object :param stream: the target file - :type total_size: int or None - :param total_size: total size of the file to be downloaded + :type total_size: int + :param total_size: (Optional) total size of the file to be downloaded :type auto_transfer: bool :param auto_transfer: should the transfer be started immediately @@ -457,8 +457,8 @@ def _compute_end_byte(self, start, end=None, use_chunks=True): :type start: int :param start: start byte of the range. - :type end: int or None - :param end: suggested last byte of the range. + :type end: int + :param end: (Optional) suggested last byte of the range. :type use_chunks: bool :param use_chunks: If False, ignore :attr:`chunksize`. @@ -493,8 +493,8 @@ def _get_chunk(self, start, end): :type start: int :param start: start byte of the range. - :type end: int or None - :param end: end byte of the range. + :type end: int + :param end: (Optional) end byte of the range. :rtype: :class:`google.cloud.streaming.http_wrapper.Response` :returns: response from the chunk request. @@ -555,8 +555,8 @@ def get_range(self, start, end=None, use_chunks=True): :type start: int :param start: Where to start fetching bytes. (See above.) - :type end: int or ``None`` - :param end: Where to stop fetching bytes. (See above.) + :type end: int + :param end: (Optional) Where to stop fetching bytes. (See above.) :type use_chunks: bool :param use_chunks: If False, ignore :attr:`chunksize` @@ -625,8 +625,8 @@ class Upload(_Transfer): :type mime_type: str: :param mime_type: MIME type of the upload. - :type total_size: int or None - :param total_size: Total upload size for the stream. + :type total_size: int + :param total_size: (Optional) Total upload size for the stream. :type http: :class:`httplib2.Http` (or workalike) :param http: Http instance used to perform requests. @@ -669,8 +669,8 @@ def from_file(cls, filename, mime_type=None, auto_transfer=True, **kwds): :type mime_type: str :param mime_type: MIMEtype of the file being uploaded - :type auto_transfer: bool or None - :param auto_transfer: should the transfer be started immediately + :type auto_transfer: bool + :param auto_transfer: (Optional) should the transfer be started immediately :type kwds: dict :param kwds: keyword arguments: passed @@ -700,11 +700,11 @@ def from_stream(cls, stream, mime_type, :type mime_type: str :param mime_type: MIMEtype of the file being uploaded - :type total_size: int or None - :param total_size: Size of the file being uploaded + :type total_size: int + :param total_size: (Optional) Size of the file being uploaded - :type auto_transfer: bool or None - :param auto_transfer: should the transfer be started immediately + :type auto_transfer: bool + :param auto_transfer: (Optional) should the transfer be started immediately :type kwds: dict :param kwds: keyword arguments: passed @@ -784,8 +784,8 @@ def total_size(self): def total_size(self, value): """Update total size of the stream to be uploaded. - :type value: int or None - :param value: the size + :type value: int + :param value: (Optional) the size """ self._ensure_uninitialized() self._total_size = value @@ -1048,8 +1048,8 @@ def _validate_chunksize(self, chunksize=None): Helper for :meth:`stream_file`. - :type chunksize: int or None - :param chunksize: the chunk size to be tested. + :type chunksize: int + :param chunksize: (Optional) the chunk size to be tested. :raises: :exc:`ValueError` if ``chunksize`` is not a multiple of the server-specified granulariy.