Helper for provide_session-decorated functions#20104
Conversation
dd307a5 to
70b2a53
Compare
|
OH NICE! |
|
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. |
2fe0f95 to
33f4447
Compare
|
|
||
| engine: Optional[Engine] = None | ||
| Session: Optional[SASession] = None | ||
| Session: Callable[..., SASession] |
There was a problem hiding this comment.
This will conflict with #20000 (and also , the SessionMaker is both callable, and behaves like an actual Session. SQLA is weird like that)
There was a problem hiding this comment.
Let me see if I can just make this Session: SessionMaker
There was a problem hiding this comment.
Hmm no, SQLAlchemy is not type hinted well enough, annotating this as sessionmaker would make Session() return Any. I’ll keep this for now since this is more useful in general.
There was a problem hiding this comment.
This is probably fine as it is (and it's how we use it in Airflow)
* Helper for provide_session-decorated functions * Apply NEW_SESSION trick on XCom (cherry picked from commit a80ac1e)
* Helper for provide_session-decorated functions * Apply NEW_SESSION trick on XCom (cherry picked from commit a80ac1e)
* Helper for provide_session-decorated functions * Apply NEW_SESSION trick on XCom (cherry picked from commit a80ac1e)
This can be used like this:
This eliminates the need to use
Optional[Session] = Noneto reduce boilerplate code.cc @potiuk this can be useful for your #19914.