Skip to content

Commit 5b496e9

Browse files
committed
inspect: Implement iscoroutinefunction and iscoroutine.
Signed-off-by: Damien George <[email protected]>
1 parent 2665047 commit 5b496e9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Diff for: python-stdlib/inspect/inspect.py

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def isgenerator(obj):
2525
return isinstance(obj, type((_g)()))
2626

2727

28+
# In MicroPython there's currently no way to distinguish between generators and coroutines.
29+
iscoroutinefunction = isgeneratorfunction
30+
iscoroutine = isgenerator
31+
32+
2833
class _Class:
2934
def meth():
3035
pass

Diff for: python-stdlib/inspect/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.2")
1+
metadata(version="0.1.3")
22

33
module("inspect.py")

Diff for: python-stdlib/inspect/test_inspect.py

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def test_isgeneratorfunction(self):
4444
def test_isgenerator(self):
4545
self._test_is_helper(inspect.isgenerator, entities[2])
4646

47+
def test_iscoroutinefunction(self):
48+
self._test_is_helper(inspect.iscoroutinefunction, entities[1])
49+
50+
def test_iscoroutine(self):
51+
self._test_is_helper(inspect.iscoroutine, entities[2])
52+
4753
def test_ismethod(self):
4854
self._test_is_helper(inspect.ismethod, entities[5])
4955

0 commit comments

Comments
 (0)