Skip to content

Add PEP 702 static-analysis deprecation overloads for size parameter — Closes #136#137

Merged
conradbzura merged 1 commit intowool-labs:mainfrom
conradbzura:136-pep702-deprecation-overloads
Mar 28, 2026
Merged

Add PEP 702 static-analysis deprecation overloads for size parameter — Closes #136#137
conradbzura merged 1 commit intowool-labs:mainfrom
conradbzura:136-pep702-deprecation-overloads

Conversation

@conradbzura
Copy link
Copy Markdown
Contributor

Summary

Add two @overload declarations decorated with @deprecated from typing_extensions to WorkerPool.__init__, covering ephemeral and hybrid modes. Type checkers (pyright, mypy) now emit a deprecation diagnostic when WorkerPool(size=...) appears in source, complementing the runtime DeprecationWarning introduced in #135.

Closes #136

Proposed changes

Deprecated overloads for size parameter

Import deprecated from typing_extensions and add two new @overload stubs after the existing three overloads on WorkerPool.__init__:

  • Ephemeral modesize: int with discovery: None (mirrors the existing ephemeral spawn overload).
  • Hybrid modesize: int with discovery: DiscoveryLike | Factory[DiscoveryLike] (mirrors the existing hybrid spawn overload).

Both are decorated with @deprecated("Use 'spawn' instead of 'size'."). The durable mode has no spawn/size parameter, so no deprecated overload is needed there.

size is declared as a required int (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-deprecated spawn overloads.

No runtime behavior changes. The @deprecated decorator on @overload stubs is a static-analysis-only annotation; the existing runtime deprecation path is untouched.

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 conradbzura marked this pull request as ready for review March 28, 2026 12:45
Copy link
Copy Markdown
Contributor Author

@conradbzura conradbzura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. The diff is clean — overload stacking order, import placement, and signature design all look correct.

@conradbzura conradbzura self-assigned this Mar 28, 2026
@conradbzura conradbzura merged commit 660a76b into wool-labs:main Mar 28, 2026
4 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.

Add PEP 702 static-analysis deprecation overloads for size parameter

1 participant