ci: apply black and isort formatting and add lint enforcement#516
Open
stealthwhizz wants to merge 2 commits into
Open
ci: apply black and isort formatting and add lint enforcement#516stealthwhizz wants to merge 2 commits into
stealthwhizz wants to merge 2 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.