From 926c8a7bd1e9bdd073f03fa2bfbbde4bb1d2d728 Mon Sep 17 00:00:00 2001 From: Yannik Tausch Date: Mon, 25 Mar 2024 11:40:33 +0100 Subject: [PATCH] schema validation errors are hints, small fixes --- conda_smithy/cli.py | 2 +- conda_smithy/configure_feedstock.py | 11 ++++++++--- conda_smithy/lint_recipe.py | 2 +- conda_smithy/utils.py | 2 +- conda_smithy/validate_schema.py | 7 +++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py index 72fe1a641..2dc462b1c 100644 --- a/conda_smithy/cli.py +++ b/conda_smithy/cli.py @@ -74,7 +74,7 @@ def generate_feedstock_content(target_directory, source_recipe_dir): yaml.dump(_cfg_feedstock, fp) -class Subcommand(object): +class Subcommand: #: The name of the subcommand subcommand = None aliases = [] diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 220a9ceab..8eb73cdda 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -9,7 +9,6 @@ import pprint import textwrap import time -import jsonschema import yaml import warnings from collections import Counter, OrderedDict, namedtuple @@ -1999,11 +1998,17 @@ def _read_forge_config(forge_dir, forge_yml=None): # Validate loaded configuration against a JSON schema. validate_lints, validate_hints = validate_json_schema(file_config) - for err in validate_lints: + if validate_lints: raise ExceptionGroup("lints", [*map(ValueError, validate_lints)]) + if validate_hints: + logger.warning( + "The conda-forge.yml file failed to validate. See the details below. " + "I will try to continue anyway but please don't rely on undefined behavior." + ) + for hint in validate_hints: - logger.info(hint.message) + logger.warning(hint) # The config is just the union of the defaults, and the overridden # values. diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py index 4ad495ab3..9f9c91760 100644 --- a/conda_smithy/lint_recipe.py +++ b/conda_smithy/lint_recipe.py @@ -1090,7 +1090,7 @@ def main(recipe_dir, conda_forge=False, return_hints=False): for err in validation_errors ] results.extend(validation_errors) - hints.extend([str(lint) for lint in validation_hints]) + hints.extend([str(hint) for hint in validation_hints]) if return_hints: return results, hints diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py index c20b88886..257621648 100644 --- a/conda_smithy/utils.py +++ b/conda_smithy/utils.py @@ -118,7 +118,7 @@ def render_meta_yaml(text): def update_conda_forge_config(forge_yaml): """Utility method used to update conda forge configuration files - Uage: + Usage: >>> with update_conda_forge_config(somepath) as cfg: ... cfg['foo'] = 'bar' """ diff --git a/conda_smithy/validate_schema.py b/conda_smithy/validate_schema.py index 5b9e38edd..ae752c066 100644 --- a/conda_smithy/validate_schema.py +++ b/conda_smithy/validate_schema.py @@ -48,8 +48,7 @@ def validate_json_schema(config, schema_file: str = None): lints = [] hints = [] for error in validator.iter_errors(config): - if isinstance(error, DeprecatedFieldWarning): - hints.append(error) - else: - lints.append(error) + # Currently, all schema errors are considered hints. + # If changing this, consider at least DeprecatedFieldWarning to be a hint. + hints.append(error) return lints, hints