Add PEP 702 static-analysis deprecation overloads for size parameter — Closes #136#137
Merged
conradbzura merged 1 commit intowool-labs:mainfrom Mar 28, 2026
Conversation
Two @overload declarations decorated with @deprecated from typing_extensions cover ephemeral and hybrid modes. Type checkers now flag WorkerPool(size=...) at static analysis time, complementing the existing runtime DeprecationWarning.
conradbzura
commented
Mar 28, 2026
Contributor
Author
conradbzura
left a comment
There was a problem hiding this comment.
No issues found. The diff is clean — overload stacking order, import placement, and signature design all look correct.
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.
Summary
Add two
@overloaddeclarations decorated with@deprecatedfromtyping_extensionstoWorkerPool.__init__, covering ephemeral and hybrid modes. Type checkers (pyright, mypy) now emit a deprecation diagnostic whenWorkerPool(size=...)appears in source, complementing the runtimeDeprecationWarningintroduced in #135.Closes #136
Proposed changes
Deprecated overloads for
sizeparameterImport
deprecatedfromtyping_extensionsand add two new@overloadstubs after the existing three overloads onWorkerPool.__init__:size: intwithdiscovery: None(mirrors the existing ephemeralspawnoverload).size: intwithdiscovery: DiscoveryLike | Factory[DiscoveryLike](mirrors the existing hybridspawnoverload).Both are decorated with
@deprecated("Use 'spawn' instead of 'size'."). The durable mode has nospawn/sizeparameter, so no deprecated overload is needed there.sizeis declared as a requiredint(no default) because callers always pass it explicitly — a default would weaken the overload's discriminating power and match calls that should resolve to the non-deprecatedspawnoverloads.No runtime behavior changes. The
@deprecateddecorator on@overloadstubs is a static-analysis-only annotation; the existing runtime deprecation path is untouched.