test: check decorator typing statically instead of with typeguard - #673
Merged
mergify[bot] merged 1 commit intoAug 5, 2026
Conversation
typeguard existed for exactly one test: TestRetryTyping asserted at runtime that @Retry preserves the decorated function's type. That check was weaker than it looked. check_type() cannot inspect a function object's signature at runtime, so 'check_type(with_raw, Callable[[int], str])' only ever confirmed the object was callable -- it would have passed just as happily on a wrapper that took different arguments or returned something else. The real guarantee comes from the WrappedFn TypeVar in the overloads, which is a static property, so check it statically. mypy already runs strict over tests/, and the annotations here catch strictly more than typeguard did: the positive cases pin the signature structurally, and the negative case would fail if @Retry ever decayed to Any, because warn_unused_ignores turns the then-dead ignore into an error. Also fixes a copy-paste bug: with_constructor_result was assigned from with_raw(1), so the @Retry(...) path's result was never checked at all. Drops the typeguard dependency, which had already cost a round of test breakage on its 3.x release. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Change-Id: Iba6bbce53302c81bb7a84c6a9925b6f234d22d37
jd
marked this pull request as ready for review
August 5, 2026 09:37
Contributor
Merge Queue Status
This pull request spent 8 seconds in the queue, including 1 second running CI. Required conditions to merge
|
mergify
Bot
deleted the
devs/jd/test/drop-typeguard/check-decorator-typing-statically-instead--ba6bbce5
branch
August 5, 2026 09:38
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.
typeguard existed for exactly one test: TestRetryTyping asserted at runtime
that @Retry preserves the decorated function's type. That check was weaker
than it looked. check_type() cannot inspect a function object's signature at
runtime, so 'check_type(with_raw, Callable[[int], str])' only ever confirmed
the object was callable -- it would have passed just as happily on a wrapper
that took different arguments or returned something else.
The real guarantee comes from the WrappedFn TypeVar in the overloads, which
is a static property, so check it statically. mypy already runs strict over
tests/, and the annotations here catch strictly more than typeguard did:
the positive cases pin the signature structurally, and the negative case
would fail if @Retry ever decayed to Any, because warn_unused_ignores turns
the then-dead ignore into an error.
Also fixes a copy-paste bug: with_constructor_result was assigned from
with_raw(1), so the @Retry(...) path's result was never checked at all.
Drops the typeguard dependency, which had already cost a round of test
breakage on its 3.x release.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com