Skip to content

Commit

Permalink
Fix TypeError when linter: or skip: keys are empty
Browse files Browse the repository at this point in the history
Fix the error such as:

```
Traceback (most recent call last):
  File "/home/mgorny/miniforge3/bin/conda-smithy", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mgorny/git/conda-smithy/conda_smithy/cli.py", line 767, in main
    args.subcommand_func(args)
  File "/home/mgorny/git/conda-smithy/conda_smithy/cli.py", line 645, in __call__
    lints, hints = linter.main(
                   ^^^^^^^^^^^^
  File "/home/mgorny/git/conda-smithy/conda_smithy/lint_recipe.py", line 733, in main
    results, hints = lintify_meta_yaml(
                     ^^^^^^^^^^^^^^^^^^
  File "/home/mgorny/git/conda-smithy/conda_smithy/lint_recipe.py", line 281, in lintify_meta_yaml
    if "lint_noarch_selectors" not in lints_to_skip:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
```

when `conda-forge.yml` contains an empty key, e.g.:

```
linter:
  skip:
```

Noticed this accidentally while testing the other changes.
  • Loading branch information
mgorny committed Jan 6, 2025
1 parent 8cd888d commit d193973
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def lintify_meta_yaml(
lints = []
hints = []
major_sections = list(meta.keys())
lints_to_skip = (
_get_forge_yaml(recipe_dir).get("linter", {}).get("skip", [])
)
lints_to_skip = (_get_forge_yaml(recipe_dir).get("linter") or {}).get(
"skip"
) or []

# If the recipe_dir exists (no guarantee within this function) , we can
# find the meta.yaml within it.
Expand Down Expand Up @@ -487,9 +487,9 @@ def run_conda_forge_specific(
hints,
recipe_version: int = 0,
):
lints_to_skip = (
_get_forge_yaml(recipe_dir).get("linter", {}).get("skip", [])
)
lints_to_skip = (_get_forge_yaml(recipe_dir).get("linter") or {}).get(
"skip"
) or []

# Retrieve sections from meta
package_section = get_section(
Expand Down

0 comments on commit d193973

Please sign in to comment.