From 5c49fc87fdb736e53c1781bbfe5503b0e31fdd41 Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Mon, 2 Dec 2024 16:57:53 +0700 Subject: [PATCH] refactor(backend): Apply lint on autogpt_lib folder on backend/linter.py (#8751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: - [ ] ...
Example test plan - [ ] 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
#### 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**)
Examples of configuration changes - Changing ports - Adding new services that need to communicate with each other - Secrets or environment variable changes - New or infrastructure changes such as databases
--------- Co-authored-by: Reinier van der Leer --- .../autogpt_libs/feature_flag/client_test.py | 3 ++- .../autogpt_libs/autogpt_libs/feature_flag/config.py | 2 +- .../autogpt_libs/autogpt_libs/utils/__init__.py | 0 autogpt_platform/backend/linter.py | 9 +++++---- 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 autogpt_platform/autogpt_libs/autogpt_libs/utils/__init__.py diff --git a/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/client_test.py b/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/client_test.py index b9d1e5c96aa1..8fccfb28b501 100644 --- a/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/client_test.py +++ b/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/client_test.py @@ -1,7 +1,8 @@ import pytest -from autogpt_libs.feature_flag.client import feature_flag, mock_flag_variation from ldclient import LDClient +from autogpt_libs.feature_flag.client import feature_flag, mock_flag_variation + @pytest.fixture def ld_client(mocker): diff --git a/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/config.py b/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/config.py index c8040a41bb8c..e01c285d1e66 100644 --- a/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/config.py +++ b/autogpt_platform/autogpt_libs/autogpt_libs/feature_flag/config.py @@ -6,7 +6,7 @@ class Settings(BaseSettings): launch_darkly_sdk_key: str = Field( default="", description="The Launch Darkly SDK key", - validation_alias="LAUNCH_DARKLY_SDK_KEY" + validation_alias="LAUNCH_DARKLY_SDK_KEY", ) model_config = SettingsConfigDict(case_sensitive=True, extra="ignore") diff --git a/autogpt_platform/autogpt_libs/autogpt_libs/utils/__init__.py b/autogpt_platform/autogpt_libs/autogpt_libs/utils/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/autogpt_platform/backend/linter.py b/autogpt_platform/backend/linter.py index 83c574b03494..9bba9d1963b6 100644 --- a/autogpt_platform/backend/linter.py +++ b/autogpt_platform/backend/linter.py @@ -2,6 +2,7 @@ import subprocess directory = os.path.dirname(os.path.realpath(__file__)) +target_dirs = ["../backend", "../autogpt_libs"] def run(*command: str) -> None: @@ -11,17 +12,17 @@ def run(*command: str) -> None: def lint(): try: - run("ruff", "check", ".", "--exit-zero") + run("ruff", "check", *target_dirs, "--exit-zero") run("isort", "--diff", "--check", "--profile", "black", ".") run("black", "--diff", "--check", ".") - run("pyright") + 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", ".") + run("ruff", "check", "--fix", *target_dirs) run("isort", "--profile", "black", ".") run("black", ".") - run("pyright", ".") + run("pyright", *target_dirs)