Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruff rule PLW2901 "redefine loop name" #216

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pixl_ehr/src/pixl_ehr/_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ def _replace_placeholders_and_populate_values(self, context: dict) -> None:
continue

for key, value in context.items():
line = line.replace("${{ " + str(key) + " }}", str(value)) # noqa: PLW2901
new_line = line.replace("${{ " + str(key) + " }}", str(value))

n = line.count(f":{key}")
n = new_line.count(f":{key}")
self.values += n * [value]
line = line.replace(f":{key}", "%s") # noqa: PLW2901
new_line = new_line.replace(f":{key}", "%s")

if ":" in line.replace("::", "") or "${{" in line:
if ":" in new_line.replace("::", "") or "${{" in new_line:
msg = (
"Had an insufficient context to replace "
f"line {i} in {self._filepath}\n"
f"{line}"
f"new_line {i} in {self._filepath}\n"
f"{new_line}"
)
raise RuntimeError(msg)
self._lines[i] = line
self._lines[i] = new_line
Loading