Skip to content

Commit 45d3ea3

Browse files
FBumannclaude
andcommitted
fix: avoid importing linopy at pytest config-parse time
The filter ``"ignore::linopy.EvolvingAPIWarning"`` forces pytest to import ``linopy`` when parsing pyproject.toml to resolve the class reference. That eager import loads ``linopy.variables`` from site-packages — and then ``pytest --doctest-modules linopy`` (used in the Windows CI job that installs from a built wheel) tries to collect ``linopy/variables.py`` from the source tree, sees the module is already imported from a different path, and fails every doctest collection with the "not the same as the test file we want to collect" error. Switch to a message-based filter on the builtin FutureWarning: "ignore:piecewise:FutureWarning" Our EvolvingAPIWarning is a FutureWarning subclass with messages that all start with "piecewise:", so the filter still catches them. FutureWarning is a builtin so pytest doesn't need to import linopy to resolve it. CI collection recovers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 646882b commit 45d3ea3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ markers = [
113113
filterwarnings = [
114114
# Silence our own EvolvingAPIWarning inside the test suite so the
115115
# piecewise tests don't emit 500+ warnings. Users still see them.
116-
"ignore::linopy.EvolvingAPIWarning",
116+
# Match by message prefix on the builtin FutureWarning base class
117+
# rather than on ``linopy.EvolvingAPIWarning`` directly — using the
118+
# class reference here would force pytest to import linopy at
119+
# config-parse time, which loads ``linopy.variables`` from
120+
# site-packages and then conflicts with ``--doctest-modules``
121+
# collection of ``linopy/variables.py`` in the source tree on
122+
# Windows CI.
123+
"ignore:piecewise:FutureWarning",
117124
]
118125

119126
[tool.coverage.run]

0 commit comments

Comments
 (0)