From c40613341b6c500bc96a341fe75d21e45d26468c Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh Date: Thu, 23 Jan 2025 16:27:33 +0000 Subject: [PATCH] simplified test --- tests/unit_tests/test_config.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/unit_tests/test_config.py b/tests/unit_tests/test_config.py index 107580d0e..f55741306 100644 --- a/tests/unit_tests/test_config.py +++ b/tests/unit_tests/test_config.py @@ -379,13 +379,11 @@ def check_no_extra_fields(model_class: Any) -> None: def validate_field_annotations(model_class: Any, model_field: str) -> None: - extracted_annotations = getattr( - model_class.model_fields[model_field].annotation, - "__args__", - model_class.model_fields[model_field].annotation, - ) - if not isinstance(extracted_annotations, Iterable): - check_no_extra_fields(extracted_annotations) + field_annotation = model_class.model_fields[model_field].annotation + extracted_annotations = getattr(field_annotation, "__args__", field_annotation) + + if isinstance(extracted_annotations, Iterable): + for annotation in extracted_annotations: + check_no_extra_fields(annotation) else: - for i in extracted_annotations: - check_no_extra_fields(i) + check_no_extra_fields(extracted_annotations)