ci: apply black and isort formatting and add lint enforcement#516
ci: apply black and isort formatting and add lint enforcement#516stealthwhizz wants to merge 3 commits into
Conversation
Apply black and isort to all Python files to bring the codebase into compliance with the style settings already defined in pyproject.toml. Add a lint job to the CI workflow that runs black --check and isort --check-only on every push and pull request. The test job now depends on lint, so unformatted code cannot merge.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR applies automatic code formatting (Black) and import ordering (isort) across the entire codebase, and adds a CI lint job to enforce these tools on future PRs.
Changes:
- Reformat ~80+ files with Black-style line breaks, trailing commas, and parenthesization
- Reorder imports with isort (stdlib → third-party → first-party grouping)
- Add a new
lintjob to.github/workflows/test.ymlrunningblack --checkandisort --check-only, gating the existingtestjob
Reviewed changes
Copilot reviewed 132 out of 136 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/test.yml |
New lint job runs Black + isort and is now a prerequisite for tests |
finbot/agents/chat.py |
isort split a single multi-name import into two duplicate from … import … statements because of an inline pylint comment |
finbot/core/llm/ollama_client.py, finbot/core/llm/mock_client.py, finbot/core/llm/openai_client.py |
Reformat + isort; stray-whitespace cleanup; no logic changes |
finbot/ctf/**, finbot/core/**, finbot/mcp/**, finbot/apps/**, finbot/agents/**, finbot/tools/** |
Pure Black/isort reformatting; behaviour preserved |
migrations/**, scripts/** |
isort import reordering only |
tests/** |
Reformat assertion blocks, dict/list literals, and reorder imports |
Comments suppressed due to low confidence (2)
tests/unit/llm/test_llm_client.py:1
- Reformatting preserved a pre-existing operator-precedence bug that is worth fixing while the file is being touched. Python parses this as
len(request.messages) if request.messages is not None else (0 == msg_count_before)— i.e. the assertion truthiness is the length ofrequest.messages(when non-None), not a comparison, so it never actually checks that the count is unchanged. Wrap the conditional in parentheses, e.g.assert (len(request.messages) if request.messages is not None else 0) == msg_count_before, ….
finbot/core/llm/ollama_client.py:1 - Cleanup of trailing whitespace here is fine, but the bare
except Exception(originallyexcept Exception as e:) catches absolutely everything includingKeyboardInterrupt-adjacent issues that propagate asExceptionsubclasses, and the only action is to log and re-raise. Since this is purely a logging wrapper, consider narrowing the exception type (e.g.ollama-specific errors and network errors) or removing the handler entirely and logging at the call site — the current shape adds no value over the original exception and can mask programming errors. Same applies tofinbot/core/llm/mock_client.pyline 33–35.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pin black==25.11.0 and isort==7.0.0 in the lint job so a future tool release cannot change formatting defaults and break CI. Merge the two split finmail routing imports in chat.py back into a single parenthesized import with the pylint disable comment on the opening line, as isort requires.
- Replace pinned black==25.11.0 isort==7.0.0 with pip install -e .[dev] so lint job always uses versions from pyproject.toml - Scope black and isort to finbot/ tests/ to avoid scanning migrations/, scripts/, and cache directories - Add --diff flag to black so CI output shows exact changes needed
Thanks @steadhac . Will rebase once #495 merges. Switched to pip install -e ".[dev]". Versions now come from pyproject.toml in one place. |
Apply black and isort to all Python files to bring the codebase into compliance with the style settings already defined in pyproject.toml.
Add a lint job to the CI workflow that runs black --check and isort --check-only on every push and pull request. The test job now depends on lint, so unformatted code cannot merge.