Skip to content

Commit 773cb29

Browse files
[Storage] [Blob] Fixed next pylint errors (#34945)
1 parent 0527e86 commit 773cb29

17 files changed

+56
-48
lines changed

sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def upload_blob_to_url(
9292
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
9393
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
9494
should be the storage account key.
95-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
95+
:type credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
9696
:keyword bool overwrite:
9797
Whether the blob to be uploaded should overwrite the current data.
9898
If True, upload_blob_to_url will overwrite any existing data. If set to False, the
@@ -156,7 +156,7 @@ def download_blob_from_url(
156156
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
157157
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
158158
should be the storage account key.
159-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
159+
:type credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
160160
:keyword bool overwrite:
161161
Whether the local file should be overwritten if it already exists. The default value is
162162
`False` - in which case a ValueError will be raised if the file already exists. If set to

sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ def upload_blob_from_url(self, source_url, **kwargs):
602602
:keyword str source_authorization:
603603
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
604604
the prefix of the source_authorization string.
605+
:returns: Response from creating a new block blob for a given URL.
606+
:rtype: Dict[str, Any]
605607
"""
606608
options = self._upload_blob_from_url_options(
607609
source_url=self._encode_source_url(source_url),
@@ -622,6 +624,7 @@ def upload_blob(
622624
"""Creates a new blob from a data source with automatic chunking.
623625
624626
:param data: The blob data to upload.
627+
:type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
625628
:param ~azure.storage.blob.BlobType blob_type: The type of the blob. This can be
626629
either BlockBlob, PageBlob or AppendBlob. The default value is BlockBlob.
627630
:param int length:
@@ -1532,6 +1535,7 @@ def set_blob_metadata(self, metadata=None, **kwargs):
15321535
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
15331536
#other-client--per-operation-configuration>`_.
15341537
:returns: Blob-updated property dict (Etag and last modified)
1538+
:rtype: Dict[str, Union[str, datetime]]
15351539
"""
15361540
options = self._set_blob_metadata_options(metadata=metadata, **kwargs)
15371541
try:
@@ -2515,6 +2519,7 @@ def stage_block(
25152519
The string should be less than or equal to 64 bytes in size.
25162520
For a given blob, the block_id must be the same size for each block.
25172521
:param data: The blob data.
2522+
:type data: Union[Iterable[AnyStr], IO[AnyStr]]
25182523
:param int length: Size of the block.
25192524
:keyword bool validate_content:
25202525
If true, calculates an MD5 hash for each chunk of the blob. The storage
@@ -3284,7 +3289,7 @@ def get_page_range_diff_for_managed_disk(
32843289
.. versionadded:: 12.2.0
32853290
This operation was introduced in API version '2019-07-07'.
32863291
3287-
:param previous_snapshot_url:
3292+
:param str previous_snapshot_url:
32883293
Specifies the URL of a previous snapshot of the managed disk.
32893294
The response will only contain pages that were changed between the target blob and
32903295
its previous snapshot.
@@ -3812,6 +3817,8 @@ def upload_pages_from_url(self, source_url, # type: str
38123817
:keyword str source_authorization:
38133818
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
38143819
the prefix of the source_authorization string.
3820+
:returns: Response after uploading pages from specified URL.
3821+
:rtype: Dict[str, Any]
38153822
"""
38163823
options = self._upload_pages_from_url_options(
38173824
source_url=self._encode_source_url(source_url),
@@ -4240,6 +4247,8 @@ def append_block_from_url(self, copy_source_url, # type: str
42404247
:keyword str source_authorization:
42414248
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
42424249
the prefix of the source_authorization string.
4250+
:returns: Result after appending a new block.
4251+
:rtype: Dict[str, Union[str, datetime, int]]
42434252
"""
42444253
options = self._append_block_from_url_options(
42454254
copy_source_url=self._encode_source_url(copy_source_url),

sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def from_connection_string(
171171
Credentials provided here will take precedence over those in the connection string.
172172
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
173173
should be the storage account key.
174-
:paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] # pylint: disable=line-too-long
174+
:type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] # pylint: disable=line-too-long
175175
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
176176
authentication. Only has an effect when credential is of type TokenCredential. The value could be
177177
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -551,6 +551,7 @@ def create_container(
551551
This value is not tracked or validated on the client. To configure client-side network timesouts
552552
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
553553
#other-client--per-operation-configuration>`_.
554+
:returns: A container client to interact with the newly created container.
554555
:rtype: ~azure.storage.blob.ContainerClient
555556
556557
.. admonition:: Example:
@@ -588,7 +589,7 @@ def delete_container(
588589
If specified, delete_container only succeeds if the
589590
container's lease is active and matches this ID.
590591
Required if the container has an active lease.
591-
:paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
592+
:type lease: ~azure.storage.blob.BlobLeaseClient or str
592593
:keyword ~datetime.datetime if_modified_since:
593594
A DateTime value. Azure expects the date value passed in to be UTC.
594595
If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -612,7 +613,6 @@ def delete_container(
612613
This value is not tracked or validated on the client. To configure client-side network timesouts
613614
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
614615
#other-client--per-operation-configuration>`_.
615-
:rtype: None
616616
617617
.. admonition:: Example:
618618
@@ -652,6 +652,7 @@ def _rename_container(self, name, new_name, **kwargs):
652652
This value is not tracked or validated on the client. To configure client-side network timesouts
653653
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
654654
#other-client--per-operation-configuration>`_.
655+
:returns: A container client for the renamed container.
655656
:rtype: ~azure.storage.blob.ContainerClient
656657
"""
657658
renamed_container = self.get_container_client(new_name)

sdk/storage/azure-storage-blob/azure/storage/blob/_container_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _get_blob_name(blob):
6565
"""Return the blob name.
6666
6767
:param blob: A blob string or BlobProperties
68-
:paramtype blob: str or BlobProperties
68+
:type blob: str or BlobProperties
6969
:returns: The name of the blob.
7070
:rtype: str
7171
"""
@@ -202,7 +202,7 @@ def from_container_url(
202202
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
203203
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
204204
should be the storage account key.
205-
:paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
205+
:type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
206206
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
207207
authentication. Only has an effect when credential is of type TokenCredential. The value could be
208208
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -251,7 +251,7 @@ def from_connection_string(
251251
Credentials provided here will take precedence over those in the connection string.
252252
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
253253
should be the storage account key.
254-
:paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
254+
:type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
255255
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
256256
authentication. Only has an effect when credential is of type TokenCredential. The value could be
257257
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -338,13 +338,14 @@ def _rename_container(self, new_name, **kwargs):
338338
:keyword lease:
339339
Specify this to perform only if the lease ID given
340340
matches the active lease ID of the source container.
341-
:paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
341+
:type lease: ~azure.storage.blob.BlobLeaseClient or str
342342
:keyword int timeout:
343343
Sets the server-side timeout for the operation in seconds. For more details see
344344
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
345345
This value is not tracked or validated on the client. To configure client-side network timesouts
346346
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
347347
#other-client--per-operation-configuration>`_.
348+
:returns: The renamed container client.
348349
:rtype: ~azure.storage.blob.ContainerClient
349350
"""
350351
lease = kwargs.pop('lease', None)
@@ -994,6 +995,7 @@ def upload_blob(
994995
995996
:param str name: The blob with which to interact.
996997
:param data: The blob data to upload.
998+
:type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
997999
:param ~azure.storage.blob.BlobType blob_type: The type of the blob. This can be
9981000
either BlockBlob, PageBlob or AppendBlob. The default value is BlockBlob.
9991001
:param int length:

sdk/storage/azure-storage-blob/azure/storage/blob/_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __init__(self, size, content, downloader, chunk_size):
236236
self._current_content = content
237237
self._iter_downloader = downloader
238238
self._iter_chunks = None
239-
self._complete = (size == 0)
239+
self._complete = size == 0
240240

241241
def __len__(self):
242242
return self.size

sdk/storage/azure-storage-blob/azure/storage/blob/_encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def decrypt_blob( # pylint: disable=too-many-locals,too-many-statements
857857
:param key_resolver:
858858
The user-provided key resolver. Uses the kid string to return a key-encryption-key
859859
implementing the interface defined above.
860-
:paramtype key_resolver: Optional[Callable[[str], KeyEncryptionKey]]
860+
:type key_resolver: Optional[Callable[[str], KeyEncryptionKey]]
861861
:param bytes content:
862862
The encrypted blob content.
863863
:param int start_offset:

sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,3 @@ def read_record(self, writer_schema, decoder):
433433
def skip_record(self, writer_schema, decoder):
434434
for field in writer_schema.fields:
435435
self.skip_data(field.type, decoder)
436-
437-
438-
# ------------------------------------------------------------------------------
439-
440-
if __name__ == '__main__':
441-
raise Exception('Not a standalone module')

sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io_async.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,3 @@ async def read_record(self, writer_schema, decoder):
417417
async def skip_record(self, writer_schema, decoder):
418418
for field in writer_schema.fields:
419419
await self.skip_data(field.type, decoder)
420-
421-
422-
# ------------------------------------------------------------------------------
423-
424-
if __name__ == '__main__':
425-
raise Exception('Not a standalone module')

sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/datafile.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,3 @@ def __next__(self):
255255
def close(self):
256256
"""Close this reader."""
257257
self.reader.close()
258-
259-
260-
if __name__ == '__main__':
261-
raise Exception('Not a standalone module')

sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/datafile_async.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,3 @@ async def __anext__(self):
208208
def close(self):
209209
"""Close this reader."""
210210
self.reader.close()
211-
212-
213-
if __name__ == '__main__':
214-
raise Exception('Not a standalone module')

0 commit comments

Comments
 (0)