Skip to content

Commit cfc185c

Browse files
authored
Refactor, update to Pydantic v2 (#65)
Previously confection did three tree operations simultaneously (in the registry._fill method): * Build a version of the config with defaults in-place * Build a modified version suitable for validation * Build an output version with promises resolved The fact that all three were being built at once made the code quite hard to update for Pydantic 2, and just difficult to work with in general. I've therefore refactored the code so that these are separate processes that apply to the whole tree at once. A bonus of this is that we now build a model for the whole config and validate against that, which means all the validation errors for the config should come in at once, instead of only getting validation errors for one promise at a time. Updating to Pydantic v2 will let spaCy finally support Python 3.13.
1 parent 81ac158 commit cfc185c

File tree

11 files changed

+2223
-1764
lines changed

11 files changed

+2223
-1764
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Configure Python version
1818
uses: actions/setup-python@v5
1919
with:
20-
python-version: "3.7"
20+
python-version: "3.10"
2121

2222
- name: black
2323
run: |
@@ -39,20 +39,7 @@ jobs:
3939
fail-fast: false
4040
matrix:
4141
os: [ubuntu-latest, windows-latest, macos-latest]
42-
python_version: [ "3.12" ]
43-
include:
44-
- os: windows-2019
45-
python_version: "3.6"
46-
- os: ubuntu-latest
47-
python_version: "3.7"
48-
- os: windows-latest
49-
python_version: "3.8"
50-
- os: macos-latest
51-
python_version: "3.9"
52-
- os: ubuntu-latest
53-
python_version: "3.10"
54-
- os: windows-latest
55-
python_version: "3.11"
42+
python_version: ["3.10", "3.12", "3.13"]
5643

5744
runs-on: ${{ matrix.os }}
5845

@@ -71,17 +58,6 @@ jobs:
7158
python -m pip install -U -r requirements.txt
7259
python -m build --sdist
7360
74-
- name: Run mypy for Pydantic v2
75-
run: |
76-
python -m mypy confection
77-
if: matrix.python_version != '3.6' && matrix.python_version != '3.7'
78-
79-
- name: Run mypy for Pydantic v1.10
80-
run: |
81-
python -m pip install -U pydantic==1.10.*
82-
python -m mypy confection
83-
if: matrix.python_version != '3.6' && matrix.python_version != '3.7'
84-
8561
- name: Delete source directory
8662
run: rm -rf confection
8763
shell: bash
@@ -100,16 +76,6 @@ jobs:
10076
- name: Test import
10177
run: python -c "import confection" -Werror
10278

103-
- name: Install test requirements with Pydantic v1
104-
run: |
105-
python -m pip install -U -r requirements.txt
106-
python -m pip install -U "pydantic<2.0"
107-
108-
- name: Run tests for Pydantic v1
109-
run: |
110-
python -c "import pydantic; print(pydantic.VERSION)"
111-
python -m pytest --pyargs confection -Werror
112-
11379
- name: Install test requirements with Pydantic v2
11480
run: |
11581
python -m pip install -U -r requirements.txt

0 commit comments

Comments
 (0)