diff --git a/conda_smithy/linter/conda_recipe_v1_linter.py b/conda_smithy/linter/conda_recipe_v1_linter.py index 53be7cc1c..c07c760d4 100644 --- a/conda_smithy/linter/conda_recipe_v1_linter.py +++ b/conda_smithy/linter/conda_recipe_v1_linter.py @@ -134,6 +134,11 @@ def lint_recipe_name( lints: list[str], ) -> None: name = get_recipe_name(recipe_content) + # Avoid false positives if the recipe is using variables + # from conda_build_config.yaml. + # https://github.com/conda-forge/conda-smithy/issues/2224 + if "${{" in name: + return lint_msg = _lint_recipe_name(name) if lint_msg: diff --git a/news/2248-v1-recipe-name-var.rst b/news/2248-v1-recipe-name-var.rst new file mode 100644 index 000000000..222647d5e --- /dev/null +++ b/news/2248-v1-recipe-name-var.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Fixed a false positive when a v1 recipe name refers to a variable from ``conda_build_config.yaml`` (#2248). + +**Security:** + +* diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index ef8264e8a..2a95b3ba6 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -1793,22 +1793,20 @@ def test_recipe_v1_recipe_name(self): lints, _ = linter.lintify_meta_yaml( meta_with_context, recipe_version=1 ) - expected_message = ( - "Recipe name has invalid characters. only lowercase alpha, " - "numeric, underscores, hyphens and dots allowed" - ) self.assertIn(expected_message, lints) meta_with_context = {"recipe": {"name": "mp++"}, "outputs": []} # noqa lints, _ = linter.lintify_meta_yaml( meta_with_context, recipe_version=1 ) - expected_message = ( - "Recipe name has invalid characters. only lowercase alpha, " - "numeric, underscores, hyphens and dots allowed" - ) self.assertIn(expected_message, lints) + # variable may be defined e.g. in conda_build_config.yaml + # https://github.com/conda-forge/conda-smithy/issues/2224 + meta = {"package": {"name": "${{ variant_name }}"}} + lints, _ = linter.lintify_meta_yaml(meta, recipe_version=1) + self.assertNotIn(expected_message, lints) + def test_end_empty_line(self): bad_contents = [ # No empty lines at the end of the file