Skip to content

Commit 987a561

Browse files
fweilunpotiuk
authored andcommitted
fix unreachable mypy warnings for microsoft/azure
1 parent 04a13b5 commit 987a561

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def request_information(
437437
method: str = "GET",
438438
query_parameters: dict[str, Any] | None = None,
439439
headers: dict[str, str] | None = None,
440-
data: dict[str, Any] | str | BytesIO | None = None,
440+
data: dict[str, Any] | str | bytes | BytesIO | None = None,
441441
) -> RequestInformation:
442442
request_information = RequestInformation()
443443
request_information.path_parameters = path_parameters or {}

providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
if TYPE_CHECKING:
5858
from azure.core.credentials import TokenCredential
59+
from azure.core.credentials_async import AsyncTokenCredential
5960
from azure.storage.blob._models import BlobProperties
6061
from azure.storage.blob.aio._list_blobs_helper import BlobPrefix
6162

@@ -590,7 +591,7 @@ def __init__(
590591
"""Initialize the hook instance."""
591592
self.conn_id = wasb_conn_id
592593
self.public_read = public_read
593-
self.blob_service_client: AsyncBlobServiceClient = None # type: ignore
594+
self.blob_service_client: AsyncBlobServiceClient | None = None # type: ignore
594595

595596
async def get_async_conn(self) -> AsyncBlobServiceClient:
596597
"""Return the Async BlobServiceClient object."""
@@ -614,8 +615,9 @@ async def get_async_conn(self) -> AsyncBlobServiceClient:
614615
tenant = self._get_field(extra, "tenant_id")
615616
if tenant:
616617
# use Active Directory auth
617-
app_id = conn.login
618-
app_secret = conn.password
618+
app_id: str = conn.login or ""
619+
app_secret: str = conn.password or ""
620+
619621
token_credential = AsyncClientSecretCredential(
620622
tenant, app_id, app_secret, **client_secret_auth_config
621623
)
@@ -652,6 +654,7 @@ async def get_async_conn(self) -> AsyncBlobServiceClient:
652654
return self.blob_service_client
653655

654656
# Fall back to old auth (password) or use managed identity if not provided.
657+
credential: str | AsyncTokenCredential | None
655658
credential = conn.password
656659
if not credential:
657660
# Check for account_key in extra fields before falling back to DefaultAzureCredential
@@ -681,6 +684,9 @@ def _get_blob_client(self, container_name: str, blob_name: str) -> AsyncBlobClie
681684
:param container_name: the name of the blob container
682685
:param blob_name: the name of the blob. This needs not be existing
683686
"""
687+
if self.blob_service_client is None:
688+
raise AirflowException("BlobServiceClient is not initialized")
689+
684690
return self.blob_service_client.get_blob_client(container=container_name, blob=blob_name)
685691

686692
async def check_for_blob_async(self, container_name: str, blob_name: str, **kwargs: Any) -> bool:
@@ -704,6 +710,9 @@ def _get_container_client(self, container_name: str) -> AsyncContainerClient: #
704710
705711
:param container_name: the name of the container
706712
"""
713+
if self.blob_service_client is None:
714+
raise AirflowException("BlobServiceClient is not initialized")
715+
707716
return self.blob_service_client.get_container_client(container_name)
708717

709718
async def get_blobs_list_async(

providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def execute_complete(
247247
@classmethod
248248
def append_result(
249249
cls,
250-
results: list[Any],
250+
results: Any,
251251
result: Any,
252252
append_result_as_list_if_absent: bool = False,
253253
) -> list[Any]:

providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/synapse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
**kwargs,
8989
) -> None:
9090
super().__init__(**kwargs)
91-
self.job_id = None
91+
self.job_id: Any = None
9292
self.azure_synapse_conn_id = azure_synapse_conn_id
9393
self.wait_for_termination = wait_for_termination
9494
self.spark_pool = spark_pool

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,18 @@ def __init__(
100100
) -> None:
101101
super().__init__()
102102
self.vault_url = vault_url
103-
if connections_prefix is not None:
103+
self.connections_prefix: str | None
104+
if connections_prefix:
104105
self.connections_prefix = connections_prefix.rstrip(sep)
105106
else:
106107
self.connections_prefix = connections_prefix
107-
if variables_prefix is not None:
108+
self.variables_prefix: str | None
109+
if variables_prefix:
108110
self.variables_prefix = variables_prefix.rstrip(sep)
109111
else:
110112
self.variables_prefix = variables_prefix
111-
if config_prefix is not None:
113+
self.config_prefix: str | None
114+
if config_prefix:
112115
self.config_prefix = config_prefix.rstrip(sep)
113116
else:
114117
self.config_prefix = config_prefix

0 commit comments

Comments
 (0)