ref: Auto-fix ruff rules in tests (#4154)
This commit is contained in:
parent
51b3909d60
commit
45c8f98692
80 changed files with 359 additions and 456 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import sys
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import packaging.version
|
||||
|
|
@ -10,39 +10,38 @@ BASE_DIR = Path(__file__).parent.parent.parent
|
|||
def update_base_dep(pyproject_path: str, new_version: str) -> None:
|
||||
"""Update the langflow-base dependency in pyproject.toml."""
|
||||
filepath = BASE_DIR / pyproject_path
|
||||
content = filepath.read_text()
|
||||
content = filepath.read_text(encoding="utf-8")
|
||||
|
||||
replacement = f'langflow-base-nightly = "{new_version}"'
|
||||
|
||||
# Updates the pattern for poetry
|
||||
pattern = re.compile(r'langflow-base = \{ path = "\./src/backend/base", develop = true \}')
|
||||
if not pattern.search(content):
|
||||
raise Exception(f'langflow-base poetry dependency not found in "{filepath}"')
|
||||
msg = f'langflow-base poetry dependency not found in "{filepath}"'
|
||||
raise Exception(msg)
|
||||
content = pattern.sub(replacement, content)
|
||||
filepath.write_text(content)
|
||||
filepath.write_text(content, encoding="utf-8")
|
||||
|
||||
|
||||
def verify_pep440(version):
|
||||
"""
|
||||
Verify if version is PEP440 compliant.
|
||||
"""Verify if version is PEP440 compliant.
|
||||
|
||||
https://github.com/pypa/packaging/blob/16.7/packaging/version.py#L191
|
||||
"""
|
||||
|
||||
try:
|
||||
return packaging.version.Version(version)
|
||||
except packaging.version.InvalidVersion as e:
|
||||
raise e
|
||||
except packaging.version.InvalidVersion:
|
||||
raise
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) != 2:
|
||||
raise Exception("New version not specified")
|
||||
msg = "New version not specified"
|
||||
raise Exception(msg)
|
||||
base_version = sys.argv[1]
|
||||
|
||||
# Strip "v" prefix from version if present
|
||||
if base_version.startswith("v"):
|
||||
base_version = base_version[1:]
|
||||
base_version = base_version.removeprefix("v")
|
||||
|
||||
verify_pep440(base_version)
|
||||
update_base_dep("pyproject.toml", base_version)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue