Fix mypy failure on datadog timer wrapped by shared observability Timer - #69202
Merged
potiuk merged 1 commit intoJul 1, 2026
Merged
Conversation
The real_timer parameter accepts any backend timer exposing start/stop (pystatsd, dogstatsd), not the shared Timer itself. Typing it against a minimal protocol reflects that contract and stops mypy rejecting the typed dogstatsd TimedContextManagerDecorator.
Lee-W
marked this pull request as draft
July 1, 2026 11:04
potiuk
approved these changes
Jul 1, 2026
potiuk
marked this pull request as ready for review
July 1, 2026 12:06
Member
|
This looks good. let me rebase ci upgrade :) |
xBis7
pushed a commit
to xBis7/airflow
that referenced
this pull request
Jul 7, 2026
…er (apache#69202) The real_timer parameter accepts any backend timer exposing start/stop (pystatsd, dogstatsd), not the shared Timer itself. Typing it against a minimal protocol reflects that contract and stops mypy rejecting the typed dogstatsd TimedContextManagerDecorator. (cherry picked from commit 5946046)
Merged
1 task
potiuk
added a commit
that referenced
this pull request
Aug 1, 2026
…er (#69202) (#70887) The real_timer parameter accepts any backend timer exposing start/stop (pystatsd, dogstatsd), not the shared Timer itself. Typing it against a minimal protocol reflects that contract and stops mypy rejecting the typed dogstatsd TimedContextManagerDecorator. (cherry picked from commit 5946046) Co-authored-by: Wei Lee <weilee.rx@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Aug 5, 2026
…er (#69202) (#70887) The real_timer parameter accepts any backend timer exposing start/stop (pystatsd, dogstatsd), not the shared Timer itself. Typing it against a minimal protocol reflects that contract and stops mypy rejecting the typed dogstatsd TimedContextManagerDecorator. (cherry picked from commit 5946046) Co-authored-by: Wei Lee <weilee.rx@gmail.com>
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.
Why
prek run mypy-shared-observabilityfails:datadog_logger.pypasses dogstatsd'sTimedContextManagerDecoratorintoTimer(...), butreal_timeris typedTimer | None, so the types don't match.real_timeris never the sharedTimeritself, it's a third-party backend timer (pystatsd / dogstatsd). It slipped through before only because pystatsd ships no stubs (treated asAny); datadog has stubs, which surfaced the mismatch.What
BackendTimerProtocol(juststart()/stop()) and retypeTimer.__init__'sreal_timerfromTimer | NonetoBackendTimerProtocol | None, reflecting the interface it actually accepts.Was generative AI tooling used to co-author this PR?
Generated-by: [Claude] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.