Skip to content

Commit

Permalink
lint for noarch python withotu a bound on python version
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Oct 22, 2020
1 parent d6fc367 commit b7514aa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,18 @@ def lintify(meta, recipe_dir=None, conda_forge=False):
" form. See lines %s." % (bad_lines,)
)

# 25: require a lower bound on python version
if build_section.get("noarch") == "python" and not outputs_section:
for req in run_reqs:
if req.startswith("python") and req != "python":
break
else:
lints.append(
"noarch: python recipes are recommended to have a lower bound "
"on minimum python bound. This recommendation will become "
"requirement in a future version."
)

# hints
# 1: suggest pip
if "script" in build_section:
Expand Down
27 changes: 27 additions & 0 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,33 @@ def test_bad_requirements_order(self):
lints, hints = linter.lintify(meta)
self.assertNotIn(expected_message, lints)

def test_noarch_python_bound(self):
expected_message = (
"noarch: python recipes are recommended to have a lower bound "
"on minimum python bound. This recommendation will become "
"requirement in a future version."
)
meta = {
"build": {"noarch": "python"},
"requirements": {"host": ["python",], "run": ["python",]},
}
lints, hints = linter.lintify(meta)
self.assertIn(expected_message, lints)

meta = {
"build": {"noarch": "python"},
"requirements": {"host": ["python",], "run": ["python >=2.7",]},
}
lints, hints = linter.lintify(meta)
self.assertNotIn(expected_message, lints)

meta = {
"build": {"noarch": "generic"},
"requirements": {"host": ["python",], "run": ["python",]},
}
lints, hints = linter.lintify(meta)
self.assertNotIn(expected_message, lints)

def test_no_sha_with_dl(self):
expected_message = (
"When defining a source/url please add a sha256, "
Expand Down

0 comments on commit b7514aa

Please sign in to comment.