3 Commits

Author SHA1 Message Date
9bb799a785 Merge pull request 'main' (#14) from main into dev
Reviewed-on: #14
2026-07-09 08:59:59 +00:00
smueller
8a556b18ea Add field validation for configuration settings in Settings class
- Introduced a field validator to parse integer values with inline comments for access token expiration, HSTS max age, editor tip max length, and highlights max length.
- Enhanced the configuration management by ensuring cleaner input handling for specific settings.
2026-07-09 10:59:37 +02:00
smueller
1674efd587 Enhance Docker build workflow by adding virtual environment setup
- Introduced a Python virtual environment for dependency management.
- Updated pip installation commands to use the virtual environment context.
2026-07-09 10:55:25 +02:00
2 changed files with 18 additions and 1 deletions

View File

@@ -27,8 +27,10 @@ jobs:
- name: Python-Abhängigkeiten prüfen (pip-audit)
run: |
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install pip-audit
python -m pip install pip-audit
pip-audit -r requirements.txt
- name: Docker Buildx einrichten

View File

@@ -1,3 +1,4 @@
from pydantic import field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -25,6 +26,20 @@ class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
@field_validator(
"access_token_expire_minutes",
"hsts_max_age",
"editor_tip_max_length",
"highlights_max_length",
mode="before",
)
@classmethod
def _parse_int_with_inline_comment(cls, value):
if isinstance(value, str):
cleaned = value.split("#", 1)[0].strip()
return int(cleaned) if cleaned else value
return value
@property
def is_production(self) -> bool:
return self.environment.lower() == "production"