Refactor inputs using pydantic #843
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the sensor input system to introduce strongly-typed, Pydantic-based configuration classes for each sensor, improving type safety, validation, and code clarity. The changes generalize the
SensorandFuserInputbase classes to support specific configuration types, and update all input plugins to use these new config classes. Theload_inputfunction is also updated to instantiate sensors with their configuration objects.Core infrastructure and typing improvements:
SensorConfigto inherit from Pydantic'sBaseModel, enabling validation and type hints for sensor configuration. The baseSensorandFuserInputclasses are now generic over their configuration type, allowing each sensor to specify its own config schema. [1] [2] [3] [4]load_inputfunction insrc/inputs/__init__.pyto accept a configuration dictionary, dynamically detect and instantiate the appropriate config class for each sensor, and pass it to the sensor's constructor. [1] [2] [3]Plugin-specific configuration classes:
battery_turtlebot4,battery_unitree_go2,dimo_tesla,fabric_closest_peer,face_presence_input,gallery_identities_input), introduced a dedicated Pydantic config class with explicit fields and documentation, replacing generic or ad-hoc config handling. Constructors and config usage within each plugin were updated accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]Generalization and consistency:
SensorConfigand usinggetattrfor config values. [1] [2] [3]These changes make the input system more robust, maintainable, and ready for further extension.