-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ImportError when running with coverage measurement activated #6584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think I got a minimal example running. Would be nice if someone could confirm that they see the same behavior. # src/my_package/__init__.py
import pydantic
Create a virtual environment and run |
@davidhewitt as the resident pyo3 expert do you have any idea what's going on? |
The cause of the interaction with coverage seems to be caused by nedbat/coveragepy@2603597#diff-7ab8fe55706697d3772483ba055af46f5aacd86b110458a7cc824ae7e2324447R274 This is even documented as expected behaviour of In general the rule is that PyO3 modules aren't safe be imported more than one, because they can contain C statics and this is particularly bad in interaction with subinterpreters. (Data can cross sub-interpreters or otherwise cause wonky state.) Maybe we can loosen this check (or give modules an opt-in way to disable it). Further thoughts welcome. |
requirements.txt
|
Uh oh!
There was an error while loading. Please reload this page.
Initial Checks
Description
I upgraded a library (A) to Pydantic v2. Now I want to upgrade a second library (B) that uses A to Pydantic v2. However, pytest runs fail with:
The tests run fine if I run with the
--no-cov
flag.I would like to produce a minimal example but I don't know where to start and the error message does not tell me anything. Library B imports some Pydantic models from library A in its conftest.py and the run crashes on importing B's conftest.py. Unit tests for library A work without problems and with activated coverage though.
How should I go about analyzing the issue? What raises the import error?
Example Code
No response
Python, Pydantic & OS Version
Selected Assignee: @dmontagu
The text was updated successfully, but these errors were encountered: