Skip to content

Commit

Permalink
Fix Ruff issue
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Jan 11, 2025
1 parent 9275c8f commit ea15146
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ lint.select = [
"YTT",
]
lint.ignore = [
"EM101",
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/
"SIM102", # sometimes it's better to nest
Expand Down
6 changes: 6 additions & 0 deletions scripts/node_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
CI_YML = ROOT / ".github" / "workflows" / "ci.yml"


class VersionNotFoundError(RuntimeError):
def __init__(self):
super().__init__("Could not find version in Dockerfile")


def main():
new_version = get_version_from_dockerfile()
old_version = get_version_from_package_json()
Expand All @@ -26,6 +31,7 @@ def get_version_from_dockerfile():
_, _, docker_tag = line.partition(":")
version_str, _, _ = docker_tag.partition("-")
return version_str
raise VersionNotFoundError


def get_version_from_package_json():
Expand Down
8 changes: 7 additions & 1 deletion scripts/ruff_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
PYPROJECT_TOML = ROOT / "pyproject.toml"


class VersionNotFoundError(RuntimeError):
def __init__(self, filename):
super().__init__(f"Could not find version in {filename}")


def main():
new_version = get_requirements_txt_version()
old_version = get_pyproject_toml_version()
if old_version == new_version:
return

update_ruff_version(old_version, new_version)
subprocess.run(["uv", "lock", "--no-upgrade"], cwd=ROOT, check=False)
subprocess.run(["uv", "lock", "--no-upgrade"], cwd=ROOT, check=False) # noqa: S603,S607


def get_requirements_txt_version():
Expand All @@ -33,6 +38,7 @@ def get_pyproject_toml_version():
for dependency in data["project"]["dependencies"]:
if dependency.startswith("ruff=="):
return dependency.split("==")[1]
raise VersionNotFoundError("pyproject.toml")


def update_ruff_version(old_version, new_version):
Expand Down

0 comments on commit ea15146

Please sign in to comment.