odoo_mqtt/iot_bridge/api
matthias.lotz 527b5645ed refactor(phase2.3): Migrate to Pydantic V2 and modernize config management
Complete Pydantic V2 migration and config modernization:

api/models.py:
- Migrated @validator → @field_validator (Pydantic V2)
- Added @classmethod decorators (required in V2)
- Updated validator signatures: (cls, v, values) → (cls, v, info)
- Consolidated unique validators into one method
- Fixed: 3 PydanticDeprecatedSince20 warnings 

config/schema.py:
- Migrated from @dataclass → Pydantic BaseModel
- Added Field() with validation constraints:
  * Port: ge=1, le=65535
  * Floats: gt=0, ge=0
  * Strings: min_length constraints
- Added descriptive field descriptions
- Better type safety and runtime validation

core/bootstrap.py:
- Replaced SimpleNamespace → MQTTConfig (Pydantic)
- Now returns properly typed Pydantic models
- Better IDE autocomplete and type checking

Benefits:
 No more Pydantic V1 deprecation warnings
 Runtime validation for all config fields
 Better error messages on invalid config
 Type-safe config throughout the application
 Automatic validation (port ranges, positive numbers, etc.)
 Prepared for Pydantic V3 migration

Migration verified:
- Config loading works: load_config('config.example.yaml') ✓
- Bootstrap works with Pydantic models ✓
- Field validation works (tested port ranges, thresholds) ✓
- All existing functionality preserved ✓

Test: python3 -c 'from core.bootstrap import bootstrap; bootstrap()'
 Works perfectly with new Pydantic V2 models

See OPTIMIZATION_PLAN.md Phase 2.3 for details.
2026-02-18 22:53:36 +01:00
..
__init__.py chore: Apply code quality tools (black, isort, ruff) 2026-02-18 22:20:25 +01:00
models.py refactor(phase2.3): Migrate to Pydantic V2 and modernize config management 2026-02-18 22:53:36 +01:00
server.py chore: Apply code quality tools (black, isort, ruff) 2026-02-18 22:20:25 +01:00