Skip to content

Commit a98070d

Browse files
committed
fix tests
1 parent 5345317 commit a98070d

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ jobs:
3737
- os: ubuntu-latest
3838
python-version: "3.12"
3939
pydantic: "'pydantic<2'"
40+
pydantic-label: "pydantic-v1"
4041
- os: ubuntu-latest
4142
python-version: "3.11"
43+
pydantic: "pydantic"
4244
resolution: "lowest-direct"
4345

4446
steps:
@@ -64,7 +66,7 @@ jobs:
6466
- name: Upload coverage
6567
uses: actions/upload-artifact@v6
6668
with:
67-
name: covreport-${{ matrix.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic }}-${{ matrix.resolution }}
69+
name: covreport-${{ matrix.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-label || 'pydantic' }}-${{ matrix.resolution }}
6870
path: ./.coverage*
6971
include-hidden-files: true
7072

src/fieldz/adapters/_named_tuple.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def replace(obj: NamedTupleInstance, /, **changes: Any) -> NamedTupleInstance:
4949

5050
def fields(obj: NamedTupleInstance | type[NamedTupleInstance]) -> tuple[Field, ...]:
5151
"""Return a tuple of fields for the class or instance."""
52-
annotations = getattr(obj, "__annotations__", {})
52+
cls = obj if isinstance(obj, type) else type(obj)
53+
annotations = getattr(cls, "__annotations__", {})
5354
defaults = getattr(obj, "_field_defaults", {})
5455
return tuple(
5556
Field(name=name, type=annotations.get(name, Any), default=defaults.get(name))

tests/test_fieldz.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dataclasses
2+
import sys
23
from collections.abc import Callable
34
from typing import Any, NamedTuple, Optional, TypedDict
45

@@ -7,6 +8,8 @@
78
from fieldz import Field, asdict, astuple, fields, params, replace
89
from fieldz.adapters._named_tuple import is_named_tuple
910

11+
PY314 = sys.version_info >= (3, 14)
12+
1013

1114
def _dataclass_model() -> type:
1215
@dataclasses.dataclass
@@ -168,10 +171,23 @@ class Model(models.Model):
168171
[
169172
_dataclass_model,
170173
_named_tuple,
171-
_dataclassy_model,
174+
pytest.param(
175+
_dataclassy_model,
176+
marks=pytest.mark.skipif(PY314, reason="dataclassy broken on 3.14"),
177+
),
172178
_pydantic_model,
173-
_pydantic_v1_model,
174-
_pydantic_v1_model_str,
179+
pytest.param(
180+
_pydantic_v1_model,
181+
marks=pytest.mark.skipif(
182+
PY314, reason="pydantic v1 incompatible with 3.14"
183+
),
184+
),
185+
pytest.param(
186+
_pydantic_v1_model_str,
187+
marks=pytest.mark.skipif(
188+
PY314, reason="pydantic v1 incompatible with 3.14"
189+
),
190+
),
175191
_attrs_model,
176192
_msgspec_model,
177193
_sqlmodel,

0 commit comments

Comments
 (0)