/pydeprecate:sunsetfrom pydeprecate
Scans Python projects for deprecation patterns and suggests pyDeprecate conversions or implements API deprecations with explicit versions. Useful for managing deprecation windows without breaking existing callers.
Ships in pydeprecate. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Verified against pyDeprecate >=0.12 (the three most recent minor releases plus the development line); check deprecate.__version__ first — identifiers newer than the floor carry a since-note, and older releases lack them.
Implement the requested migration while keeping existing callers working during the deprecation window. A preview or advice request stays read-only.
For a scan, assessment or adoption request, inspect the requested project scope and recommend conversions without changing code or dependencies.
Search source and tests for:
warnings.warn and DeprecationWarning/FutureWarning.These are candidates, not proof that every warning or wrapper is a deprecation. Exclude generated/vendored code unless requested. Record coverage limits for dynamic patterns.
For each candidate, inspect its callers and tests. Compare its observable contract with the installed pyDeprecate version. If the package is absent, compare with a specifically identified available release.
Read matching API documentation/source before claiming support. Check warning category, message, frequency, stack location, timing, conditional behavior, signature/binding, forwarding side effects, descriptor/async behavior, and static-checker expectations.
A similar decorator name is insufficient. Replacing PEP 702 decorators can lose static type-checker diagnostics even when runtime warnings look equivalent.
Return a compact table with these fields:
convert, keep, or needs decision).Recommend convert only where the behavior is supported and useful. Keep simple standard-library warning-only patterns when pyDeprecate adds no benefit.
Ordinary operational warnings, unavailable source, unknown deadlines, unverified APIs or behavior that cannot be preserved stay keep/needs decision, with reasons. Never infer release dates from a version-looking string unrelated to the deprecation.
Conclude with prioritized opportunities and required dependency/version decisions. If pyDeprecate is absent, disclose that adoption adds a dependency. Do not install it during a scan.
An explicit conversion request authorizes the selected implementation work, not unrelated candidates. Resolve material compatibility changes before applying it.
Present the proposed conversion set and stop before the first edit. Proceed only after the user confirms that set. Continue with the contract and verification below for approved conversions.
deprecated_in, and remove_in.
deprecated_in < remove_in before editing.pyDeprecate; the import name is deprecate.deprecate.__version__ and import location before choosing APIs.Before choosing versions, look for a [tool.pydeprecate.policy] table in the nearest pyproject.toml. Search the directory being edited and up to two parents. This is the same lookup pydeprecate policy performs (since v0.13; older releases read no such table, so on them treat this section as absent and ask).
Keys are the rule slugs:
| Key | Accepted value |
|---|---|
min-grace | Use a quoted dotted delta: "0.3" means three minors, "1.0" means one major, and "0.0.2" means two patches. A one-key unit table such as { minor = 3 } also works. Use a bare TOML false to disable it. |
message-required | Use a boolean. |
No table means the built-in defaults min-grace = "0.3" and message-required = true. Name the source of each value when reporting.
Apply the policy when filling the contract:
deprecated_in is the release the user names, or the project's next release derived from its current version.
deprecate.__version__ is pyDeprecate's own, not the consumer's: read the consumer's version module or distribution metadata.remove_in is deprecated_in advanced by the min-grace window as one clean bump of a single component with everything below reset.
1.2 + "0.3" gives 1.5, 1.2 + "1.0" gives 2.0, and 1.2.4 + "0.0.2" gives 1.2.6.1.2 → 2.0 clears "0.3").1.2 → 2.3 or 1.2 → 1.3.1.min-grace = false the window imposes nothing. Still ask for remove_in instead of inventing one.message-required = true, every new wrapper must carry a callable or module target, a non-empty args_mapping/attrs_mapping, or a custom message_template.
TargetMode.NOTIFY wrapper therefore needs message_template naming the replacement or the reason.deprecated_instance whose target is a data object (since v0.16), unless it has an attrs_mapping.Present the derived versions with the rule and source behind each before the first edit. The user confirms or overrides them.
After editing, run pydeprecate policy <path> (requires pyDeprecate[audit], plus [cli] before v0.15; since v0.13) or validate_deprecation_policy(module, min_grace="0.3", message_required=True) (since v0.13) with the table's values; map min-grace = false to min_grace=None, since the Python API rejects the boolean false value. The function never reads pyproject.toml. Expect zero violations.
If the consumer package cannot be imported in the available environment, check whether pydeprecate policy --help lists --static (since v0.16). When it does, run pydeprecate policy --static <path> as a fallback. The shipped pydeprecate-policy-static and pydeprecate-expiry-static pre-commit hooks (since v0.16) use the same static scans.
A static scan reports recognized unresolved forms as gaps without failing. It can miss forms without a gap, including wrappers created in loops or through getattr, importlib or exec. It can also misclassify bare target names imported from outside the package.
Report these coverage limits and run the import-mode check when the dependencies are available. If the package cannot be imported and pydeprecate policy --help does not list --static, report that the static fallback is unavailable. In that case, also report that the policy could not be machine-checked.
Before v0.13 report that the policy was applied by hand and could not be machine-checked.
| Intent | Form | Body |
|---|---|---|
| Function/method rename or move | @deprecated(target=replacement, ...) | Forwarded calls bypass the old body |
| Warn without forwarding | @deprecated(target=TargetMode.NOTIFY, ...) | Keep working implementation |
| Rename/drop arguments on a surviving API | TargetMode.ARGS_REMAP, args_mapping={"old": "new"} or {"old": None} | Keep new implementation |
| Class rename | deprecated_class(target=Replacement, ...) | Preserve constructor compatibility |
| Object alias | deprecated_instance(...); deprecated_instance(old_obj, target=new_obj, ...) to serve the replacement under the old name (since v0.16; on older releases wrap the replacement itself: deprecated_instance(new_obj, name="OLD_NAME", ...)) | Inspect proxy behavior needed by callers; type checks and writes follow the replacement |
| Attribute-only migration | deprecated_class(target=TargetMode.ATTRS_REMAP, attrs_mapping=..., ...) | Preserve unaffected class behavior |
| Final release before removal | add as_exception=True (since v0.14) to the existing wrapper | Body unreachable — the call raises |
Use explicit modes, never legacy target=True / target=None sentinels. Attribute mappings belong on deprecated_class, not deprecated. Keep old calling conventions, including positional arguments, defaults and keyword conflicts; a rename must not silently change binding.
For properties, descriptors, async/generators, modules or stacked wrappers, read the relevant installed implementation/release documentation before editing.
A deprecated generator or async generator stub must itself contain a yield statement. A synchronous generator can use yield from (); an async generator must use a plain yield statement, for example in an unreachable branch. A stub that only does return void(...) is a plain function. It gets a plain wrapper, warns at call time and is not a generator function.
For a generator or async generator wrapper (since v0.15), the warning, the num_warns budget and the as_exceptions() / as_exception=True error fire at the first iteration step. This means next or async for, not the call. Earlier releases warn at call time and a wrapped async generator fails isgeneratorfunction-style checks.
A generator never iterated never warns; tests must wrap the iteration in pytest.warns(). Property forwarding is not supported by the decorator: delegate inside the accessor for warn-only property migrations.
Preserve unrelated decorators and future deprecation layers. Check skip_if: it can execute the original body instead of forwarding.
A deprecation that is past polite warning can refuse the call instead. as_exception=True (since v0.14; no equivalent before v0.14) raises DeprecatedError carrying the same message. It never invokes the target and never runs the source body.
Use it as the warn -> raise -> delete middle step, one release before removal. Record in the changelog that the symbol now raises.
It ignores num_warns (every call raises) and is not silenced by stream=None; skip_if still suppresses it.
The process-wide deprecate.AS_EXCEPTIONS (seeded from DEPRECATE_AS_EXCEPTIONS) is the consumer's switch, not the library's: do not set it in library code. When the user only wants every FutureWarning to fail their run, point at -W error::FutureWarning instead.
For block-scoped fatal handling, use deprecate.as_exceptions() to make deprecations fatal for a block. Use deprecate.as_exceptions(False) to exempt a block from a strict run.
Both restore the previous setting on exit, including exceptions, and nested scopes compose. An explicit wrapper as_exception=True remains fatal inside a disabled scope.
The scope is local to the current thread and asyncio task and never modifies deprecate.AS_EXCEPTIONS. Do not read that attribute to detect a scope.
As a decorator, it supports plain synchronous functions only. An async def, generator or async-generator function raises a TypeError at decoration, so use with deprecate.as_exceptions(): inside its body.
Like the global itself, as_exceptions() is the consumer's switch for application or test code. Library code must not use as_exceptions(False) to escape a caller's strict run. as_exception=False on a wrapper (singular) never escapes one.
as_exceptions() is available since v0.15. On an older install, check that the installed deprecate module provides it before using it.
On an installed release that has deprecate.AS_EXCEPTIONS but not the helper, preserve the previous value with try/finally:
import deprecate
if hasattr(deprecate, "as_exceptions"):
with deprecate.as_exceptions():
# Run the application or test code that should reject deprecations.
pass
elif hasattr(deprecate, "AS_EXCEPTIONS"):
_previous = deprecate.AS_EXCEPTIONS
deprecate.AS_EXCEPTIONS = True
try:
# Run the application or test code that should reject deprecations.
pass
finally:
deprecate.AS_EXCEPTIONS = _previous
else:
raise RuntimeError("This pyDeprecate version does not support fatal deprecations.")
Provide migration guidance through the replacement/mapping and, when needed, message_template. Verify supported template fields rather than inventing a message= argument.
Type checkers and IDEs flag a deprecation only through warnings.deprecated (Python 3.13+) or typing_extensions.deprecated. pyDeprecate's decorators stay invisible to them on every release.
When the user also wants an editor strikethrough or a mypy/pyright gate, stack a PEP 702 marker directly above the pyDeprecate decorator: use @warnings.deprecated("Use new_name instead.", category=None) on Python 3.13+ and @typing_extensions.deprecated("Use new_name instead.", category=None) on Python 3.12 and earlier:
category=None; otherwise every call warns twice.deprecated is not shadowed.Over deprecated_class both mypy and pyright flag the alias, and before v0.14 the marker leaked onto the replacement class.
To list symbols deprecated with that decorator alone, use find_deprecation_wrappers(..., include_pep702=True) (since v0.14; no equivalent before v0.14). Those rows carry no versions and are the ones with row.pep702_message is not None. Keep them out of expiry and policy decisions.
as_exception=True, assert that it raises instead.pyDeprecate[audit] (plus [cli] before v0.15); Python expiry and policy helpers need [audit]. Verify commands against the loaded version; the pydeprecate policy subcommand exists since v0.13 only. Follow the project's dependency workflow if extras are missing.deprecate.audit.find_deprecation_wrappers_static returns a frozen StaticScanResult (both since v0.16, like pydeprecate policy --static).validate_deprecation_policy with the project's policy values, or to validate_deprecation_expiry with an explicit current_version when .version is missing..gaps, even when .wrappers or the findings are empty.[tool.pydeprecate.policy] table and the project's documented cadence decide.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 skills in this plugin
npx claudepluginhub borda/pydeprecate --plugin pydeprecateOther plugins' skills for the same job