Skip to content

Coverage collection fails due to ecgtools/pydantic 2.11 incompatibility #491

@lewisjared

Description

@lewisjared

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

  1. conftest.py imports climate_ref.cli
  2. cli imports datasets
  3. datasets imports ecgtools.Builder
  4. ecgtools uses deprecated @pydantic.validate_arguments
  5. 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

  1. Pin pydantic < 2.11 in project dependencies

    "pydantic>=2.10.6,<2.11"
  2. Wait for ecgtools fix - upstream needs to migrate from deprecated decorator

  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions