Summary
Running pytest with --cov flag fails when importing climate_ref due to an incompatibility between ecgtools and pydantic 2.11+.
Error
PydanticSchemaGenerationError: Unable to generate pydantic-core schema for
<class 'pydantic.deprecated.decorator.ValidatedFunction.create_model.<locals>.DecoratorBaseModel'>
Root Cause
The ecgtools package uses the deprecated @pydantic.validate_arguments decorator which was removed/broken in pydantic 2.11:
# ecgtools/builder.py:148
@pydantic.validate_arguments
def build(self, ...):
Import Chain
conftest.py imports climate_ref.cli
cli imports datasets
datasets imports ecgtools.Builder
ecgtools uses deprecated @pydantic.validate_arguments
- pydantic 2.11+ fails to generate schema
Current State
climate-ref-core requires pydantic>=2.10.6
- Installed:
pydantic 2.11.4
ecgtools 2024.7.31 has no upper bound on pydantic
- Tests pass without
--cov, only coverage collection triggers the import error
make test-ref works (coverage shows 88.77%)
Potential Solutions
-
Pin pydantic < 2.11 in project dependencies
-
Wait for ecgtools fix - upstream needs to migrate from deprecated decorator
-
Lazy import ecgtools - defer import until actually needed, avoiding the conftest import chain
Environment
- pydantic: 2.11.4
- ecgtools: 2024.7.31
- Python: 3.11.14
Summary
Running pytest with
--covflag fails when importingclimate_refdue to an incompatibility betweenecgtoolsand pydantic 2.11+.Error
Root Cause
The
ecgtoolspackage uses the deprecated@pydantic.validate_argumentsdecorator which was removed/broken in pydantic 2.11:Import Chain
conftest.pyimportsclimate_ref.clicliimportsdatasetsdatasetsimportsecgtools.Builderecgtoolsuses deprecated@pydantic.validate_argumentsCurrent State
climate-ref-corerequirespydantic>=2.10.6pydantic 2.11.4ecgtools 2024.7.31has no upper bound on pydantic--cov, only coverage collection triggers the import errormake test-refworks (coverage shows 88.77%)Potential Solutions
Pin pydantic < 2.11 in project dependencies
"pydantic>=2.10.6,<2.11"Wait for ecgtools fix - upstream needs to migrate from deprecated decorator
Lazy import ecgtools - defer import until actually needed, avoiding the conftest import chain
Environment