Skip to content

Commit

Permalink
schema validation errors are hints, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausch committed Mar 25, 2024
1 parent 0aed6d7 commit 926c8a7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
11 changes: 8 additions & 3 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pprint
import textwrap
import time
import jsonschema
import yaml
import warnings
from collections import Counter, OrderedDict, namedtuple
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
"""
Expand Down
7 changes: 3 additions & 4 deletions conda_smithy/validate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 926c8a7

Please sign in to comment.