Skip to content

Commit

Permalink
Fix mypy checks for new azure libraries (#41386)
Browse files Browse the repository at this point in the history
(cherry picked from commit 68a6a05)
  • Loading branch information
potiuk committed Aug 11, 2024
1 parent 09567dc commit 6c6797c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions airflow/providers/microsoft/azure/hooks/wasb.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def get_conn(self) -> BlobServiceClient:
**extra,
)

def _get_container_client(self, container_name: str) -> ContainerClient:
# TODO: rework the interface as it might also return AsyncContainerClient
def _get_container_client(self, container_name: str) -> ContainerClient: # type: ignore[override]
"""
Instantiate a container client.
Expand All @@ -222,7 +223,7 @@ def _get_container_client(self, container_name: str) -> ContainerClient:
"""
return self.blob_service_client.get_container_client(container_name)

def _get_blob_client(self, container_name: str, blob_name: str) -> BlobClient:
def _get_blob_client(self, container_name: str, blob_name: str) -> BlobClient | AsyncBlobClient:
"""
Instantiate a blob client.
Expand Down Expand Up @@ -415,7 +416,8 @@ def upload(
self.create_container(container_name)

blob_client = self._get_blob_client(container_name, blob_name)
return blob_client.upload_blob(data, blob_type, length=length, **kwargs)
# TODO: rework the interface as it might also return Awaitable
return blob_client.upload_blob(data, blob_type, length=length, **kwargs) # type: ignore[return-value]

def download(
self, container_name, blob_name, offset: int | None = None, length: int | None = None, **kwargs
Expand All @@ -430,7 +432,8 @@ def download(
:param length: Number of bytes to read from the stream.
"""
blob_client = self._get_blob_client(container_name, blob_name)
return blob_client.download_blob(offset=offset, length=length, **kwargs)
# TODO: rework the interface as it might also return Awaitable
return blob_client.download_blob(offset=offset, length=length, **kwargs) # type: ignore[return-value]

def create_container(self, container_name: str) -> None:
"""
Expand Down Expand Up @@ -656,7 +659,8 @@ async def check_for_blob_async(self, container_name: str, blob_name: str, **kwar
return False
return True

def _get_container_client(self, container_name: str) -> AsyncContainerClient:
# TODO: rework the interface as in parent Hook it returns ContainerClient
def _get_container_client(self, container_name: str) -> AsyncContainerClient: # type: ignore[override]
"""
Instantiate a container client.
Expand Down

0 comments on commit 6c6797c

Please sign in to comment.