Skip to content

Conversation

@yunchipang
Copy link
Contributor

related: #53395

original warning:

providers/singularity/src/airflow/providers/singularity/operators/singularity.py:176: error:
Statement is unreachable  [unreachable]
[self.log.info](http://self.log.info/)("Stopping Singularity instance")

this is caused by:

def on_kill(self) -> None:
    if self.instance is not None:
        self.log.info("Stopping Singularity instance")
        self.instance.stop()

when mypy infers the type of self.instance as None, it makes the if self.instance is not None condition always false, which makes self.log.info("Stopping Singularity instance") unreachable.

fix: use self.instance: Any = None to tell mypy that self.instance can be None or any other type
note: affected # type: ignore[attr-defined] comments are removed to fix all warnings


^ 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.

@yunchipang yunchipang force-pushed the 53395-fix-mypy-unreachable-warnings-in-singularity branch 2 times, most recently from 7bcf033 to d26b20c Compare July 17, 2025 21:11
@yunchipang yunchipang force-pushed the 53395-fix-mypy-unreachable-warnings-in-singularity branch from d26b20c to 265ab27 Compare July 18, 2025 17:14
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.

Fix sounds reasonable and is well analyzed. Please have another eye on review before merge.

@gopidesupavan gopidesupavan merged commit 573e34f into apache:main Jul 19, 2025
71 checks passed
@yunchipang yunchipang deleted the 53395-fix-mypy-unreachable-warnings-in-singularity branch July 22, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants