-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
Sometimes, mostly in tests, I write something like
from contextvars import ContextVar
var = ContextVar('var')
def test_a():
token = var.set('new val')
do_stuff()
var.reset(token)
It looks a little cumbersome, the support for with var:
would be awesome:
def test_b():
with var.set('new val'):
do_stuff()
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
maxfischer2781 and akshaykarthik
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement