Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Pydantic 2.9 #362

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 3 additions & 1 deletion launch/camera.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
CAMERAS.append(
CameraConfig(
name='camera1',
param_path=Path(USB_CAM_DIR, 'config', 'params_1.yaml')
param_path=Path(USB_CAM_DIR, 'config', 'params_1.yaml'),
remappings=None,
namespace=None,
)
# Add more Camera's here and they will automatically be launched below
)
Expand Down
6 changes: 3 additions & 3 deletions launch/camera_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from typing import List, Optional

from ament_index_python.packages import get_package_share_directory
from pydantic import BaseModel, root_validator, validator
from pydantic import BaseModel, model_validator, field_validator

USB_CAM_DIR = get_package_share_directory('usb_cam')

Expand All @@ -42,13 +42,13 @@ class CameraConfig(BaseModel):
remappings: Optional[List]
namespace: Optional[str]

@validator('param_path')
@field_validator('param_path')
def validate_param_path(cls, value):
if value and not value.exists():
raise FileNotFoundError(f'Could not find parameter file: {value}')
return value

@root_validator
@model_validator(mode='before')
def validate_root(cls, values):
name = values.get('name')
remappings = values.get('remappings')
Expand Down