Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@asynccontextmanager decorated functions are not callable like @contextmanager #82596

Closed
fried mannequin opened this issue Oct 8, 2019 · 5 comments
Closed

@asynccontextmanager decorated functions are not callable like @contextmanager #82596

fried mannequin opened this issue Oct 8, 2019 · 5 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@fried
Copy link
Mannequin

fried mannequin commented Oct 8, 2019

BPO 38415
Nosy @ambv, @serhiy-storchaka, @1st1, @graingert, @fried
PRs
  • bpo-38415 @asynccontextmanager as decorators like @contextmanager #16667
  • bpo-38415: Remove redundant AsyncContextDecorator.__call__ override from _AsyncG… #30233
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-09-23.21:37:12.435>
    created_at = <Date 2019-10-08.20:45:49.255>
    labels = ['type-feature', 'library', '3.11']
    title = '@asynccontextmanager decorated functions are not callable like @contextmanager'
    updated_at = <Date 2022-02-26.12:05:50.881>
    user = 'https://github.com/fried'

    bugs.python.org fields:

    activity = <Date 2022-02-26.12:05:50.881>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-09-23.21:37:12.435>
    closer = 'lukasz.langa'
    components = ['Library (Lib)']
    creation = <Date 2019-10-08.20:45:49.255>
    creator = 'fried'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38415
    keywords = ['patch']
    message_count = 5.0
    messages = ['354232', '402528', '402529', '409056', '414094']
    nosy_count = 5.0
    nosy_names = ['lukasz.langa', 'serhiy.storchaka', 'yselivanov', 'graingert', 'fried']
    pr_nums = ['16667', '30233']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue38415'
    versions = ['Python 3.11']

    @fried
    Copy link
    Mannequin Author

    fried mannequin commented Oct 8, 2019

    The standard contextmanager decorator produces a wrapper that itself can be used as a decorator

    @contextmanager
    def some_context():
        ...
        yield
    
    @some_context()
    def some_function():
        # we are inside a with some_context() now. 
        ...
    
    
    

    When I created a version of asynccontextmanager internally before it was available in the stdLib I copied this behavior and I have people internally to facebook using this behavior, Was there a reason this behavior was not replicated to asynccontextmanager?

    I have a diff an tests to add

    @fried fried mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Oct 8, 2019
    @ambv
    Copy link
    Contributor

    ambv commented Sep 23, 2021

    New changeset 86b833b by Jason Fried in branch 'main':
    bpo-38415: Allow using @asynccontextmanager-made ctx managers as decorators (GH-16667)
    86b833b

    @ambv
    Copy link
    Contributor

    ambv commented Sep 23, 2021

    Look, not even 23 months to land this thing!

    Thanks, Jason! ✨ 🍰 ✨

    @ambv ambv added 3.11 only security fixes and removed 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes labels Sep 23, 2021
    @ambv ambv closed this as completed Sep 23, 2021
    @graingert
    Copy link
    Mannequin

    graingert mannequin commented Dec 23, 2021

    actually it was already done in 13 months!

    @serhiy-storchaka
    Copy link
    Member

    New changeset b57dbe5 by Thomas Grainger in branch 'main':
    bpo-38415: Remove redundant AsyncContextDecorator.__call__ override from _AsyncGeneratorContextManager (GH-30233)
    b57dbe5

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants