mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
linter.py, only applies in the `backend` module, not `autogpt_libs`. The scope of this PR is to clear this out. ### Changes 🏗️ * Add a linting scope to both the `backend` & `autogpt_libs` modules, and apply the linter. ### Checklist 📋 #### For code changes: - [ ] I have clearly listed my changes in the PR description - [ ] I have made a test plan - [ ] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [ ] ... <details> <summary>Example test plan</summary> - [ ] Create from scratch and execute an agent with at least 3 blocks - [ ] Import an agent from file upload, and confirm it executes correctly - [ ] Upload agent to marketplace - [ ] Import an agent from marketplace and confirm it executes correctly - [ ] Edit an agent from monitor, and confirm it executes correctly </details> #### For configuration changes: - [ ] `.env.example` is updated or already compatible with my changes - [ ] `docker-compose.yml` is updated or already compatible with my changes - [ ] I have included a list of my configuration changes in the PR description (under **Changes**) <details> <summary>Examples of configuration changes</summary> - Changing ports - Adding new services that need to communicate with each other - Secrets or environment variable changes - New or infrastructure changes such as databases </details> --------- Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
29 lines
852 B
Python
29 lines
852 B
Python
import os
|
|
import subprocess
|
|
|
|
directory = os.path.dirname(os.path.realpath(__file__))
|
|
target_dirs = ["../backend", "../autogpt_libs"]
|
|
|
|
|
|
def run(*command: str) -> None:
|
|
print(f">>>>> Running poetry run {' '.join(command)}")
|
|
subprocess.run(["poetry", "run"] + list(command), cwd=directory, check=True)
|
|
|
|
|
|
def lint():
|
|
try:
|
|
run("ruff", "check", *target_dirs, "--exit-zero")
|
|
run("isort", "--diff", "--check", "--profile", "black", ".")
|
|
run("black", "--diff", "--check", ".")
|
|
run("pyright", *target_dirs)
|
|
except subprocess.CalledProcessError as e:
|
|
print("Lint failed, try running `poetry run format` to fix the issues: ", e)
|
|
raise e
|
|
|
|
|
|
def format():
|
|
run("ruff", "check", "--fix", *target_dirs)
|
|
run("isort", "--profile", "black", ".")
|
|
run("black", ".")
|
|
run("pyright", *target_dirs)
|