Nick Coghlan <ncogh...@gmail.com> added the comment:

You are correct that this proposal is technically rejected, rather than being a 
true duplicate of the AsyncContextManager addition.

The core problem with the automatic inference idea is that it isn't possible 
for the standard library to reliably distinguish at decoration time between 
"synchronous function that happens to return an awaitable" and "coroutine 
factory function written as a synchronous function that should nevertheless be 
treated like a coroutine function".

That ambiguity doesn't exist when ContextDecorator and AsyncContextDecorator 
are applied to distinct helper functions.

Within a given codebase, you may be able to write a "coroutine argument 
detection" function that is robust enough for that particular codebase (and 
iscoroutinefunction() may even be adequate for that purpose), in which case 
ContextDecorator and AsyncContextDecorator provide the building blocks for 
implementing the two halves of the solution, leaving only the auto-switching 
code as project specific.

----------
resolution: duplicate -> rejected

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37398>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to