Skip to content

Commit

Permalink
Incorporates JC's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
schuylermartin45 committed Dec 20, 2023
1 parent 5646374 commit 0f9d650
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions anaconda_linter/lint/check_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def check_recipe(self, recipe) -> None:
# Search all dependencies for missing whitespace
for path in check_paths:
output: Final[int] = -1 if not path.startswith("/outputs") else int(path.split("/")[2])
n = int(path.split("/")[-1])
spec = cast(str, ro_parser.get_value(path))
has_constraints = version_constraints_missing_whitespace._CONSTRAINTS_RE.search(spec)
if not has_constraints:
Expand All @@ -50,7 +49,7 @@ def check_recipe(self, recipe) -> None:
dependency, version = has_constraints.groups()
new_dependency: Final[str] = f"{dependency} {version}"
self.message(
section=f"{path}/{n}",
section=path,
data={"path": path, "new_dependency": new_dependency},
output=output,
)
Expand All @@ -59,12 +58,12 @@ def fix(self, message, data) -> bool:
path = cast(str, data["path"])
new_dependency = cast(str, data["new_dependency"])

def _rm_whitespace(parser: RecipeParser):
def _add_whitespace(parser: RecipeParser):
selector: Final[str] = (
"" if not parser.contains_selector_at_path(path) else parser.get_selector_at_path(path)
)
parser.patch({"op": "replace", "path": path, "value": new_dependency})
if selector:
parser.add_selector(path, selector)

return self.recipe.patch_with_parser(_rm_whitespace)
return self.recipe.patch_with_parser(_add_whitespace)

0 comments on commit 0f9d650

Please # to comment.