Skip to content

Commit d925b84

Browse files
jameshilliardb-rowan
authored andcommitted
Enable mypy pydantic plugin
1 parent dfea565 commit d925b84

6 files changed

Lines changed: 20 additions & 12 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ repos:
3535
rev: v1.18.2
3636
hooks:
3737
- id: mypy
38-
additional_dependencies: [types-pyyaml==6.0.12.20250915]
38+
additional_dependencies:
39+
[
40+
pydantic==2.11.9,
41+
pydantic-settings==2.10.1,
42+
types-pyyaml==6.0.12.20250915,
43+
]
3944
- repo: local
4045
hooks:
4146
- id: pytest

goosebit/api/v1/devices/device/responses.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22

33
from pydantic import BaseModel
44

5-
from goosebit.schema.devices import DeviceSchema
6-
75

86
class DeviceLogResponse(BaseModel):
97
log: str | None
108
progress: int | None
11-
12-
13-
class DeviceResponse(DeviceSchema):
14-
pass

goosebit/api/v1/devices/device/routes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from fastapi import APIRouter, Depends, HTTPException, Security
44
from fastapi.requests import Request
55

6-
from goosebit.api.v1.devices.device.responses import DeviceLogResponse, DeviceResponse
6+
from goosebit.api.v1.devices.device.responses import DeviceLogResponse
77
from goosebit.auth import validate_user_permissions
88
from goosebit.auth.permissions import GOOSEBIT_PERMISSIONS
99
from goosebit.db import Device
1010
from goosebit.device_manager import get_device
11+
from goosebit.schema.devices import DeviceSchema
1112

1213
router = APIRouter(prefix="/{dev_id}")
1314

@@ -16,11 +17,11 @@
1617
"",
1718
dependencies=[Security(validate_user_permissions, scopes=[GOOSEBIT_PERMISSIONS["device"]["read"]()])],
1819
)
19-
async def device_get(_: Request, device: Device = Depends(get_device)) -> DeviceResponse:
20+
async def device_get(_: Request, device: Device = Depends(get_device)) -> DeviceSchema:
2021
if device is None:
2122
raise HTTPException(404)
2223
await device.fetch_related("assigned_software", "hardware")
23-
return DeviceResponse.model_validate(device)
24+
return DeviceSchema.model_validate(device)
2425

2526

2627
@router.get(

goosebit/api/v1/rollouts/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ async def rollouts_put(_: Request, rollout: RolloutsPutRequest) -> RolloutsPutRe
2929
software = await Software.filter(id=rollout.software_id)
3030
if len(software) == 0:
3131
raise HTTPException(404, f"No software with ID {rollout.software_id} found")
32-
rollout = await Rollout.create(
32+
created_rollout = await Rollout.create(
3333
name=rollout.name,
3434
feed=rollout.feed,
3535
software_id=rollout.software_id,
3636
)
37-
return RolloutsPutResponse(success=True, id=rollout.id)
37+
return RolloutsPutResponse(success=True, id=created_rollout.id)
3838

3939

4040
@router.patch(

goosebit/settings/schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class StorageSettings(BaseModel):
7474
class GooseBitSettings(BaseSettings):
7575
model_config = SettingsConfigDict(env_prefix="GOOSEBIT_", extra="ignore", env_nested_delimiter="__")
7676

77+
config_file: Path | None = None
78+
7779
port: int = 60053 # GOOSE
7880
tenant: str = "DEFAULT"
7981

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ src_folder = "./goosebit"
7777

7878
[tool.mypy]
7979
explicit_package_bases = true
80+
plugins = ["pydantic.mypy"]
81+
82+
[tool.pydantic-mypy]
83+
init_forbid_extra = true
84+
init_typed = true
85+
warn_required_dynamic_aliases = true
8086

8187
[tool.djlint]
8288
ignore = "H030,H031,H021"

0 commit comments

Comments
 (0)