Repository navigation
Fix MyPy type errors in airflow-core/src/airflow/models/dag.py for Sqlalchemy 2 migration - #57532
Closed
KoviAnusha wants to merge 19 commits into
Closed
KoviAnusha wants to merge 19 commits into
KoviAnusha wants to merge 19 commits into
Conversation
…,dag,variable) for Sqlalchemy 2 migration
KoviAnusha
marked this pull request as ready for review
October 30, 2025 15:41
Dev-iL
reviewed
Nov 2, 2025
Dev-iL
reviewed
Nov 2, 2025
Dev-iL
reviewed
Nov 2, 2025
uranusjr
reviewed
Nov 6, 2025
3 of 10 tasks
Contributor
Author
uranusjr
reviewed
Nov 17, 2025
uranusjr
reviewed
Nov 17, 2025
uranusjr
reviewed
Nov 17, 2025
uranusjr
reviewed
Nov 17, 2025
uranusjr
reviewed
Nov 17, 2025
arnoldmr01
reviewed
Nov 20, 2025
uranusjr
reviewed
Nov 20, 2025
| log.warning( | ||
| warning_message, | ||
| "return value" if key == XCOM_RETURN_KEY else f"value {key}", | ||
| "return value" if key == XCOM_RETURN_KEY else "value %s", |
Member
There was a problem hiding this comment.
I don’t think this would work. This is the second argument and putting the template placeholder would not work as you expect.
>>> import logging, sys
>>> logging.basicConfig(stream=sys.stdout, level=logging.INFO)
>>> logging.getLogger('').info('foo %s', 'bar %s', 1)
--- Logging error ---
Traceback (most recent call last):
File "logging/__init__.py", line 1100, in emit
msg = self.format(record)
File "logging/__init__.py", line 943, in format
return fmt.format(record)
File "logging/__init__.py", line 678, in format
record.message = record.getMessage()
File "logging/__init__.py", line 368, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "<stdin>", line 1, in <module>
Message: 'foo %s'
Arguments: ('bar %s', 1)It’s probably a good idea to switch this to use structlog instead.
Contributor
Author
There was a problem hiding this comment.
Thanks for suggesting this approach. I have addressed this. Please review.
vincbeck
approved these changes
Nov 24, 2025
Contributor
|
All mypy errors have been fixed. Closing it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related: #56735
mypy errors:
airflow-core/src/airflow/models/dagbag.py:75: error: Need type annotation for
"info" [var-annotated]
info = inspect(dag_run)
^~~~~~~~~~~~~~~~
airflow-core/src/airflow/models/dagbag.py:81: error: Incompatible return value
type (got "DagVersion | None", expected "DagVersion") [return-value]
return session.get(DagVersion, dag_run.created_dag_version_id)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
airflow-core/src/airflow/models/dag.py:139: error: Argument 2 to
"infer_automated_data_interval" has incompatible type "datetime | None";
expected "datetime" [arg-type]
return infer_automated_data_interval(timetable, run.logical_date)
^~~~~~~~~~~~~~~~
airflow-core/src/airflow/models/dag.py:525: error: Incompatible types in
assignment (expression has type "set[Any]", variable has type
"Result[tuple[str]]") [assignment]
paused_dag_ids = {paused_dag_id for (paused_dag_id,) in paused...
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
airflow-core/src/airflow/models/dag.py:526: error: Incompatible return value
type (got "Result[tuple[str]]", expected "set[str]") [return-value]
return paused_dag_ids
^~~~~~~~~~~~~~
^ 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.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.