From 9fdf740025e1d3f6cb48c3d7aa6eb1e45f284361 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 00:47:38 +0000 Subject: [PATCH 01/14] feat: support iscoroutinefunction introspection --- mypyc/codegen/emitmodule.py | 7 +++++++ mypyc/ir/func_ir.py | 4 ++++ mypyc/irbuild/prepare.py | 9 ++++++++- mypyc/lib-rt/pythonsupport.c | 16 ++++++++++++++++ mypyc/test-data/run-async.test | 13 +++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index b8a19ac1d669..38b4692169ec 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -954,6 +954,13 @@ def generate_module_def(self, emitter: Emitter, module_name: str, module: Module emitter.emit_lines(f"if (unlikely(!{type_struct}))", " goto fail;") emitter.emit_lines("if (CPyGlobalsInit() < 0)", " goto fail;") + # Patch async native functions so they're recognized as coroutines + for fn in module.functions: + if fn.decl.is_async and fn.class_name is None: + emitter.emit_line(f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");') + emitter.emit_line("if (!func) goto fail;") + emitter.emit_line("if (!CPyPatchAsyncCode(func)) { Py_DECREF(func); goto fail; }") + emitter.emit_line("Py_DECREF(func);") self.generate_top_level_call(module, emitter) diff --git a/mypyc/ir/func_ir.py b/mypyc/ir/func_ir.py index bf21816fb07a..6130b83b95e4 100644 --- a/mypyc/ir/func_ir.py +++ b/mypyc/ir/func_ir.py @@ -140,6 +140,7 @@ def __init__( is_prop_setter: bool = False, is_prop_getter: bool = False, implicit: bool = False, + is_async: bool = False, ) -> None: self.name = name self.class_name = class_name @@ -159,6 +160,7 @@ def __init__( # If True, not present in the mypy AST and must be synthesized during irbuild # Currently only supported for property getters/setters self.implicit = implicit + self.is_async = is_async # This is optional because this will be set to the line number when the corresponding # FuncIR is created @@ -204,6 +206,7 @@ def serialize(self) -> JsonDict: "is_prop_setter": self.is_prop_setter, "is_prop_getter": self.is_prop_getter, "implicit": self.implicit, + "is_async": self.is_async, } # TODO: move this to FuncIR? @@ -226,6 +229,7 @@ def deserialize(cls, data: JsonDict, ctx: DeserMaps) -> FuncDecl: data["is_prop_setter"], data["is_prop_getter"], data["implicit"], + data["is_async"], ) diff --git a/mypyc/irbuild/prepare.py b/mypyc/irbuild/prepare.py index 98ff348d8c30..ac0be7fffbd2 100644 --- a/mypyc/irbuild/prepare.py +++ b/mypyc/irbuild/prepare.py @@ -185,7 +185,14 @@ def prepare_func_def( else (FUNC_CLASSMETHOD if fdef.is_class else FUNC_NORMAL) ) sig = mapper.fdef_to_sig(fdef, options.strict_dunders_typing) - decl = FuncDecl(fdef.name, class_name, module_name, sig, kind) + decl = FuncDecl( + fdef.name, + class_name, + module_name, + sig, + kind=kind, + is_async=fdef.is_coroutine, + ) mapper.func_to_decl[fdef] = decl return decl diff --git a/mypyc/lib-rt/pythonsupport.c b/mypyc/lib-rt/pythonsupport.c index 90fb69705a00..8873f3c1b057 100644 --- a/mypyc/lib-rt/pythonsupport.c +++ b/mypyc/lib-rt/pythonsupport.c @@ -103,4 +103,20 @@ CPyLong_AsSsize_tAndOverflow_(PyObject *vv, int *overflow) } +// CPy support for async functions: patch code object to include CO_COROUTINE +PyObject* CPyPatchAsyncCode(PyObject* func) { + PyObject* code = PyObject_GetAttrString(func, "__code__"); + if (!code) { + return NULL; + } + PyCodeObject* codeobj = (PyCodeObject*)code; + codeobj->co_flags |= CO_COROUTINE; + int res = PyObject_SetAttrString(func, "__code__", code); + Py_DECREF(code); + if (res < 0) { + return NULL; + } + Py_INCREF(func); + return func; +} #endif diff --git a/mypyc/test-data/run-async.test b/mypyc/test-data/run-async.test index 58b690a944af..7141f052f4f1 100644 --- a/mypyc/test-data/run-async.test +++ b/mypyc/test-data/run-async.test @@ -561,3 +561,16 @@ def test_bool() -> None: [file asyncio/__init__.pyi] def run(x: object) -> object: ... + +[case testIsCoroutineFunction] +import asyncio +import inspect + +async def foo(): + return 1 + +def test_asyncio_iscoroutinefunction(): + assert asyncio.iscoroutinefunction(foo) is True, "foo should be recognized as coroutine function" + +def test_inspect_iscoroutinefunction(): + assert inspect.iscoroutinefunction(foo) is True, "foo should be recognized as coroutine function" From 352d0d1f7604464b398c9a43fc7d6e16066eff4e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 00:51:11 +0000 Subject: [PATCH 02/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypyc/codegen/emitmodule.py | 4 +++- mypyc/irbuild/prepare.py | 9 +-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index ad7428b002dd..c32c735ddfa2 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -989,7 +989,9 @@ def emit_module_exec_func( # Patch async native functions so they're recognized as coroutines for fn in module.functions: if fn.decl.is_async and fn.class_name is None: - emitter.emit_line(f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");') + emitter.emit_line( + f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' + ) emitter.emit_line("if (!func) goto fail;") emitter.emit_line("if (!CPyPatchAsyncCode(func)) { Py_DECREF(func); goto fail; }") emitter.emit_line("Py_DECREF(func);") diff --git a/mypyc/irbuild/prepare.py b/mypyc/irbuild/prepare.py index 288cbeea95c0..53491b0e3889 100644 --- a/mypyc/irbuild/prepare.py +++ b/mypyc/irbuild/prepare.py @@ -185,14 +185,7 @@ def prepare_func_def( else (FUNC_CLASSMETHOD if fdef.is_class else FUNC_NORMAL) ) sig = mapper.fdef_to_sig(fdef, options.strict_dunders_typing) - decl = FuncDecl( - fdef.name, - class_name, - module_name, - sig, - kind=kind, - is_async=fdef.is_coroutine, - ) + decl = FuncDecl(fdef.name, class_name, module_name, sig, kind=kind, is_async=fdef.is_coroutine) mapper.func_to_decl[fdef] = decl return decl From 6073ea5bf7891ec5b73b833688fb2de0a1d322e4 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 00:55:46 +0000 Subject: [PATCH 03/14] chore: rename c func --- mypyc/codegen/emitmodule.py | 2 +- mypyc/lib-rt/pythonsupport.c | 2 +- mypyc/lib-rt/pythonsupport.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 38b4692169ec..519047b0dc64 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -959,7 +959,7 @@ def generate_module_def(self, emitter: Emitter, module_name: str, module: Module if fn.decl.is_async and fn.class_name is None: emitter.emit_line(f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");') emitter.emit_line("if (!func) goto fail;") - emitter.emit_line("if (!CPyPatchAsyncCode(func)) { Py_DECREF(func); goto fail; }") + emitter.emit_line("if (!CPyFunc_SetCoroFlag(func)) { Py_DECREF(func); goto fail; }") emitter.emit_line("Py_DECREF(func);") self.generate_top_level_call(module, emitter) diff --git a/mypyc/lib-rt/pythonsupport.c b/mypyc/lib-rt/pythonsupport.c index 8873f3c1b057..ea0b29465732 100644 --- a/mypyc/lib-rt/pythonsupport.c +++ b/mypyc/lib-rt/pythonsupport.c @@ -104,7 +104,7 @@ CPyLong_AsSsize_tAndOverflow_(PyObject *vv, int *overflow) // CPy support for async functions: patch code object to include CO_COROUTINE -PyObject* CPyPatchAsyncCode(PyObject* func) { +PyObject* CPyFunc_SetCoroFlag(PyObject* func) { PyObject* code = PyObject_GetAttrString(func, "__code__"); if (!code) { return NULL; diff --git a/mypyc/lib-rt/pythonsupport.h b/mypyc/lib-rt/pythonsupport.h index 7019c12cf59a..2b201176b59e 100644 --- a/mypyc/lib-rt/pythonsupport.h +++ b/mypyc/lib-rt/pythonsupport.h @@ -474,5 +474,8 @@ CPyCoro_GetAwaitableIter(PyObject *o) return NULL; } +static PyObject * +CPyFunc_SetCoroFlag(PyObject* func) + #endif From 77c4df4abade579825ecaa4f5a46151167e52d3d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 00:57:09 +0000 Subject: [PATCH 04/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypyc/codegen/emitmodule.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 9dbbd8ef6444..d0457c6102a2 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -993,7 +993,9 @@ def emit_module_exec_func( f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) emitter.emit_line("if (!func) goto fail;") - emitter.emit_line("if (!CPyFunc_SetCoroFlag(func)) { Py_DECREF(func); goto fail; }") + emitter.emit_line( + "if (!CPyFunc_SetCoroFlag(func)) { Py_DECREF(func); goto fail; }" + ) emitter.emit_line("Py_DECREF(func);") self.generate_top_level_call(module, emitter) From 2ff06e567919637f64604b7a96d2979a9c5a31a5 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 01:02:52 +0000 Subject: [PATCH 05/14] fix: missing ; --- mypyc/lib-rt/pythonsupport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/lib-rt/pythonsupport.h b/mypyc/lib-rt/pythonsupport.h index 2b201176b59e..8b66e6f42c0c 100644 --- a/mypyc/lib-rt/pythonsupport.h +++ b/mypyc/lib-rt/pythonsupport.h @@ -475,7 +475,7 @@ CPyCoro_GetAwaitableIter(PyObject *o) } static PyObject * -CPyFunc_SetCoroFlag(PyObject* func) +CPyFunc_SetCoroFlag(PyObject* func); #endif From ab903ef9a76aa5262351d6c0081ccd06d03778e5 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 01:22:14 +0000 Subject: [PATCH 06/14] fix: name conflict --- mypyc/codegen/emitmodule.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index d0457c6102a2..90807c2a3eba 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -990,13 +990,13 @@ def emit_module_exec_func( for fn in module.functions: if fn.decl.is_async and fn.class_name is None: emitter.emit_line( - f'PyObject *func = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' + f'PyObject *func_temp = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) - emitter.emit_line("if (!func) goto fail;") + emitter.emit_line("if (!func_temp) goto fail;") emitter.emit_line( - "if (!CPyFunc_SetCoroFlag(func)) { Py_DECREF(func); goto fail; }" + "if (!CPyFunc_SetCoroFlag(func_temp)) { Py_DECREF(func_temp); goto fail; }" ) - emitter.emit_line("Py_DECREF(func);") + emitter.emit_line("Py_DECREF(func_temp);") self.generate_top_level_call(module, emitter) From 88e6543ff6bdbd47e8f95c840e4c997a6dab04f4 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 03:13:18 +0000 Subject: [PATCH 07/14] fix: name already defined --- mypyc/codegen/emitmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 90807c2a3eba..c9fff11591f9 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -990,7 +990,7 @@ def emit_module_exec_func( for fn in module.functions: if fn.decl.is_async and fn.class_name is None: emitter.emit_line( - f'PyObject *func_temp = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' + f'PyObject *{fn.decl.name}_temp = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) emitter.emit_line("if (!func_temp) goto fail;") emitter.emit_line( From be0c85590f44ea70cba9d57fab0dd52968d20f98 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 03:48:19 +0000 Subject: [PATCH 08/14] fix: compile err --- mypyc/codegen/emitmodule.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index c9fff11591f9..6554ed5f251b 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -989,14 +989,15 @@ def emit_module_exec_func( # Patch async native functions so they're recognized as coroutines for fn in module.functions: if fn.decl.is_async and fn.class_name is None: + temp_name = f"{fn.fullname}_temp" emitter.emit_line( - f'PyObject *{fn.decl.name}_temp = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' + f'PyObject *{temp_name} = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) - emitter.emit_line("if (!func_temp) goto fail;") + emitter.emit_line(f"if (!{temp_name}) goto fail;") emitter.emit_line( - "if (!CPyFunc_SetCoroFlag(func_temp)) { Py_DECREF(func_temp); goto fail; }" + "if (!CPyFunc_SetCoroFlag(" + temp_name + ")) { Py_DECREF(" + temp_name + "); goto fail; }" ) - emitter.emit_line("Py_DECREF(func_temp);") + emitter.emit_line(f"Py_DECREF({temp_name});") self.generate_top_level_call(module, emitter) From dd35ab742aa0a8298f37b916a39806d9ed4a7881 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 03:49:43 +0000 Subject: [PATCH 09/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypyc/codegen/emitmodule.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 6554ed5f251b..e7fc08e9082a 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -995,7 +995,11 @@ def emit_module_exec_func( ) emitter.emit_line(f"if (!{temp_name}) goto fail;") emitter.emit_line( - "if (!CPyFunc_SetCoroFlag(" + temp_name + ")) { Py_DECREF(" + temp_name + "); goto fail; }" + "if (!CPyFunc_SetCoroFlag(" + + temp_name + + ")) { Py_DECREF(" + + temp_name + + "); goto fail; }" ) emitter.emit_line(f"Py_DECREF({temp_name});") From b6719019f99332241c56a1410887bfdb04c06638 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 04:02:27 +0000 Subject: [PATCH 10/14] fix: no . in var names --- mypyc/codegen/emitmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 6554ed5f251b..ccf4ed4ccd7b 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -989,7 +989,7 @@ def emit_module_exec_func( # Patch async native functions so they're recognized as coroutines for fn in module.functions: if fn.decl.is_async and fn.class_name is None: - temp_name = f"{fn.fullname}_temp" + temp_name = f"{fn.fullname.replace(".", "__")}_temp" emitter.emit_line( f'PyObject *{temp_name} = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) From ca8ffad4060ab81c3b54115d75d0cddf5b9dae04 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 04:06:12 +0000 Subject: [PATCH 11/14] fix: f-string --- mypyc/codegen/emitmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 84a5495ee85c..003d8d41e920 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -989,7 +989,7 @@ def emit_module_exec_func( # Patch async native functions so they're recognized as coroutines for fn in module.functions: if fn.decl.is_async and fn.class_name is None: - temp_name = f"{fn.fullname.replace(".", "__")}_temp" + temp_name = f"{fn.fullname.replace('.', '__')}_temp" emitter.emit_line( f'PyObject *{temp_name} = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' ) From a802c16679115b3ac4ced1e1be18ec7cfe58b562 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 04:59:43 +0000 Subject: [PATCH 12/14] fix: add flag --- mypyc/codegen/emitmodule.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 003d8d41e920..ba5513fc7d25 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -9,7 +9,7 @@ import os import sys from collections.abc import Iterable -from typing import Optional, TypeVar +from typing import List, Optional, TypeVar from mypy.build import ( BuildResult, @@ -911,15 +911,19 @@ def emit_module_methods( if fn.class_name is not None or fn.name == TOP_LEVEL_NAME: continue name = short_id_from_name(fn.name, fn.decl.shortname, fn.line) + flags: List[str] = [] if is_fastcall_supported(fn, emitter.capi_version): - flag = "METH_FASTCALL" + flags.append("METH_FASTCALL") else: - flag = "METH_VARARGS" + flags.append("METH_VARARGS") + flags.append("METH_KEYWORDS") + if fn.decl.is_async: + flags.append("METH_COROUTINE") emitter.emit_line( ( - '{{"{name}", (PyCFunction){prefix}{cname}, {flag} | METH_KEYWORDS, ' + '{{"{name}", (PyCFunction){prefix}{cname}, {flags}, ' "NULL /* docstring */}}," - ).format(name=name, cname=fn.cname(emitter.names), prefix=PREFIX, flag=flag) + ).format(name=name, cname=fn.cname(emitter.names), prefix=PREFIX, flags=" | ".join(flags)) ) emitter.emit_line("{NULL, NULL, 0, NULL}") emitter.emit_line("};") From 199ae781f32f140d2548fa72814f0d315f3a0507 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Wed, 18 Jun 2025 05:00:51 +0000 Subject: [PATCH 13/14] new idea --- mypyc/codegen/emitmodule.py | 16 ---------------- mypyc/lib-rt/pythonsupport.c | 16 ---------------- mypyc/lib-rt/pythonsupport.h | 3 --- 3 files changed, 35 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index ba5513fc7d25..5fab22175384 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -990,22 +990,6 @@ def emit_module_exec_func( emitter.emit_lines(f"if (unlikely(!{type_struct}))", " goto fail;") emitter.emit_lines("if (CPyGlobalsInit() < 0)", " goto fail;") - # Patch async native functions so they're recognized as coroutines - for fn in module.functions: - if fn.decl.is_async and fn.class_name is None: - temp_name = f"{fn.fullname.replace('.', '__')}_temp" - emitter.emit_line( - f'PyObject *{temp_name} = PyObject_GetAttrString({module_static}, "{fn.decl.name}");' - ) - emitter.emit_line(f"if (!{temp_name}) goto fail;") - emitter.emit_line( - "if (!CPyFunc_SetCoroFlag(" - + temp_name - + ")) { Py_DECREF(" - + temp_name - + "); goto fail; }" - ) - emitter.emit_line(f"Py_DECREF({temp_name});") self.generate_top_level_call(module, emitter) diff --git a/mypyc/lib-rt/pythonsupport.c b/mypyc/lib-rt/pythonsupport.c index ea0b29465732..90fb69705a00 100644 --- a/mypyc/lib-rt/pythonsupport.c +++ b/mypyc/lib-rt/pythonsupport.c @@ -103,20 +103,4 @@ CPyLong_AsSsize_tAndOverflow_(PyObject *vv, int *overflow) } -// CPy support for async functions: patch code object to include CO_COROUTINE -PyObject* CPyFunc_SetCoroFlag(PyObject* func) { - PyObject* code = PyObject_GetAttrString(func, "__code__"); - if (!code) { - return NULL; - } - PyCodeObject* codeobj = (PyCodeObject*)code; - codeobj->co_flags |= CO_COROUTINE; - int res = PyObject_SetAttrString(func, "__code__", code); - Py_DECREF(code); - if (res < 0) { - return NULL; - } - Py_INCREF(func); - return func; -} #endif diff --git a/mypyc/lib-rt/pythonsupport.h b/mypyc/lib-rt/pythonsupport.h index 8b66e6f42c0c..7019c12cf59a 100644 --- a/mypyc/lib-rt/pythonsupport.h +++ b/mypyc/lib-rt/pythonsupport.h @@ -474,8 +474,5 @@ CPyCoro_GetAwaitableIter(PyObject *o) return NULL; } -static PyObject * -CPyFunc_SetCoroFlag(PyObject* func); - #endif From fbb3fb59118cd63f19270d52f89a8f4973a9926d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 05:02:16 +0000 Subject: [PATCH 14/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypyc/codegen/emitmodule.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 5fab22175384..83703dec408b 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -921,9 +921,13 @@ def emit_module_methods( flags.append("METH_COROUTINE") emitter.emit_line( ( - '{{"{name}", (PyCFunction){prefix}{cname}, {flags}, ' - "NULL /* docstring */}}," - ).format(name=name, cname=fn.cname(emitter.names), prefix=PREFIX, flags=" | ".join(flags)) + '{{"{name}", (PyCFunction){prefix}{cname}, {flags}, ' "NULL /* docstring */}}," + ).format( + name=name, + cname=fn.cname(emitter.names), + prefix=PREFIX, + flags=" | ".join(flags), + ) ) emitter.emit_line("{NULL, NULL, 0, NULL}") emitter.emit_line("};")