Skip to content

Commit

Permalink
Merge pull request #1829 from cofinoa/add_stub_functions_linting
Browse files Browse the repository at this point in the history
Complete conda-build load data functions stubs
  • Loading branch information
xhochy authored Jan 15, 2024
2 parents 29f1ae3 + af71682 commit 30d4485
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conda_smithy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions news/PR1829_load-data-fun.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Complete conda-build load data functions stubs PR #1829

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
51 changes: 51 additions & 0 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_file_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_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.
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_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.
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:
Expand Down

0 comments on commit 30d4485

Please sign in to comment.