mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-04-10 20:04:18 +03:00
Merge branch 'master' into lint-format-template-with-ruff
# Conflicts: # scripts/ruff_version.py
This commit is contained in:
commit
ea6661018c
|
@ -12,7 +12,7 @@ trim_trailing_whitespace = true
|
|||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{html,css,scss,json,yml,xml}]
|
||||
[*.{html,css,scss,json,yml,xml,toml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -10,7 +12,7 @@ PRE_COMMIT_CONFIG = TEMPLATED_ROOT / ".pre-commit-config.yaml"
|
|||
PYPROJECT_TOML = ROOT / "pyproject.toml"
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
new_version = get_requirements_txt_version()
|
||||
old_version = get_pyproject_toml_version()
|
||||
if old_version == new_version:
|
||||
|
@ -20,23 +22,23 @@ def main():
|
|||
subprocess.run(["uv", "lock", "--no-upgrade"], cwd=ROOT, check=False) # noqa: S603,S607
|
||||
|
||||
|
||||
def get_requirements_txt_version():
|
||||
def get_requirements_txt_version() -> str:
|
||||
content = REQUIREMENTS_LOCAL_TXT.read_text()
|
||||
for line in content.split("\n"):
|
||||
if line.startswith("ruff"):
|
||||
return line.split(" ")[0].split("==")[1]
|
||||
return None
|
||||
raise RuntimeError("Could not find ruff version in requirements/local.txt")
|
||||
|
||||
|
||||
def get_pyproject_toml_version():
|
||||
def get_pyproject_toml_version() -> str:
|
||||
data = tomllib.loads(PYPROJECT_TOML.read_text())
|
||||
for dependency in data["project"]["dependencies"]:
|
||||
if dependency.startswith("ruff=="):
|
||||
return dependency.split("==")[1]
|
||||
raise RuntimeError("Could not find version in pyproject.toml")
|
||||
raise RuntimeError("Could not find ruff version in pyproject.toml")
|
||||
|
||||
|
||||
def update_ruff_version(old_version, new_version):
|
||||
def update_ruff_version(old_version: str, new_version: str) -> None:
|
||||
# Update pyproject.toml
|
||||
new_content = PYPROJECT_TOML.read_text().replace(
|
||||
f"ruff=={old_version}",
|
||||
|
|
Loading…
Reference in New Issue
Block a user