Skip to content

Improve inline type annotations - #664

Merged
mergify[bot] merged 3 commits into
jd:mainfrom
heejaechang:heejaechang-port-inline-annotations
Aug 5, 2026
Merged

mergify[bot] merged 3 commits into
jd:mainfrom
heejaechang:heejaechang-port-inline-annotations

Conversation

@heejaechang

@heejaechang heejaechang commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add missing -> None annotations to AttemptManager.__init__ and BaseRetrying.__init__.
  • Declare the non-trivial re.Pattern[str] | None shape of retry_if_exception_message.match.
  • Normalize union ordering required by the repository's configured Ruff rules.
  • Preserve runtime behavior and all existing Any annotations.

Annotation audit

The accepted Tenacity 8.1.0 benchmark patch was re-audited against current main. Inline field declarations were removed when their type was already evident from:

  • literals (NAME, REPR_FIELDS)
  • conversions such as float(...) and _utils.to_seconds(...)
  • assignments from typed parameters or varargs
  • direct singleton constructors

Those declarations improved VerifyTypes scoring but did not add an independent API contract or checker guarantee. The retained match annotation documents and checks a conditional public field union that is not represented by one simple assignment source.

Validation

  • uv run poe all — lint, strict mypy, 172 tests, doctests, and HTML docs passed
  • uv run --with pyright --with-editable . pyright --verifytypes tenacity --ignoreexternal — 63.3% (210/332 known exports), measured as informational evidence rather than an optimization target
  • Annotation-stripped AST comparison against main — executable AST unchanged

Port decisions

The Tornado sleep annotation and RetryCallState.__repr__ return type are already present on main. Existing Any annotations remain unchanged. The benchmark's get_callback_name(object), Future.construct(..., object, ...), and broad Callable[..., bool] changes are omitted because current upstream typing is stricter or more precise.

heejaechang and others added 3 commits August 5, 2026 13:46
Port the accepted annotation-only completeness improvements from Tenacity 8.1.0 while adapting them to current main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the existing public annotations for RetryCallState arguments and results rather than narrowing them to object-based container types.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep only constructor return annotations and the non-trivial regex field union; remove declarations already evident from literals, conversions, typed parameters, varargs, and singleton constructors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jd
jd force-pushed the heejaechang-port-inline-annotations branch from 50543f4 to 25de3f6 Compare August 5, 2026 11:46
@mergify

mergify Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-05 11:47 UTC · Rule: default · triggered by rule autoqueue
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-05 11:47 UTC · at 25de3f6e0b18d8d5d3eb859497fc5937d0936819 · squash

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

Required conditions to merge

@mergify
mergify Bot merged commit 6fec225 into jd:main Aug 5, 2026
9 checks passed
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.

2 participants