Pass ClientTimeout to aiohttp in Cloud Composer async hook - #74164
Merged
Merged
Conversation
aiohttp types the keyword arguments of ClientSession.request only when type-checking on Python 3.11 or newer, where timeout must be a ClientTimeout. On 3.10 the arguments are untyped, so passing the hook's float timeout went unnoticed until CI moved to Python 3.11. aiohttp already converts a bare number to ClientTimeout(total=...) at runtime, so building it explicitly keeps the behaviour and satisfies mypy.
dabla
approved these changes
Oct 3, 2026
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: #74151
This PR passes
ClientTimeoutexplicitly toaiohttpin Cloud Composer async hook.This fix is simple yet required to appease mypy when upgrading to Python 3.11.
AI Summary
CloudComposerAsyncHook.make_composer_airflow_api_requestpassed itstimeout: float | Nonestraight toaiohttp.ClientSession.request. aiohttp only types the request keyword arguments when type-checking on Python 3.11+ (if sys.version_info >= (3, 11) and TYPE_CHECKING: ... **kwargs: Unpack[_RequestOptions]), wheretimeoutisClientTimeout | _SENTINEL | None. On 3.10 the kwargs areAny, so the mismatch went unnoticed until #74151 moved CI (and mypy) to Python 3.11:The fix wraps the value in
ClientTimeout(total=timeout). This is exactly what aiohttp already does at runtime for a non-ClientTimeoutvalue (real_timeout = ClientTimeout(total=timeout)), so behaviour is unchanged, includingNonemeaning no total timeout. A unit test for the async request method (which had none) asserts theClientTimeoutthat reachessession.requestfor both a float andNone; it fails without the change.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines
🤖 Generated with Claude Code