Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,20 @@ jobs:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: ["3.14"]
pydantic-version: ["v2"]
include:
- python-version: "3.8"
pydantic-version: "v1"
os: windows-latest
- python-version: "3.9"
pydantic-version: "v2"
os: macos-latest
- python-version: "3.10"
pydantic-version: "v1"
os: ubuntu-latest
- python-version: "3.11"
pydantic-version: "v2"
os: windows-latest
- python-version: "3.12"
pydantic-version: "v1"
os: macos-latest
- python-version: "3.13"
pydantic-version: "v1"
os: ubuntu-latest
- python-version: "3.13"
pydantic-version: "v2"
os: windows-latest
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -81,21 +73,18 @@ jobs:
limit-access-to-actor: true
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- name: Install Pydantic v1
if: matrix.pydantic-version == 'v1'
run: uv pip install "pydantic<2.0.0"
- name: Lint
run: bash scripts/lint.sh
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v5
with:
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
path: coverage
include-hidden-files: true

Expand Down
10 changes: 1 addition & 9 deletions src/fastapi_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
from typing import Any, Dict, Optional

from pydantic import BaseModel, StrictStr
from pydantic.version import VERSION as PYDANTIC_VERSION

logger = logging.getLogger(__name__)

PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2])
PYDANTIC_V2 = PYDANTIC_VERSION_MINOR_TUPLE[0] == 2


class FastAPIConfig(BaseModel):
entrypoint: Optional[StrictStr] = None
Expand Down Expand Up @@ -43,8 +39,4 @@ def resolve(cls, entrypoint: Optional[str] = None) -> "FastAPIConfig":
if entrypoint is not None:
config["entrypoint"] = entrypoint

# Pydantic v2 uses model_validate, v1 uses parse_obj
if not PYDANTIC_V2:
return cls.parse_obj(config) # type: ignore[no-any-return, unused-ignore]

return cls.model_validate(config) # type: ignore[no-any-return, unused-ignore, attr-defined]
return cls.model_validate(config)
Loading