Skip to content

Commit b9eba48

Browse files
authored
Merge pull request #47 from team23/dev/#46-drop-pydantic-v1-support
Fix #46: Drop pydantic v1 support
2 parents 08a289e + 4b9969f commit b9eba48

File tree

10 files changed

+222
-439
lines changed

10 files changed

+222
-439
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,29 @@ on:
55
schedule:
66
- cron: '0 7 * * 1'
77
jobs:
8+
test-older-python:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade poetry
22+
poetry install
23+
- name: Test with pytest
24+
run: |
25+
poetry run tox -e 'py-2.6,py-2.x'
826
test:
927
runs-on: ubuntu-latest
1028
strategy:
1129
matrix:
12-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
30+
python-version: ["3.13"]
1331
steps:
1432
- uses: actions/checkout@v4
1533
- name: Set up Python ${{ matrix.python-version }}
@@ -22,4 +40,4 @@ jobs:
2240
poetry install
2341
- name: Test with pytest
2442
run: |
25-
poetry run tox -e 'py-1.9,py-1.10,py-2.x'
43+
poetry run tox -e 'py-2.x'

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ repos:
88
- id: check-docstring-first
99
- id: debug-statements
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.8.1
11+
rev: v0.11.7
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --exit-non-zero-on-fix]
1515
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
16-
rev: v9.19.0
16+
rev: v9.22.0
1717
hooks:
1818
- id: commitlint
1919
stages: [commit-msg]

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
Just use `pip install pydantic-changedetect` to install the library.
66

7-
**Note:** `pydantic-changedetect` is compatible with `pydantic` versions `1.9`, `1.10` and even `2.x` (🥳) on
8-
Python `3.9`, `3.10`, `3.11`, `3.12` and `3.13`. This is also ensured running all tests on all those versions
9-
using `tox`.
7+
**Note:** `pydantic-changedetect` is compatible with `pydantic` version `2.x` on Python `3.9`, `3.10`, `3.11`,
8+
`3.12` and `3.13`. This is also ensured running all tests on all those versions using `tox`.
109

1110
## About
1211

pydantic_changedetect/_compat.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,4 @@
1-
from typing import Any
2-
3-
import pydantic
4-
from pydantic.fields import FieldInfo
51
from pydantic.version import VERSION as PYDANTIC_VERSION
62

7-
PYDANTIC_V1 = PYDANTIC_VERSION.startswith("1.")
8-
PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.")
93
PYDANTIC_VERSION_TUPLE = tuple(map(int, PYDANTIC_VERSION.split('.')))
10-
11-
if PYDANTIC_V1: # pragma: no cover
12-
class PydanticCompat: # type: ignore
13-
obj: pydantic.BaseModel
14-
15-
def __init__(
16-
self,
17-
obj: pydantic.BaseModel,
18-
) -> None:
19-
self.obj = obj
20-
21-
@property
22-
def model_fields(self) -> dict[str, FieldInfo]:
23-
return self.obj.__fields__
24-
25-
def get_model_field_info_annotation(self, model_field: FieldInfo) -> type:
26-
return model_field.type_ # type: ignore
27-
28-
elif PYDANTIC_V2: # pragma: no cover
29-
class PydanticCompat: # type: ignore
30-
obj: pydantic.BaseModel
31-
32-
def __init__(
33-
self,
34-
obj: pydantic.BaseModel,
35-
) -> None:
36-
self.obj = obj
37-
38-
@property
39-
def model_fields(self) -> dict[str, FieldInfo]:
40-
return self.obj.__class__.model_fields
41-
42-
def get_model_field_info_annotation(self, model_field: FieldInfo) -> type[Any]:
43-
if model_field.annotation is None:
44-
raise RuntimeError("model field has not typing annotation")
45-
return model_field.annotation
4+
PYDANTIC_GE_V2_7 = PYDANTIC_VERSION_TUPLE >= (2, 7, 0)

0 commit comments

Comments
 (0)