How to extend `warnings.deprecated`?

Open
#2,256 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python

Research direction

Start with the issue's warnings.deprecated and TYPE_CHECKING examples, then review how the typing specification represents deprecation metadata and decorator signatures. Done means reaching an agreed design for accepting packaging.Version metadata while preserving correct type-system behavior; the issue does not name a specific file or test.

Written by the indexing model from the issue text.

Description

topic: documentation

We need more metadata for our deprecation decorator, but the spec doesn’t say how deprecated marks an API. So the only way to mark something as deprecated it is by creating an API with the same exact signature and replace it with warnings.deprecated at the type level:

if TYPE_CHECKING:
    from warnings import deprecated
else:
    def deprecated[F](msg: str) -> Callable[[F], F]: ...

We need to define deprecated(msg: str, version: packaging.Version) and have it work with the type system. How?

Dominant language
Python
Stars
1.8k
Forks
302
Avg merge
23h
Merged PRs (30d)
8

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/typing

All issues in python/typing

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.