parent
3a034476f4
commit
c8d537c7ab
@ -0,0 +1,22 @@
|
|||||||
|
[flake8]
|
||||||
|
max-line-length = 88
|
||||||
|
extend-ignore = E203, W503
|
||||||
|
exclude =
|
||||||
|
.git,
|
||||||
|
__pycache__,
|
||||||
|
build,
|
||||||
|
dist,
|
||||||
|
*.egg-info,
|
||||||
|
.eggs,
|
||||||
|
.tox,
|
||||||
|
.venv,
|
||||||
|
venv,
|
||||||
|
.env,
|
||||||
|
.pytest_cache,
|
||||||
|
.coverage,
|
||||||
|
htmlcov,
|
||||||
|
.mypy_cache,
|
||||||
|
.ruff_cache
|
||||||
|
per-file-ignores =
|
||||||
|
__init__.py: F401
|
||||||
|
max-complexity = 10
|
@ -0,0 +1,4 @@
|
|||||||
|
[pyupgrade]
|
||||||
|
py3-plus = True
|
||||||
|
py39-plus = True
|
||||||
|
keep-runtime-typing = True
|
@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def run_command(command: list[str], cwd: Path) -> bool:
|
||||||
|
"""Run a command and return True if successful."""
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
command,
|
||||||
|
cwd=cwd,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error running {' '.join(command)}:")
|
||||||
|
print(e.stdout)
|
||||||
|
print(e.stderr, file=sys.stderr)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run all code quality checks."""
|
||||||
|
root_dir = Path(__file__).parent.parent
|
||||||
|
success = True
|
||||||
|
|
||||||
|
# Run flake8
|
||||||
|
print("\nRunning flake8...")
|
||||||
|
if not run_command(["flake8", "swarms", "tests"], root_dir):
|
||||||
|
success = False
|
||||||
|
|
||||||
|
# Run pyupgrade
|
||||||
|
print("\nRunning pyupgrade...")
|
||||||
|
if not run_command(["pyupgrade", "--py39-plus", "swarms", "tests"], root_dir):
|
||||||
|
success = False
|
||||||
|
|
||||||
|
# Run black
|
||||||
|
print("\nRunning black...")
|
||||||
|
if not run_command(["black", "--check", "swarms", "tests"], root_dir):
|
||||||
|
success = False
|
||||||
|
|
||||||
|
# Run ruff
|
||||||
|
print("\nRunning ruff...")
|
||||||
|
if not run_command(["ruff", "check", "swarms", "tests"], root_dir):
|
||||||
|
success = False
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
print("\nCode quality checks failed. Please fix the issues and try again.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("\nAll code quality checks passed!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in new issue