Typing annotations not working as intented

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

Nobody has claimed this yet.

Assessment

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

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.

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?

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

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 MagicStack/contextvars

All issues in MagicStack/contextvars

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.