Skip to content

Conversation

@uranusjr
Copy link
Member

@uranusjr uranusjr commented Dec 9, 2021

Some more typing fixups found when implementing another feature, submitted separately.

Comment on lines -890 to +891
models_to_dagrun = [TaskInstance, TaskReschedule]
models_to_dagrun: List[Any] = [TaskInstance, TaskReschedule]
Copy link
Member Author

@uranusjr uranusjr Dec 9, 2021

Choose a reason for hiding this comment

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

Technically we can type this (what we want is the __tablename__ attribute from SQLAlchemy), but SQLAlchemy is so dynamic, adding accurate type here does not really help much, so I don’t really want to bother.

Copy link
Member

Choose a reason for hiding this comment

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

👍🏻 Also, as this isn't called anywhere from outside of this module it doesn't impact the typing of the rest of the code base.

self, state: Optional[Iterable[TaskInstanceState]] = None, session=None
self,
state: Optional[Iterable[Optional[TaskInstanceState]]] = None,
session: Session = NEW_SESSION,
Copy link
Member

Choose a reason for hiding this comment

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

In a separate PR or this (your choice) - can you add a small section in https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices to let devs know when they should use NEW_SESSION vs Session for type hints

Copy link
Member Author

Choose a reason for hiding this comment

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

Submitted as #20181.

@kaxil kaxil closed this Dec 9, 2021
@kaxil kaxil reopened this Dec 9, 2021
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Dec 9, 2021
@github-actions
Copy link

github-actions bot commented Dec 9, 2021

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@kaxil kaxil removed the full tests needed We need to run full set of tests for this PR to merge label Dec 9, 2021
def get_task_instances(
self, state: Optional[Iterable[TaskInstanceState]] = None, session=None
self,
state: Optional[Iterable[Optional[TaskInstanceState]]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Isn't None a valid TaskInstanceState?

NONE = None

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect subclassing from str is the problem here (but we probably can’t fix that without breaking a ton of things).

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Dec 9, 2021
@github-actions
Copy link

github-actions bot commented Dec 9, 2021

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@uranusjr uranusjr merged commit b297fc7 into apache:main Dec 9, 2021
@uranusjr uranusjr deleted the mypy-dr-ti-db branch December 9, 2021 20:36
@potiuk potiuk added the mypy Fixing MyPy problems after bumpin MyPy to 0.990 label Dec 13, 2021
@kaxil kaxil added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) full tests needed We need to run full set of tests for this PR to merge mypy Fixing MyPy problems after bumpin MyPy to 0.990

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants