Skip to content

Commit

Permalink
fix lint_recipe_dir_inside_example_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausch committed Apr 5, 2024
1 parent 5fbe8f1 commit a654438
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conda_smithy/linters_meta_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def lint_recipe_dir_inside_example_dir(
"""
recipe_dir = extras.recipe_dir

if recipe_dir and "recipes/example/" in str(recipe_dir):
if recipe_dir and "recipes/example/" in str(recipe_dir) + "/":
return LintsHints.lint(
"Please move the recipe out of the example dir and "
"into its own dir."
Expand Down
5 changes: 5 additions & 0 deletions conda_smithy/linting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def __add__(self, other: Any) -> LintsHints:
hints=self.hints + other.hints,
)

def __eq__(self, other: Any) -> bool:
if not isinstance(other, LintsHints):
return NotImplemented
return self.lints == other.lints and self.hints == other.hints

def append_lint(self, lint: str) -> None:
if lint in self.lints:
return
Expand Down
23 changes: 23 additions & 0 deletions tests/test_linters_meta_yaml.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import inspect
import unittest
from pathlib import Path
from typing import Set, Callable

from conda_smithy import linters_meta_yaml
from conda_smithy.linters_meta_yaml import MetaYamlLintExtras
from conda_smithy.linting_utils import LintsHints


class TestLintersMetaYaml(unittest.TestCase):
def test_lint_recipe_dir_inside_example_dir_no_recipe_dir(self):
results = linters_meta_yaml.lint_recipe_dir_inside_example_dir(
{}, MetaYamlLintExtras(is_conda_forge=True)
)

self.assertEqual(results, LintsHints())

def test_lint_recipe_dir_inside_example_dir(self):
recipe_dir = Path("recipes") / "example"

results = linters_meta_yaml.lint_recipe_dir_inside_example_dir(
{}, MetaYamlLintExtras(recipe_dir, is_conda_forge=True)
)

message = "Please move the recipe out of the example dir and into its own dir."

self.assertIn(message, results.lints)


def test_complete_linter_list():
module_linters: Set[Callable[..., LintsHints]] = set()

Expand Down

0 comments on commit a654438

Please sign in to comment.