Skip to content

test: check decorator typing statically instead of with typeguard - #673

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/test/drop-typeguard/check-decorator-typing-statically-instead--ba6bbce5
Aug 5, 2026
Merged

test: check decorator typing statically instead of with typeguard#673
mergify[bot] merged 1 commit into
mainfrom
devs/jd/test/drop-typeguard/check-decorator-typing-statically-instead--ba6bbce5

Conversation

@jd

@jd jd commented Aug 5, 2026

Copy link
Copy Markdown
Owner

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

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
jd marked this pull request as ready for review August 5, 2026 09:37
@mergify

mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-05 09:37 UTC · Rule: default · triggered by rule autoqueue
  • Checks skipped · PR is already up-to-date
  • Merged2026-08-05 09:38 UTC · at 6ceafc0ef6bc563d582e3123f4ab0988d9656194 · squash

This pull request spent 8 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Aug 5, 2026
@mergify
mergify Bot merged commit 7246120 into main Aug 5, 2026
9 checks passed
@mergify
mergify Bot deleted the devs/jd/test/drop-typeguard/check-decorator-typing-statically-instead--ba6bbce5 branch August 5, 2026 09:38
@mergify mergify Bot removed the queued label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant