MagicStack / MagicStack/contextvars

Typing annotations not working as intented

Open
#15 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
90
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Hi! I've found a difference between the built-in version of contextvars and this backport.

Generic type annotations are not supported. This works in python:

```
c: contextvars.ContextVar[str] = contextvars.ContextVar('test')
```

but not in this backport. It caused a pretty surprising issue with celery https://github.com/celery/celery/issues/6534

Would it be possible to fix it?

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.

Research direction

Compare the backport's ContextVar behavior with Python's built-in contextvars using the generic annotation example from the issue. Add regression coverage for ContextVar[str] annotations and verify that the Celery-related usage works as expected; done means the backport accepts the same annotation form.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.