-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Describe the bug
As of LabThings 0.0.12. Parsing the server config and importing Things is done within a Pydantic model. However Pydantic only expects it is serialising/deserialising data and hence captures every ValueError and TypeError and raises a ValidationError without the traceback of the original error.
This means that if there is ever a TypeError or ValueError when importing a Thing the traceback is removed and an unhelpful Pydantic error is shown instead,
To Reproduce
- Create a Value error in a Thing file that will be called at import time
- Run labthings with this thing in the configuration
Expected behaviour
A traceback that points at the ValueError itself.
Suggested fix
While it could be possible to catch the ValueErrors or TypeErrors and raise them as a different type that Pydantic will not capture, however this is fragile to pydantic capturing changing overtime and capturing different things. It would be better to parse the configuration and serialise it with the strings. And then import the modules outside pydantic validation.
System:
- OS: Kubuntu 24.01
- Python version: 3.11
- Version: 0.0.12