You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/05/12 07:06:32 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #31240: Better typing for Job and JobRunners

potiuk commented on code in PR #31240:
URL: https://github.com/apache/airflow/pull/31240#discussion_r1191988567


##########
airflow/jobs/base_job_runner.py:
##########
@@ -17,22 +17,27 @@
 
 from __future__ import annotations
 
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Generic, TypeVar
 
 from airflow.utils.session import NEW_SESSION, provide_session
 
 if TYPE_CHECKING:
     from sqlalchemy.orm import Session
 
     from airflow.jobs.job import Job
+    from airflow.serialization.pydantic.job import JobPydantic
 
+T = TypeVar("T", bound="Job | JobPydantic")

Review Comment:
   Nice!



##########
airflow/jobs/base_job_runner.py:
##########
@@ -17,22 +17,27 @@
 
 from __future__ import annotations
 
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Generic, TypeVar
 
 from airflow.utils.session import NEW_SESSION, provide_session
 
 if TYPE_CHECKING:
     from sqlalchemy.orm import Session
 
     from airflow.jobs.job import Job
+    from airflow.serialization.pydantic.job import JobPydantic
 
+T = TypeVar("T", bound="Job | JobPydantic")
 
-class BaseJobRunner:
+JobOrJobPydantic = TypeVar("JobOrJobPydantic", bound="Job | JobPydantic")

Review Comment:
   Even nicer!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org