Skip to content

Commit 427f070

Browse files
hallvictoriaVictoria Hall
andauthored
Linting blob extension (#18)
* black * isort * weird import ordering --------- Co-authored-by: Victoria Hall <[email protected]>
1 parent 634cefa commit 427f070

File tree

12 files changed

+284
-204
lines changed

12 files changed

+284
-204
lines changed

azure-functions-extension-blob/azure/functions/extension/blob/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# Licensed under the MIT License.
33

44
from .blobClient import BlobClient
5+
from .blobClientConverter import BlobClientConverter
56
from .containerClient import ContainerClient
67
from .storageStreamDownloader import StorageStreamDownloader
7-
from .blobClientConverter import BlobClientConverter
88

99
__all__ = [
10-
'BlobClient',
11-
'ContainerClient',
12-
'StorageStreamDownloader',
13-
'BlobClientConverter']
10+
"BlobClient",
11+
"ContainerClient",
12+
"StorageStreamDownloader",
13+
"BlobClientConverter",
14+
]
1415

1516
__version__ = "1.0.0a1"

azure-functions-extension-blob/azure/functions/extension/blob/blobClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import json
55
import os
6+
from typing import Union
67

78
from azure.functions.extension.base import Datum, SdkType
89
from azure.storage.blob import BlobClient as BlobClientSdk
9-
from typing import Union
1010

1111

1212
class BlobClient(SdkType):
@@ -35,7 +35,7 @@ def get_sdk_type(self):
3535
return BlobClientSdk.from_connection_string(
3636
conn_str=self._connection,
3737
container_name=self._containerName,
38-
blob_name=self._blobName
38+
blob_name=self._blobName,
3939
)
4040
else:
4141
return None

azure-functions-extension-blob/azure/functions/extension/blob/blobClientConverter.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
from typing import Any
55

66
from azure.functions.extension.base import Datum, InConverter, OutConverter
7+
78
from .blobClient import BlobClient
89
from .containerClient import ContainerClient
910
from .storageStreamDownloader import StorageStreamDownloader
1011

1112

12-
class BlobClientConverter(InConverter,
13-
OutConverter,
14-
binding='blob',
15-
trigger='blobTrigger',):
13+
class BlobClientConverter(
14+
InConverter,
15+
OutConverter,
16+
binding="blob",
17+
trigger="blobTrigger",
18+
):
1619

1720
@classmethod
1821
def check_input_type_annotation(cls, pytype: type) -> bool:
19-
return issubclass(pytype, (BlobClient, ContainerClient,
20-
StorageStreamDownloader))
22+
return issubclass(
23+
pytype, (BlobClient, ContainerClient, StorageStreamDownloader)
24+
)
2125

2226
@classmethod
2327
def decode(cls, data: Datum, *, trigger_metadata, pytype) -> Any:
@@ -26,12 +30,12 @@ def decode(cls, data: Datum, *, trigger_metadata, pytype) -> Any:
2630

2731
data_type = data.type
2832

29-
if data_type == 'model_binding_data':
33+
if data_type == "model_binding_data":
3034
data = data.value
3135
else:
3236
raise ValueError(
3337
f'unexpected type of data received for the "blob" binding '
34-
f': {data_type!r}'
38+
f": {data_type!r}"
3539
)
3640

3741
# Determines which sdk type to return based on pytype

azure-functions-extension-blob/azure/functions/extension/blob/containerClient.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import json
55
import os
6+
from typing import Union
67

78
from azure.functions.extension.base import Datum, SdkType
89
from azure.storage.blob import ContainerClient as ContainerClientSdk
9-
from typing import Union
1010

1111

1212
class ContainerClient(SdkType):
@@ -33,8 +33,7 @@ def __init__(self, *, data: Union[bytes, Datum]) -> None:
3333
def get_sdk_type(self):
3434
if self._data:
3535
return ContainerClientSdk.from_connection_string(
36-
conn_str=self._connection,
37-
container_name=self._containerName
36+
conn_str=self._connection, container_name=self._containerName
3837
)
3938
else:
4039
return None

azure-functions-extension-blob/azure/functions/extension/blob/storageStreamDownloader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import json
55
import os
6+
from typing import Union
67

78
from azure.functions.extension.base import Datum, SdkType
89
from azure.storage.blob import BlobClient as BlobClientSdk
9-
from typing import Union
1010

1111

1212
class StorageStreamDownloader(SdkType):
@@ -36,7 +36,8 @@ def get_sdk_type(self):
3636
blob_client = BlobClientSdk.from_connection_string(
3737
conn_str=self._connection,
3838
container_name=self._containerName,
39-
blob_name=self._blobName)
39+
blob_name=self._blobName,
40+
)
4041
# download_blob() returns a StorageStreamDownloader object
4142
return blob_client.download_blob()
4243
else:

azure-functions-extension-blob/samples/blob_samples_blobclient/function_app.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
import logging
10+
1011
import azure.functions as func
1112
import azure.functions.extension.blob as blob
1213

@@ -27,21 +28,25 @@
2728
"""
2829

2930

30-
@app.blob_trigger(arg_name="client",
31-
path="PATH/TO/BLOB",
32-
connection="AzureWebJobsStorage")
31+
@app.blob_trigger(
32+
arg_name="client", path="PATH/TO/BLOB", connection="AzureWebJobsStorage"
33+
)
3334
def blob_trigger(client: blob.BlobClient):
34-
logging.info(f"Python blob trigger function processed blob \n"
35-
f"Properties: {client.get_blob_properties()}\n"
36-
f"Blob content: {client.download_blob().readall()}")
35+
logging.info(
36+
f"Python blob trigger function processed blob \n"
37+
f"Properties: {client.get_blob_properties()}\n"
38+
f"Blob content: {client.download_blob().readall()}"
39+
)
3740

3841

3942
@app.route(route="file")
40-
@app.blob_input(arg_name="client",
41-
path="PATH/TO/BLOB",
42-
connection="AzureWebJobsStorage")
43+
@app.blob_input(
44+
arg_name="client", path="PATH/TO/BLOB", connection="AzureWebJobsStorage"
45+
)
4346
def blob_input(req: func.HttpRequest, client: blob.BlobClient):
44-
logging.info(f"Python blob trigger function processed blob \n"
45-
f"Properties: {client.get_blob_properties()}\n"
46-
f"Blob content: {client.download_blob().readall()}")
47+
logging.info(
48+
f"Python blob trigger function processed blob \n"
49+
f"Properties: {client.get_blob_properties()}\n"
50+
f"Blob content: {client.download_blob().readall()}"
51+
)
4752
return "ok"

azure-functions-extension-blob/samples/blob_samples_containerclient/function_app.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
import logging
10+
1011
import azure.functions as func
1112
import azure.functions.extension.blob as blob
1213

@@ -27,19 +28,19 @@
2728
"""
2829

2930

30-
@app.blob_trigger(arg_name="client",
31-
path="CONTAINER",
32-
connection="AzureWebJobsStorage")
31+
@app.blob_trigger(arg_name="client", path="CONTAINER", connection="AzureWebJobsStorage")
3332
def blob_trigger(client: blob.ContainerClient):
34-
logging.info(f"Python blob trigger function processed blob \n"
35-
f"Properties: {client.get_container_properties()}\n")
33+
logging.info(
34+
f"Python blob trigger function processed blob \n"
35+
f"Properties: {client.get_container_properties()}\n"
36+
)
3637

3738

3839
@app.route(route="file")
39-
@app.blob_input(arg_name="client",
40-
path="CONTAINER",
41-
connection="AzureWebJobsStorage")
40+
@app.blob_input(arg_name="client", path="CONTAINER", connection="AzureWebJobsStorage")
4241
def blob_input(req: func.HttpRequest, client: blob.BlobClient):
43-
logging.info(f"Python blob trigger function processed blob \n"
44-
f"Properties: {client.get_container_properties()}\n")
42+
logging.info(
43+
f"Python blob trigger function processed blob \n"
44+
f"Properties: {client.get_container_properties()}\n"
45+
)
4546
return "ok"

azure-functions-extension-blob/samples/blob_samples_storagestreamdownloader/function_app.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
import logging
10+
1011
import azure.functions as func
1112
import azure.functions.extension.blob as blob
1213

@@ -27,21 +28,25 @@
2728
"""
2829

2930

30-
@app.blob_trigger(arg_name="stream",
31-
path="PATH/TO/BLOB",
32-
connection="AzureWebJobsStorage")
31+
@app.blob_trigger(
32+
arg_name="stream", path="PATH/TO/BLOB", connection="AzureWebJobsStorage"
33+
)
3334
def blob_trigger(stream: blob.StorageStreamDownloader):
3435
for chunk in stream.chunks():
35-
logging.info(f"Python blob trigger function processed blob chunk \n"
36-
f"Chunk: {chunk.decode()}")
36+
logging.info(
37+
f"Python blob trigger function processed blob chunk \n"
38+
f"Chunk: {chunk.decode()}"
39+
)
3740

3841

3942
@app.route(route="file")
40-
@app.blob_input(arg_name="stream",
41-
path="PATH/TO/BLOB",
42-
connection="AzureWebJobsStorage")
43+
@app.blob_input(
44+
arg_name="stream", path="PATH/TO/BLOB", connection="AzureWebJobsStorage"
45+
)
4346
def blob_input(req: func.HttpRequest, stream: blob.StorageStreamDownloader):
4447
for chunk in stream.chunks():
45-
logging.info(f"Python blob trigger function processed blob chunk \n"
46-
f"Chunk: {chunk.decode()}")
48+
logging.info(
49+
f"Python blob trigger function processed blob chunk \n"
50+
f"Chunk: {chunk.decode()}"
51+
)
4752
return "ok"

azure-functions-extension-blob/tests/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
def suite():
1313
test_loader = unittest.TestLoader()
14-
return test_loader.discover(
15-
os.path.dirname(__file__), pattern='test_*.py')
14+
return test_loader.discover(os.path.dirname(__file__), pattern="test_*.py")
1615

1716

18-
if __name__ == '__main__':
17+
if __name__ == "__main__":
1918
runner = unittest.runner.TextTestRunner()
2019
result = runner.run(suite())
2120
sys.exit(not result.wasSuccessful())

0 commit comments

Comments
 (0)