<@ULVA73B9P> when running pipeline tests using pyt...
# marvin-ai
f
@Marvin when running pipeline tests using pytest with prefect_test_harness, we get the following error: TypeError: Can't instantiate abstract class GatherTaskGroup with abstract method create_task What can be the reason for this?
m
thought for 202.3 seconds
Most likely, this is a dependency compatibility issue, not a problem with your test code. Cause
prefect_test_harness
exercises Prefect async internals, and your environment is probably using a newer
anyio
version where
TaskGroup
gained a new required abstract method:
create_task
. Prefect has an internal class called
GatherTaskGroup
that subclasses
anyio.abc.TaskGroup
. If that Prefect version does not implement the new
create_task
method, Python raises:
Copy code
text
TypeError: Can't instantiate abstract class GatherTaskGroup with abstract method create_task
So the usual reason is: Your installed Prefect version is incompatible with your installed
anyio
version.
What to check Run:
Copy code
bash
pip show prefect anyio
If you see a very recent
anyio
version, that’s the likely trigger. Typical fix Try pinning
anyio
to an earlier compatible version, for example:
Copy code
bash
pip install "anyio<4.14.0"
or add a constraint in your project config. You can also try upgrading Prefect to the latest release in case a fix has already landed:
Copy code
bash
pip install -U prefect
Recommended order 1. Upgrade Prefect 2. If it still fails, pin
anyio<4.14.0
Why it shows up in tests
prefect_test_harness
spins up Prefect testing infrastructure and touches async orchestration code paths that instantiate this task group, so the incompatibility often appears there first. Helpful links - Prefect docs: Prefect documentation - Prefect releases: Prefect release notes If you want, I can help you figure out the exact compatible version pair for your current Prefect install.