Skip to content
Snippets Groups Projects
Commit 1d831f39 authored by Maurice Herné's avatar Maurice Herné
Browse files

Replaces type assertion in configuration_model.py

assert will be removed when compiling to optimized bytecode. This can lead to UB. Instead we are now using if not isinstance(): raise TypeError().
parent 910b321f
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,9 @@ class ConfigurationModel(ConfiguredBaseModel):
Causes defaults to get validated as a side effect.
Since this only happens during the startup of the application, I consider this to be a positive side effect that protects against errors.
"""
assert isinstance(data, dict)
if not isinstance(data, dict):
raise TypeError(f"data must be a dict, not {type(data)}")
for field, info in cls.model_fields.items():
data.setdefault(field, environ.get(field, info.default))
return data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment