python / python/typeshed

`@deprecated` overloads for invalid uses of `contextlib.ContextDecorator`?

Open
#12,881 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

https://github.com/python/cpython/issues/125862 describes some problems that can occur when applying a ContextDecorator to an async function or a generator function. Is it reasonable to add overloads returning Never for such cases, so that typecheckers can warn people?

The code in question runs, but it doesn't do anything useful let alone have the expected effect, so I'd love to warn about it sooner than CPython will release a fix.

Contributor guide

Open the contributing guide

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.

Research direction

Start by reading the linked CPython issue and the existing ContextDecorator stubs in typeshed. Determine how async and generator functions are represented, then add overloads returning Never if appropriate and verify that type checkers warn for those uses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.