From daa07b727cfc1254d18451b49fc52d714cc43cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Mon, 8 Jan 2024 22:21:06 +0100 Subject: [PATCH 1/7] Update load data functions to linting Add the rest of load data from files functions existing from the current conda-build version --- conda_smithy/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py index b0be1a656..3461ad69d 100644 --- a/conda_smithy/utils.py +++ b/conda_smithy/utils.py @@ -97,6 +97,9 @@ def render_meta_yaml(text): pin_compatible=stub_compatible_pin, cdt=lambda *args, **kwargs: "cdt_stub", load_file_regex=lambda *args, **kwargs: defaultdict(lambda: ""), + load_file_data=lambda *args, **kwargs: defaultdict(lambda: ""), + load_setup_py_data=lambda *args, **kwargs: defaultdict(lambda: ""), + load_str_data=lambda *args, **kwargs: defaultdict(lambda: ""), datetime=datetime, time=time, target_platform="linux-64", From b5511a045ced29f4ca4480b038470dcaaf605e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Tue, 9 Jan 2024 15:01:48 +0100 Subject: [PATCH 2/7] Add tests --- tests/test_lint_recipe.py | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 6bdfbefaa..f11e53cd6 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -674,6 +674,57 @@ def test_jinja_load_file_regex(self): ) lints = linter.main(recipe_dir) + def test_jinja_load_file_data(self): + # Test that we can use load_file_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting + # TODO: add *args and **kwargs for functions used to parse the file + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_setup_py_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + + def test_jinja_load_setup_py_data(self): + # Test that we can use load_file_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting + # TODO: add *args and **kwargs for functions used to parse the file + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_setup_py_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + + def test_jinja_load_str_data(self): + # Test that we can use load_file_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting + # TODO: add *args and **kwargs for functions used to parse the data + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_str_data("IDONTNEED", "json") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + def test_jinja_os_sep(self): # Test that we can use os.sep in a recipe. with tmp_directory() as recipe_dir: From 3760c7ec008d1cdf3e4ad496830e399786926587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Tue, 9 Jan 2024 15:02:11 +0100 Subject: [PATCH 3/7] Add news entry --- news/PR1829_load-data-fun.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/PR1829_load-data-fun.rst diff --git a/news/PR1829_load-data-fun.rst b/news/PR1829_load-data-fun.rst new file mode 100644 index 000000000..b373f11a1 --- /dev/null +++ b/news/PR1829_load-data-fun.rst @@ -0,0 +1,23 @@ +**Added:** + +* Complete conda-build load data functions stubs PR #1829 + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 939941d3cb723e5137ebdd24fa1814171e79e9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Tue, 9 Jan 2024 15:05:19 +0100 Subject: [PATCH 4/7] Trimming trailing spaces --- tests/test_lint_recipe.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index f11e53cd6..bd4c3d0f8 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -676,9 +676,9 @@ def test_jinja_load_file_regex(self): def test_jinja_load_file_data(self): # Test that we can use load_file_data in a recipe. We don't care about - # the results here and/or the actual file data because the recipe linter - # renders conda-build functions to just function stubs to pass the linting - # TODO: add *args and **kwargs for functions used to parse the file + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the file. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( @@ -693,9 +693,9 @@ def test_jinja_load_file_data(self): def test_jinja_load_setup_py_data(self): # Test that we can use load_file_data in a recipe. We don't care about - # the results here and/or the actual file data because the recipe linter - # renders conda-build functions to just function stubs to pass the linting - # TODO: add *args and **kwargs for functions used to parse the file + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the file. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( @@ -710,9 +710,9 @@ def test_jinja_load_setup_py_data(self): def test_jinja_load_str_data(self): # Test that we can use load_file_data in a recipe. We don't care about - # the results here and/or the actual file data because the recipe linter - # renders conda-build functions to just function stubs to pass the linting - # TODO: add *args and **kwargs for functions used to parse the data + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the data. with tmp_directory() as recipe_dir: with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( From 3e3eb9a70501923832539c68dea7b32cbe063e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Tue, 9 Jan 2024 22:54:56 +0100 Subject: [PATCH 5/7] Fixing tests/test_lint_recipe.py comment Co-authored-by: Uwe L. Korn --- tests/test_lint_recipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index bd4c3d0f8..92c7937db 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -692,7 +692,7 @@ def test_jinja_load_file_data(self): lints = linter.main(recipe_dir) def test_jinja_load_setup_py_data(self): - # Test that we can use load_file_data in a recipe. We don't care about + # Test that we can use load_setup_py_data in a recipe. We don't care about # the results here and/or the actual file data because the recipe linter # renders conda-build functions to just function stubs to pass the linting. # TODO: add *args and **kwargs for functions used to parse the file. From c7c638042ff6acd766b28de27922cc74081971a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Tue, 9 Jan 2024 22:55:12 +0100 Subject: [PATCH 6/7] Fixing tests/test_lint_recipe.py comment Co-authored-by: Uwe L. Korn --- tests/test_lint_recipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 92c7937db..e62b41f9f 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -709,7 +709,7 @@ def test_jinja_load_setup_py_data(self): lints = linter.main(recipe_dir) def test_jinja_load_str_data(self): - # Test that we can use load_file_data in a recipe. We don't care about + # Test that we can use load_str_data in a recipe. We don't care about # the results here and/or the actual file data because the recipe linter # renders conda-build functions to just function stubs to pass the linting. # TODO: add *args and **kwargs for functions used to parse the data. From af71682094609378096354333a343771242eb629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=2E=20Cofi=C3=B1o?= Date: Mon, 15 Jan 2024 19:36:45 +0100 Subject: [PATCH 7/7] Update tests/test_lint_recipe.py Co-authored-by: Uwe L. Korn --- tests/test_lint_recipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index e62b41f9f..c385f0be9 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -683,7 +683,7 @@ def test_jinja_load_file_data(self): with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: fh.write( """ - {% set data = load_setup_py_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} + {% set data = load_file_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} package: name: foo version: {{ version }}