Skip to content

Commit c3c7b85

Browse files
[Storage] [File Share] Fixed next pylint errors in file share (Azure#34955)
1 parent b1c6841 commit c3c7b85

File tree

13 files changed

+106
-88
lines changed

13 files changed

+106
-88
lines changed

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6+
# pylint: disable=too-many-lines
67

78
import functools
89
import sys
@@ -169,7 +170,8 @@ def from_directory_url(
169170
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
170171
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
171172
should be the storage account key.
172-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
173+
:type credential:
174+
Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]]
173175
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
174176
authentication. Only has an effect when credential is of type TokenCredential. The value could be
175177
https://storage.azure.com/ (default) or https://<account>.file.core.windows.net.
@@ -231,7 +233,8 @@ def from_connection_string(
231233
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
232234
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
233235
should be the storage account key.
234-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
236+
:type credential:
237+
Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]]
235238
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
236239
authentication. Only has an effect when credential is of type TokenCredential. The value could be
237240
https://storage.azure.com/ (default) or https://<account>.file.core.windows.net.
@@ -337,7 +340,7 @@ def create_directory(self, **kwargs):
337340
This parameter was introduced in API version '2021-06-08'.
338341
339342
:paramtype file_change_time: str or ~datetime.datetime
340-
:keyword dict(str,str) metadata:
343+
:keyword dict[str, str] metadata:
341344
Name-value pairs associated with the directory as metadata.
342345
:keyword int timeout:
343346
Sets the server-side timeout for the operation in seconds. For more details see
@@ -346,7 +349,7 @@ def create_directory(self, **kwargs):
346349
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
347350
#other-client--per-operation-configuration>`_.
348351
:returns: Directory-updated property dict (Etag and last modified).
349-
:rtype: dict(str, Any)
352+
:rtype: dict[str, Any]
350353
351354
.. admonition:: Example:
352355
@@ -725,15 +728,15 @@ def set_directory_metadata(self, metadata, **kwargs):
725728
726729
:param metadata:
727730
Name-value pairs associated with the directory as metadata.
728-
:type metadata: dict(str, str)
731+
:type metadata: dict[str, str]
729732
:keyword int timeout:
730733
Sets the server-side timeout for the operation in seconds. For more details see
731734
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations.
732735
This value is not tracked or validated on the client. To configure client-side network timesouts
733736
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
734737
#other-client--per-operation-configuration>`_.
735738
:returns: Directory-updated property dict (Etag and last modified).
736-
:rtype: dict(str, Any)
739+
:rtype: dict[str, Any]
737740
"""
738741
timeout = kwargs.pop('timeout', None)
739742
headers = kwargs.pop('headers', {})
@@ -786,13 +789,13 @@ def set_http_headers(self, file_attributes="none", # type: Union[str, NTFSAttri
786789
The file system attributes for files and directories.
787790
If not set, indicates preservation of existing values.
788791
Here is an example for when the var type is str: 'Temporary|Archive'
789-
:type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes`
792+
:type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes
790793
:param file_creation_time: Creation time for the file
791794
Default value: Preserve.
792-
:type file_creation_time: str or datetime
795+
:type file_creation_time: str or ~datetime.datetime
793796
:param file_last_write_time: Last write time for the file
794797
Default value: Preserve.
795-
:type file_last_write_time: str or datetime
798+
:type file_last_write_time: str or ~datetime.datetime
796799
:param file_permission: If specified the permission (security
797800
descriptor) shall be set for the directory/file. This header can be
798801
used if Permission size is <= 8KB, else x-ms-file-permission-key
@@ -818,7 +821,7 @@ def set_http_headers(self, file_attributes="none", # type: Union[str, NTFSAttri
818821
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
819822
#other-client--per-operation-configuration>`_.
820823
:returns: File-updated property dict (Etag and last modified).
821-
:rtype: dict(str, Any)
824+
:rtype: dict[str, Any]
822825
"""
823826
timeout = kwargs.pop('timeout', None)
824827
file_permission = _get_file_permission(file_permission, permission_key, 'preserve')
@@ -847,7 +850,7 @@ def create_subdirectory(
847850
848851
:param str directory_name:
849852
The name of the subdirectory.
850-
:keyword dict(str,str) metadata:
853+
:keyword dict[str, str] metadata:
851854
Name-value pairs associated with the subdirectory as metadata.
852855
:keyword int timeout:
853856
Sets the server-side timeout for the operation in seconds. For more details see
@@ -918,9 +921,10 @@ def upload_file(
918921
The name of the file.
919922
:param data:
920923
Content of the file.
924+
:type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
921925
:param int length:
922926
Length of the file in bytes. Specify its maximum size, up to 1 TiB.
923-
:keyword dict(str,str) metadata:
927+
:keyword dict[str, str] metadata:
924928
Name-value pairs associated with the file as metadata.
925929
:keyword ~azure.storage.fileshare.ContentSettings content_settings:
926930
ContentSettings object used to set file properties. Used to set content type, encoding,

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, size, content, downloader, chunk_size):
143143
self._current_content = content
144144
self._iter_downloader = downloader
145145
self._iter_chunks = None
146-
self._complete = (size == 0)
146+
self._complete = size == 0
147147

148148
def __len__(self):
149149
return self.size

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_file_client.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def from_file_url(
230230
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
231231
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
232232
should be the storage account key.
233-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
233+
:type credential:
234+
Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]]
234235
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
235236
authentication. Only has an effect when credential is of type TokenCredential. The value could be
236237
https://storage.azure.com/ (default) or https://<account>.file.core.windows.net.
@@ -291,7 +292,8 @@ def from_connection_string(
291292
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
292293
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
293294
should be the storage account key.
294-
:paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
295+
:type credential:
296+
Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]]
295297
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
296298
authentication. Only has an effect when credential is of type TokenCredential. The value could be
297299
https://storage.azure.com/ (default) or https://<account>.file.core.windows.net.
@@ -393,7 +395,7 @@ def create_file( # type: ignore
393395
If not set, the default value would be "None" and the attributes will be set to "Archive".
394396
Here is an example for when the var type is str: 'Temporary|Archive'.
395397
file_attributes value is not case sensitive.
396-
:type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes`
398+
:type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes
397399
:param file_creation_time: Creation time for the file
398400
Default value: Now.
399401
:type file_creation_time: str or ~datetime.datetime
@@ -421,7 +423,7 @@ def create_file( # type: ignore
421423
:keyword ~azure.storage.fileshare.ContentSettings content_settings:
422424
ContentSettings object used to set file properties. Used to set content type, encoding,
423425
language, disposition, md5, and cache control.
424-
:keyword dict(str,str) metadata:
426+
:keyword dict[str, str] metadata:
425427
Name-value pairs associated with the file as metadata.
426428
:keyword lease:
427429
Required if the file has an active lease. Value can be a ShareLeaseClient object
@@ -437,7 +439,7 @@ def create_file( # type: ignore
437439
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
438440
#other-client--per-operation-configuration>`_.
439441
:returns: File-updated property dict (Etag and last modified).
440-
:rtype: dict(str, Any)
442+
:rtype: dict[str, Any]
441443
442444
.. admonition:: Example:
443445
@@ -500,6 +502,7 @@ def upload_file(
500502
501503
:param data:
502504
Content of the file.
505+
:type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
503506
:param int length:
504507
Length of the file in bytes. Specify its maximum size, up to 1 TiB.
505508
:param file_attributes:
@@ -532,7 +535,7 @@ def upload_file(
532535
This parameter was introduced in API version '2021-06-08'.
533536
534537
:paramtype file_change_time: str or ~datetime.datetime
535-
:keyword dict(str,str) metadata:
538+
:keyword dict[str, str] metadata:
536539
Name-value pairs associated with the file as metadata.
537540
:keyword ~azure.storage.fileshare.ContentSettings content_settings:
538541
ContentSettings object used to set file properties. Used to set content type, encoding,
@@ -567,7 +570,7 @@ def upload_file(
567570
:keyword str encoding:
568571
Defaults to UTF-8.
569572
:returns: File-updated property dict (Etag and last modified).
570-
:rtype: dict(str, Any)
573+
:rtype: dict[str, Any]
571574
572575
.. admonition:: Example:
573576
@@ -621,7 +624,7 @@ def upload_file(
621624

622625
@distributed_trace
623626
def start_copy_from_url(self, source_url, **kwargs):
624-
# type: (str, Any) -> Any
627+
# type: (str, Any) -> Dict[str, Any]
625628
"""Initiates the copying of data from a source URL into the file
626629
referenced by the client.
627630
@@ -703,7 +706,7 @@ def start_copy_from_url(self, source_url, **kwargs):
703706
704707
:keyword metadata:
705708
Name-value pairs associated with the file as metadata.
706-
:type metadata: dict(str, str)
709+
:type metadata: dict[str, str]
707710
:keyword lease:
708711
Required if the file has an active lease. Value can be a ShareLeaseClient object
709712
or the lease ID as a string.
@@ -717,7 +720,8 @@ def start_copy_from_url(self, source_url, **kwargs):
717720
This value is not tracked or validated on the client. To configure client-side network timesouts
718721
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
719722
#other-client--per-operation-configuration>`_.
720-
:rtype: dict(str, Any)
723+
:returns: Response after data copying operation has been initiated.
724+
:rtype: dict[str, Any]
721725
722726
.. admonition:: Example:
723727
@@ -1086,7 +1090,7 @@ def set_http_headers(self, content_settings, # type: ContentSettings
10861090
The file system attributes for files and directories.
10871091
If not set, indicates preservation of existing values.
10881092
Here is an example for when the var type is str: 'Temporary|Archive'
1089-
:type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes`
1093+
:type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes
10901094
:param file_creation_time: Creation time for the file
10911095
Default value: Preserve.
10921096
:type file_creation_time: str or ~datetime.datetime
@@ -1125,7 +1129,7 @@ def set_http_headers(self, content_settings, # type: ContentSettings
11251129
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
11261130
#other-client--per-operation-configuration>`_.
11271131
:returns: File-updated property dict (Etag and last modified).
1128-
:rtype: dict(str, Any)
1132+
:rtype: dict[str, Any]
11291133
"""
11301134
access_conditions = get_access_conditions(kwargs.pop('lease', None))
11311135
timeout = kwargs.pop('timeout', None)
@@ -1169,7 +1173,7 @@ def set_file_metadata(self, metadata=None, **kwargs):
11691173
11701174
:param metadata:
11711175
Name-value pairs associated with the file as metadata.
1172-
:type metadata: dict(str, str)
1176+
:type metadata: dict[str, str]
11731177
:keyword lease:
11741178
Required if the file has an active lease. Value can be a ShareLeaseClient object
11751179
or the lease ID as a string.
@@ -1184,7 +1188,7 @@ def set_file_metadata(self, metadata=None, **kwargs):
11841188
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-share
11851189
#other-client--per-operation-configuration>`_.
11861190
:returns: File-updated property dict (Etag and last modified).
1187-
:rtype: dict(str, Any)
1191+
:rtype: dict[str, Any]
11881192
"""
11891193
access_conditions = get_access_conditions(kwargs.pop('lease', None))
11901194
timeout = kwargs.pop('timeout', None)
@@ -1387,6 +1391,8 @@ def upload_range_from_url(self, source_url,
13871391
:keyword str source_authorization:
13881392
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
13891393
the prefix of the source_authorization string.
1394+
:returns: Result after writing to the specified range of the destination Azure File endpoint.
1395+
:rtype: dict[str, Any]
13901396
"""
13911397
options = self._upload_range_from_url_options(
13921398
source_url=source_url,
@@ -1514,7 +1520,7 @@ def get_ranges_diff(
15141520
:returns:
15151521
A tuple of two lists of file ranges as dictionaries with 'start' and 'end' keys.
15161522
The first element are filled file ranges, the 2nd element is cleared file ranges.
1517-
:rtype: tuple(list(dict(str, str), list(dict(str, str))
1523+
:rtype: tuple[list[dict[str, str], list[dict[str, str]]
15181524
"""
15191525
options = self._get_ranges_options(
15201526
offset=offset,

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class DirectoryPropertiesPaged(PageIterator):
624624
:ivar str location_mode: The location mode being used to list results. The available
625625
options include "primary" and "secondary".
626626
:ivar current_page: The current page of listed results.
627-
:vartype current_page: list(dict(str, Any))
627+
:vartype current_page: list[dict[str, Any]]
628628
629629
:param callable command: Function to retrieve the next page of items.
630630
:param str prefix: Filters the results to return only directories whose names

0 commit comments

Comments
 (0)