Skip to content

Commit e013bb6

Browse files
committed
tuned
1 parent 95cc7ef commit e013bb6

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

.github/prompts/pydantic-annotated-fields.prompt.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ class ProjectModel(BaseModel):
5858
name: str = Field(default="Untitled Project", min_length=3, max_length=50)
5959
created_at: datetime = Field(default_factory=datetime.now)
6060
value: int = Field(..., description="Project value")
61+
str_with_default: str = Field(default="foo")
62+
6163
config: dict = Field(default={"version": "1.0", "theme": "default"})
6264

63-
@field_validator("name")
64-
def validate_name(cls, v):
65-
if v.isdigit():
66-
raise ValueError("Name cannot be only digits")
67-
return v
6865
```
6966

7067
### After:
@@ -80,11 +77,8 @@ class ProjectModel(BaseModel):
8077
name: Annotated[str, Field(min_length=3, max_length=50)] = "Untitled Project"
8178
created_at: Annotated[datetime, Field(default_factory=datetime.now)] = DEFAULT_FACTORY
8279
value: Annotated[int, Field(description="Project value")]
80+
str_with_default: str = "foo"
81+
8382
config: dict = {"version": "1.0", "theme": "default"}
8483

85-
@field_validator("name")
86-
def validate_name(cls, v):
87-
if v.isdigit():
88-
raise ValueError("Name cannot be only digits")
89-
return v
9084
```

services/web/server/src/simcore_service_webserver/diagnostics/_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from aiohttp import ClientError, ClientSession, web
99
from models_library.app_diagnostics import AppStatusCheck
10-
from pydantic import BaseModel, Field
10+
from pydantic import BaseModel
1111
from servicelib.aiohttp.client_session import get_client_session
1212
from servicelib.aiohttp.requests_validation import parse_request_query_parameters_as
1313
from servicelib.utils import logged_gather
@@ -29,7 +29,7 @@
2929

3030

3131
class StatusDiagnosticsQueryParam(BaseModel):
32-
top_tracemalloc: int | None = Field(default=None)
32+
top_tracemalloc: int | None = None
3333

3434

3535
class StatusDiagnosticsGet(BaseModel):

0 commit comments

Comments
 (0)