Skip to content

Conversation

@gopidesupavan
Copy link
Member

@jscheffl and Me were discussing on mypy unreachable code warnings, we scanned through all the providers and found around 120 warnings, there could be some false positives. I have drafted all those warnings here #53395.

In this PR, will be fixing some of AWS provider warnings, that are make sense to fix. and this will help reference PR to people who works on the created issues.

Will be sending out devlist about this work, once it merged #53398


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@gopidesupavan
Copy link
Member Author

FYI for amazon provider mypy flagged these:

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:94: error: Statement is unreachable [unreachable]
self.connections_prefix = connections_prefix

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:98: error: Statement is unreachable [unreachable]
self.variables_prefix = variables_prefix

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:102: error: Statement is unreachable [unreachable]
self.config_prefix = config_prefix

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:142: error: Statement is unreachable [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:154: error: Statement is unreachable [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/secrets/systems_manager.py:166: error: Statement is unreachable [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/secrets/secrets_manager.py:208: error: Statement is unreachable [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/secrets/secrets_manager.py:237: error: Statement is unreachable [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/secrets/secrets_manager.py:249: error: Statement is unreachable  [unreachable]
return None

providers/amazon/src/airflow/providers/amazon/aws/hooks/eks.py:534: error: Statement is unreachable  [unreachable]
self.log.info("Retrieved list of %s %s.", len(name_collection)...

providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py:234: error: Subclass of "str" and "ExecuteTask" cannot exist: would have incompatible method signatures  [unreachable]
if isinstance(command[0], ExecuteTask):

providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py:235: error: Statement is unreachable  [unreachable]
workload = command[0]

providers/amazon/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py:496: error: Subclass of "str" and "ExecuteTask" cannot exist: would have incompatible method signatures  [unreachable]
if isinstance(command[0], ExecuteTask):

providers/amazon/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py:497: error: Statement is unreachable  [unreachable]
workload = command[0]

providers/amazon/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py:382: error: Subclass of "str" and "ExecuteTask" cannot exist: would have incompatible method signatures  [unreachable]
if isinstance(command[0], ExecuteTask):

providers/amazon/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py:383: error: Statement is unreachable  [unreachable]
workload = command[0]

providers/amazon/src/airflow/providers/amazon/aws/transfers/sql_to_s3.py:167: error: Statement is unreachable  [unreachable]
df[col] = df[col].astype(str)

providers/amazon/src/airflow/providers/amazon/aws/operators/athena.py:242: error: Subclass of "str" and "list[Any]" cannot exist: would have incompatible method signatures  [unreachable]
totalTasks=len(self.query) if isinstance(self.query, list) els...

providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker.py:92: error: Subclass of "dict[Any, Any]" and "list[Any]" cannot exist: would have incompatible method signatures  [unreachable]
if isinstance(config, list):

providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker.py:93: error: Statement is unreachable  [unreachable]
for sub_config in config:

providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker.py:100: error: Subclass of "dict[Any, Any]" and "list[Any]" cannot exist: would have incompatible method signatures  [unreachable]
if isinstance(config, list):

providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker.py:101: error: Statement is unreachable  [unreachable]
for sub_config in config:

providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker.py:1012: error: Statement is unreachable  [unreachable]
description = {} # never executed but makes static checke...

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@gopidesupavan gopidesupavan merged commit 5ca58d6 into apache:main Jul 16, 2025
77 checks passed
@gopidesupavan gopidesupavan deleted the remove-or-fix-unreachable-code-in-aws-provider branch July 16, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants