From 2ad7036d1c93d68c92cf2c1c31b664ebfffbe6e8 Mon Sep 17 00:00:00 2001 From: xkam7ar Date: Thu, 16 Jul 2026 11:26:43 -0700 Subject: [PATCH] build: install Black and Ruff for contributors Signed-off-by: xkam7ar --- CONTRIBUTING.md | 8 ++++++++ agent/tests/test_packaging_dependencies.py | 7 +++++++ pyproject.toml | 2 ++ 3 files changed, 17 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13ef08b4..bbaa220c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,6 +140,14 @@ merging. Authors are strongly encouraged to self-check first. ## Code Style - Format with `black`; lint with `ruff` (config in `pyproject.toml`). +- Install both tools with the development extra: `pip install -e ".[dev]"`. +- Run them on the Python files you changed, for example: + ```bash + black --check agent/src/example.py agent/tests/test_example.py + ruff check agent/src/example.py agent/tests/test_example.py + ``` + The repository does not yet enforce a whole-tree Black or Ruff check, so + avoid mixing unrelated formatting cleanup into a focused pull request. - Type-annotate all public function and method signatures. - Google-style docstrings (`Args:` / `Returns:` / `Raises:`). - Keep files under 400 lines where practical, 800 hard cap. diff --git a/agent/tests/test_packaging_dependencies.py b/agent/tests/test_packaging_dependencies.py index d1de9a6f..f97ff39c 100644 --- a/agent/tests/test_packaging_dependencies.py +++ b/agent/tests/test_packaging_dependencies.py @@ -136,3 +136,10 @@ def test_channel_optional_extras_cover_all_sdk_backed_adapters() -> None: "wecom-aibot-sdk", } assert expected_packages.issubset(channel_extra) +def test_development_extra_includes_bounded_style_tools() -> None: + """Contributor style commands should be installed by the dev extra.""" + pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text()) + dev_extra = pyproject["project"]["optional-dependencies"]["dev"] + + assert "black>=24.0,<27" in dev_extra + assert "ruff>=0.9,<1" in dev_extra diff --git a/pyproject.toml b/pyproject.toml index 632ff578..0b76d346 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -182,9 +182,11 @@ channels = [ "wecom-aibot-sdk>=1.0.0", ] dev = [ + "black>=24.0,<27", "pytest>=7.0", "pytest-cov>=4.0", "pytest-socket>=0.7.0", + "ruff>=0.9,<1", ] [tool.pytest.ini_options]