fweilun opened a new pull request, #53647:
URL: https://github.com/apache/airflow/pull/53647

   Related: https://github.com/apache/airflow/issues/53395
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:106:
 error: Statement is unreachable [unreachable]
   self.connections_prefix = connections_prefix
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:110:
 error: Statement is unreachable [unreachable]
   self.variables_prefix = variables_prefix
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:114:
 error: Statement is unreachable [unreachable]
   self.config_prefix = config_prefix
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:151:
 error: Statement is unreachable [unreachable]
   return None
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:163:
 error: Statement is unreachable [unreachable]
   return None
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:175:
 error: Statement is unreachable [unreachable]
   return None
   
   
   All of the variables (connections_prefix, variables_prefix, config_prefix) 
are allowed to be None, as seen in existing test cases. However, the original 
code only implied string types, leading to unreachable MyPy errors.
   
   We resolved this by:
        •       Explicitly annotating input arguments as str | None
        •       Using safe conditional initialization with
   
   original:
   ```python
   if connections_prefix:
       self.connections_prefix = connections_prefix.rstrip(sep)
   else:
       self.connections_prefix = connections_prefix
   ```
   
   ```python
   self.connections_prefix = connections_prefix
   if isinstance(self.connections_prefix, str):
       self.connections_prefix.rstrip(sep)
   ```
   
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:599:
 error: Statement is unreachable [unreachable]
   conn = await sync_to_async(self.get_connection)(self.conn_id)
   
   The code was flagged as unreachable by MyPy because self.blob_service_client 
was not annotated to allow None.
   As a result, the following condition is always True from the type checker’s 
perspective:
   ```python
   if self.blob_service_client is not None:
       return self.blob_service_client
   ```
   To fix this, we explicitly annotated the attribute to allow None:
   ```python
   self.blob_service_client: AsyncBlobServiceClient | None = None  # type: 
ignore
   ```
   This makes the conditional logic valid and resolves the MyPy warning.
   
   
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py:463:
 error: Statement is unreachable [unreachable]
   request_information.content = data
   
   Added bytes to the input type annotation to fix a type mismatch.
   
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/synapse.py:129:
 error: Statement is unreachable [unreachable]
   self.hook.cancel_job_run(
   
   Annotated self.job_id as Any to match its default value None and resolve the 
type warning.
   
   
   
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py:260:
 error: Statement is unreachable [unreachable]
   if append_result_as_list_if_absent:
   
   The is condition was unreachable due to the static type of results. Changing 
its annotation to Any resolves the issue.
   


-- 
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]

Reply via email to