diff --git a/sphinx_needs/directives/needimport.py b/sphinx_needs/directives/needimport.py index 9261d4b6d..d869c919c 100644 --- a/sphinx_needs/directives/needimport.py +++ b/sphinx_needs/directives/needimport.py @@ -113,14 +113,13 @@ def run(self) -> Sequence[nodes.Node]: except (OSError, json.JSONDecodeError) as e: # TODO: Add exception handling raise SphinxNeedsFileException(correct_need_import_path) from e - - errors = check_needs_data(needs_import_list) - if errors.schema: - logger.info( - f"Schema validation errors detected in file {correct_need_import_path}:" - ) - for error in errors.schema: - logger.info(f" {error.message} -> {'.'.join(error.path)}") + errors = check_needs_data(needs_import_list) + if errors.schema: + logger.info( + f"Schema validation errors detected in file {correct_need_import_path}:" + ) + for error in errors.schema: + logger.info(f" {error.message} -> {'.'.join(error.path)}") if version is None: try: