Skip to content

ci: apply black and isort formatting and add lint enforcement#516

Open
stealthwhizz wants to merge 2 commits into
GenAI-Security-Project:mainfrom
stealthwhizz:ci/black-isort-enforcement
Open

ci: apply black and isort formatting and add lint enforcement#516
stealthwhizz wants to merge 2 commits into
GenAI-Security-Project:mainfrom
stealthwhizz:ci/black-isort-enforcement

Conversation

@stealthwhizz
Copy link
Copy Markdown
Contributor

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.

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.
Copilot AI review requested due to automatic review settings May 29, 2026 16:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lint job to .github/workflows/test.yml running black --check and isort --check-only, gating the existing test job

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 of request.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 (originally except Exception as e:) catches absolutely everything including KeyboardInterrupt-adjacent issues that propagate as Exception subclasses, 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 to finbot/core/llm/mock_client.py line 33–35.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread finbot/agents/chat.py Outdated
Comment thread .github/workflows/test.yml Outdated
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants