jason810496 commented on code in PR #54219:
URL: https://github.com/apache/airflow/pull/54219#discussion_r2280739101
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -735,6 +745,8 @@ async def get_blobs_list_async(
:param delimiter: filters objects based on the delimiter (for e.g
'.csv')
"""
container = self._get_container_client(container_name)
+ self.check_for_variable_type("container", container,
AsyncContainerClient)
+
Review Comment:
```suggestion
container = cast("AsyncContainerClient", container)
```
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -312,8 +328,11 @@ def get_blobs_list_recursive(
:param delimiter: filters objects based on the delimiter (for e.g
'.csv')
"""
container = self._get_container_client(container_name)
+ self.check_for_variable_type("container", container, ContainerClient)
+
Review Comment:
```suggestion
container = cast("ContainerClient", container)
```
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -591,12 +610,15 @@ def __init__(
"""Initialize the hook instance."""
self.conn_id = wasb_conn_id
self.public_read = public_read
- self.blob_service_client: AsyncBlobServiceClient = None # type: ignore
+ self._blob_service_client: AsyncBlobServiceClient | BlobServiceClient
| None = None
async def get_async_conn(self) -> AsyncBlobServiceClient:
"""Return the Async BlobServiceClient object."""
- if self.blob_service_client is not None:
- return self.blob_service_client
+ if self._blob_service_client is not None:
+ self.check_for_variable_type(
+ "self._blob_service_client", self._blob_service_client,
AsyncBlobServiceClient
+ )
Review Comment:
```suggestion
)
self._blob_service_client = cast("AsyncBlobServiceClient",
self._blob_service_client)
```
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -266,6 +272,14 @@ def check_for_prefix(self, container_name: str, prefix:
str, **kwargs) -> bool:
blobs = self.get_blobs_list(container_name=container_name,
prefix=prefix, **kwargs)
return bool(blobs)
+ T = TypeVar("T", AsyncBlobServiceClient, ContainerClient,
AsyncContainerClient)
Review Comment:
The TypeVar should be moved to the top level since it is a constant.
Additionally, `BlobServiceClient` should be included in the TypeVar.
```suggestion
T = TypeVar("T", AsyncBlobServiceClient, BlobServiceClient,
ContainerClient, AsyncContainerClient)
```
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -286,6 +300,8 @@ def get_blobs_list(
:param delimiter: filters objects based on the delimiter (for e.g
'.csv')
"""
container = self._get_container_client(container_name)
+ self.check_for_variable_type("container", container, ContainerClient)
+
Review Comment:
```suggestion
container = cast("ContainerClient", container)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]