Skip to content

ENH: Add async function support#878

Draft
basnijholt wants to merge 6 commits intomainfrom
async
Draft

ENH: Add async function support#878
basnijholt wants to merge 6 commits intomainfrom
async

Conversation

@basnijholt
Copy link
Collaborator

No description provided.


@functools.cached_property
def func(self) -> Callable[..., tuple[Any, ...]]: # type: ignore[override]
def func(self) -> Callable[..., Any]: # type: ignore[override]

Check failure

Code scanning / CodeQL

Superclass attribute shadows subclass method Error

This method is shadowed by
attribute func
in superclass
PipeFunc
.

Copilot Autofix

AI 5 months ago

To resolve the shadowing, we should rename either the instance attribute self.func in the superclass (PipeFunc.__init__) or the method/property func in the subclass (the @functools.cached_property at line 1500). The best way, to preserve the standard functional APIs and existing code stability, is to rename the cached property in the subclass: change its name to something descriptive but not in conflict (for example, _computed_func). This will allow both attributes to coexist, and downstream code which expects self.func as the attribute will continue to work, while code wanting the rich/derived version will use the new method/property name.

Required changes:

  • In the subclass, rename the @functools.cached_property named func (line 1500+) to e.g. _computed_func — that is, change both the decorator line and the def func(... line and all references within this subclass to use the new property name.
  • If the subclass (or nearby code) refers to self.func and intends to use the cached property, update those references to use self._computed_func.
  • No imports/additional methods are required for Python built-in cached_property.
Suggested changeset 1
pipefunc/_pipefunc.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pipefunc/_pipefunc.py b/pipefunc/_pipefunc.py
--- a/pipefunc/_pipefunc.py
+++ b/pipefunc/_pipefunc.py
@@ -1497,7 +1497,7 @@
         return tuple(sorted(inputs))
 
     @functools.cached_property
-    def func(self) -> Callable[..., Any]:  # type: ignore[override]
+    def _computed_func(self) -> Callable[..., Any]:
         outputs = [f.output_name for f in self.pipeline.leaf_nodes]
         if self._is_async_func:
 
EOF
@@ -1497,7 +1497,7 @@
return tuple(sorted(inputs))

@functools.cached_property
def func(self) -> Callable[..., Any]: # type: ignore[override]
def _computed_func(self) -> Callable[..., Any]:
outputs = [f.output_name for f in self.pipeline.leaf_nodes]
if self._is_async_func:

Copilot is powered by AI and may make mistakes. Always verify output.
@github-actions
Copy link
Contributor

✅ PR Title Formatted Correctly

The title of this PR has been updated to match the correct format. Thank you!

@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 64.13793% with 104 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pipefunc/map/_run.py 52.88% 49 Missing ⚠️
pipefunc/_pipeline/_base.py 65.51% 30 Missing ⚠️
pipefunc/_pipefunc.py 74.74% 25 Missing ⚠️
Files with missing lines Coverage Δ
pipefunc/_pipefunc.py 96.23% <74.74%> (-3.77%) ⬇️
pipefunc/_pipeline/_base.py 96.68% <65.51%> (-3.32%) ⬇️
pipefunc/map/_run.py 91.72% <52.88%> (-8.28%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 17, 2025

CodSpeed Instrumentation Performance Report

Merging #878 will degrade performances by 5.01%

Comparing async (d81d042) with main (c867a1f)

Summary

❌ 1 regression
✅ 5 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_calling_pipeline_directly 70.6 ms 74.3 ms -5.01%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant