Skip to content

Accept callable stop conditions in combinator types - #760

Closed
shreyans-chowdry wants to merge 1 commit into
jd:mainfrom
shreyans-chowdry:fix-callable-stop-combinator-types
Closed

shreyans-chowdry wants to merge 1 commit into
jd:mainfrom
shreyans-chowdry:fix-callable-stop-combinator-types

Conversation

@shreyans-chowdry

Copy link
Copy Markdown

Custom stop functions are accepted by Retrying(stop=...) and work at runtime inside stop_any and stop_all, but the two combinator constructors only annotate stop_base. This makes otherwise valid combinations fail type checking.

Use the existing StopBaseT alias for their arguments, consistent with BaseRetrying. The regression test combines a typed custom attempt-limit function with stop_after_delay, checks both combinators' results, and is included in the repository mypy run. Before the annotation change, mypy reports two argument-type errors in that test. Afterward it passes; runtime behavior is unchanged.

Validation on Python 3.12.4/macOS:

  • Full suite: 186 passed, 15 subtests passed.
  • Repository mypy and Ruff lint/format: pass.
  • Strict Sphinx doctests: 35 passed.
  • Strict Sphinx HTML build: passes.

Includes a release note. Investigated, implemented, and tested with OpenAI Codex assistance; found during source review, not a production incident.

@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

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