mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-16 19:12:25 +03:00
Fix Ruff issue
This commit is contained in:
parent
9275c8f13d
commit
ea151466bf
|
@ -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
|
||||
|
|
|
@ -8,6 +8,11 @@ PACKAGE_JSON = TEMPLATED_ROOT / "package.json"
|
|||
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()
|
||||
|
@ -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():
|
||||
|
|
|
@ -10,6 +10,11 @@ PRE_COMMIT_CONFIG = TEMPLATED_ROOT / ".pre-commit-config.yaml"
|
|||
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()
|
||||
|
@ -17,7 +22,7 @@ def main():
|
|||
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():
|
||||
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user