From ea0bf1bb6021a8dc1682693c37f37f46c25c2918 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 23 Jan 2024 20:05:33 +0100 Subject: [PATCH] Report class name when reporting an error during instantiating BaseModel object --- osc/util/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osc/util/models.py b/osc/util/models.py index bfb95d8f..10f9d9ee 100644 --- a/osc/util/models.py +++ b/osc/util/models.py @@ -321,12 +321,12 @@ class BaseModel(metaclass=ModelMeta): if kwargs: unknown_fields_str = ", ".join([f"'{i}'" for i in kwargs]) - raise TypeError(f"The following kwargs do not match any field: {unknown_fields_str}") + raise TypeError(f"The following kwargs of '{self.__class__.__name__}.__init__()' do not match any field: {unknown_fields_str}") if uninitialized_fields: uninitialized_fields_str = ", ".join([f"'{i}'" for i in uninitialized_fields]) raise TypeError( - f"The following fields are not initialized and have no default either: {uninitialized_fields_str}" + f"The following fields of '{self.__class__.__name__}' object are not initialized and have no default either: {uninitialized_fields_str}" ) for name, field in self.__fields__.items():