Skip to content

Commit 4a27155

Browse files
authored
➖ Drop support for Pydantic v1 (#268)
1 parent 53bb39a commit 4a27155

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,20 @@ jobs:
3030
matrix:
3131
os: [ ubuntu-latest, windows-latest, macos-latest ]
3232
python-version: ["3.14"]
33-
pydantic-version: ["v2"]
3433
include:
3534
- python-version: "3.8"
36-
pydantic-version: "v1"
3735
os: windows-latest
3836
- python-version: "3.9"
39-
pydantic-version: "v2"
4037
os: macos-latest
4138
- python-version: "3.10"
42-
pydantic-version: "v1"
4339
os: ubuntu-latest
4440
- python-version: "3.11"
45-
pydantic-version: "v2"
4641
os: windows-latest
4742
- python-version: "3.12"
48-
pydantic-version: "v1"
4943
os: macos-latest
5044
- python-version: "3.13"
51-
pydantic-version: "v1"
5245
os: ubuntu-latest
5346
- python-version: "3.13"
54-
pydantic-version: "v2"
5547
os: windows-latest
5648
fail-fast: false
5749
runs-on: ${{ matrix.os }}
@@ -81,21 +73,18 @@ jobs:
8173
limit-access-to-actor: true
8274
- name: Install Dependencies
8375
run: uv pip install -r requirements-tests.txt
84-
- name: Install Pydantic v1
85-
if: matrix.pydantic-version == 'v1'
86-
run: uv pip install "pydantic<2.0.0"
8776
- name: Lint
8877
run: bash scripts/lint.sh
8978
- run: mkdir coverage
9079
- name: Test
9180
run: bash scripts/test.sh
9281
env:
93-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
94-
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
82+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
83+
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
9584
- name: Store coverage files
9685
uses: actions/upload-artifact@v5
9786
with:
98-
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
87+
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
9988
path: coverage
10089
include-hidden-files: true
10190

src/fastapi_cli/config.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
from typing import Any, Dict, Optional
44

55
from pydantic import BaseModel, StrictStr
6-
from pydantic.version import VERSION as PYDANTIC_VERSION
76

87
logger = logging.getLogger(__name__)
98

10-
PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2])
11-
PYDANTIC_V2 = PYDANTIC_VERSION_MINOR_TUPLE[0] == 2
12-
139

1410
class FastAPIConfig(BaseModel):
1511
entrypoint: Optional[StrictStr] = None
@@ -43,8 +39,4 @@ def resolve(cls, entrypoint: Optional[str] = None) -> "FastAPIConfig":
4339
if entrypoint is not None:
4440
config["entrypoint"] = entrypoint
4541

46-
# Pydantic v2 uses model_validate, v1 uses parse_obj
47-
if not PYDANTIC_V2:
48-
return cls.parse_obj(config) # type: ignore[no-any-return, unused-ignore]
49-
50-
return cls.model_validate(config) # type: ignore[no-any-return, unused-ignore, attr-defined]
42+
return cls.model_validate(config)

0 commit comments

Comments
 (0)