This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Support functools.partial in inspect.is*function() checks
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, asvetlov, pablogsal, yselivanov
Priority: normal Keywords: patch

Created on 2018-10-04 07:29 by asvetlov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9903 merged pablogsal, 2018-10-15 22:14
Messages (5)
msg327039 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-10-04 07:29
isfunction() processes both `isfunction(func)` and `isfunction(partial(func, arg))` correctly.

But `iscoroutinefunction()` misses this functionality.

We can implement it easy by adding a check for `isinstance(func, partial)` and applying a coroutine check for `func.func`.

Also, we can do the same for `isgeneratorfunction()` and `isasyncgenfunction()`.

The patch looks easy and straightforward.

Yuri, what do you think about?
msg327056 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-10-04 15:32
I think the fact that `inspect.isfunction` recognizes partials is a very strong argument to enable inspect.iscoroutinefunction to do so as well.  

This is a backwards incompatible change though, strictly speaking.
msg327057 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-10-04 15:33
Feel free to work on the PR.  If we want to push this to 3.8 we should do that now and have enough time for it to be tested.
msg328538 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-10-26 11:19
New changeset 7cd25434164882c2093ea41ccfc7b95a05cd5cbd by Pablo Galindo in branch 'master':
bpo-34890: Make iscoroutinefunction, isgeneratorfunction and isasyncgenfunction work with functools.partial (GH-9903)
https://github.com/python/cpython/commit/7cd25434164882c2093ea41ccfc7b95a05cd5cbd
msg413171 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2022-02-13 06:36
See https://bugs.python.org/issue46722 for a concern about this change.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79071
2022-02-13 06:36:40Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg413171
2018-10-26 11:23:04pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-10-26 11:19:19pablogsalsetnosy: + pablogsal
messages: + msg328538
2018-10-15 22:14:22pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request9265
2018-10-04 15:33:50yselivanovsetmessages: + msg327057
2018-10-04 15:32:54yselivanovsetmessages: + msg327056
2018-10-04 07:29:56asvetlovcreate