Skip to content

chore: adopt ruff as the linter, replace flake8#2511

Open
shmulc8 wants to merge 1 commit into
feature/uv-migrationfrom
feature/ruff-linter
Open

chore: adopt ruff as the linter, replace flake8#2511
shmulc8 wants to merge 1 commit into
feature/uv-migrationfrom
feature/ruff-linter

Conversation

@shmulc8

@shmulc8 shmulc8 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Stacked on the uv migration (#2509). Base is feature/uv-migration so this diff shows only the ruff changes; retarget to main once #2509 merges.

What

Consolidates linting on ruff and, crucially, makes it enforced — ruff was already configured in pyproject.toml but never run in CI.

  • Replace flake8 with ruff (pinned 0.15.20) in the dev group; enable the ruff pre-commit hook and drop the now-redundant isort hook (ruff sorts imports). The existing pre-commit.yml workflow now enforces linting on every PR.
  • Apply ruff's safe autofixes only: remove unused imports (F401), collapse f-strings without placeholders (F541), sort imports (I001) — 302 fixes across 72 files. Also removed a duplicate GiteaProvider import.
  • Defer pre-existing violations (E501, bare-except, bugbear rules, …) via an explicit lint.ignore list with a TODO to burn it down, so ruff runs green on adoption without a mass-churn reformat. F821 is scoped to pr_similar_issue.py (its optional deps are imported lazily).
  • Update AGENTS.md to run ruff check instead of flake8.

Deliberately NOT included

ruff format (repo-wide formatting) — that's a large diff best done as its own PR plus a .git-blame-ignore-revs entry.

Verification

  • ruff checkAll checks passed; ruff pre-commit hook passes.
  • PYTHONPATH=. uv run pytest tests/unittest1245 passed (autofixes broke nothing).

Follow-up debt (flagged, not fixed here)

  • F811 — two real redefinitions worth a look: a shadowed handle_github_webhooks in bitbucket_app.py:311 and a re-imported Request in azuredevops_server_webhook.py:18.
  • The lint.ignore list is the debt ledger — each entry is a rule to clean up and re-enable.

🤖 Generated with Claude Code

- Replace flake8 with ruff (pinned 0.15.20) in the dev group and enable the
  ruff pre-commit hook; drop the now-redundant isort hook (ruff sorts
  imports). The existing pre-commit CI workflow now actually enforces
  linting, which the configured-but-unused ruff never did.
- Apply ruff's safe autofixes: remove unused imports (F401), collapse
  f-strings without placeholders (F541), sort imports (I001) — 302 fixes
  across 72 files, tests still green.
- Defer pre-existing violations (E501, bare-except, bugbear rules, etc.)
  via an explicit ignore list with a TODO to burn it down, so ruff runs
  green on adoption without a mass-churn reformat. Scope F821 to the
  similar-issue tool's lazy optional imports.
- Update AGENTS.md to run `ruff check` instead of flake8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADg72cCmirPo9W3E74Htyk
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Adopt Ruff as enforced linter (replace flake8) and apply safe autofixes

⚙️ Configuration changes ✨ Enhancement 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Replace flake8/isort with Ruff and enforce linting via pre-commit/CI.
• Enable Ruff safe autofixes (unused imports, import sorting, f-string cleanup) across codebase.
• Add explicit Ruff ignore ledger and update contributor guidance to use ruff check.
Diagram

graph TD
  D["Developer"] --> PC["pre-commit"] --> RH["Ruff hook"] --> RCFG["pyproject Ruff config"]
  CI["CI: pre-commit workflow"] --> PC
  RH --> CODE["Repo Python code"]
  RCFG --> RH
  subgraph Legend
    direction LR
    _person["Actor"] ~~~ _tool["Tooling"] ~~~ _cfg["Config"] ~~~ _code["Code"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add a dedicated CI Ruff step (without `--fix`)
  • ➕ CI behavior becomes explicit (ruff check), independent of pre-commit setup
  • ➕ Avoids any perception of CI mutating code (even though pre-commit in CI typically doesn't commit)
  • ➖ Duplicates configuration/logic between pre-commit and CI
  • ➖ Developers may still bypass local checks unless pre-commit is installed
2. Adopt `ruff format` in the same PR
  • ➕ One-time convergence on a consistent formatter
  • ➕ Reduces future diff noise due to style drift
  • ➖ Large churn and noisy review/blame without .git-blame-ignore-revs planning
  • ➖ Higher merge conflict risk with parallel work
3. Burn down ignores incrementally using `lint.extend-ignore` per package
  • ➕ Keeps global rule set stricter while scoping legacy debt by module
  • ➕ Makes debt ownership clearer (which package still violates what)
  • ➖ More config complexity
  • ➖ Requires decisions about package boundaries and ownership

Recommendation: The PR’s approach is a pragmatic Ruff adoption: enforce Ruff via pre-commit/CI, apply only safe autofixes, and explicitly ledger pre-existing violations to keep the initial transition green. Consider adding a follow-up dedicated ruff check CI step (non-fixing) if you want enforcement to be transparent outside the pre-commit abstraction, and tackle ignore burn-down in small, scoped PRs.

Files changed (74) +414 / -415

Refactor (49) +325 / -321
langchain_ai_handler.pyRemove unused import and normalize import ordering +1/-2

Remove unused import and normalize import ordering

• Drops an unused 'functools' import and adjusts import order to satisfy Ruff. No functional behavior change intended.

pr_agent/algo/ai_handlers/langchain_ai_handler.py

litellm_ai_handler.pyRuff-driven import formatting and f-string simplification +15/-11

Ruff-driven import formatting and f-string simplification

• Reformats multi-import statements into Ruff-preferred style and adjusts helper imports. Simplifies an f-string without placeholders into a plain string.

pr_agent/algo/ai_handlers/litellm_ai_handler.py

openai_ai_handler.pyRemove unused BaseAiHandler import +1/-1

Remove unused BaseAiHandler import

• Removes an unused 'BaseAiHandler' import at module top and keeps remaining imports intact. This aligns the file with Ruff unused-import rules.

pr_agent/algo/ai_handlers/openai_ai_handler.py

cli_args.pyDrop unused base64/hashlib imports +2/-2

Drop unused base64/hashlib imports

• Removes unused names from the base64 import and deletes an unused 'hashlib' import. Keeps only 'b64decode' which is referenced.

pr_agent/algo/cli_args.py

git_patch_processing.pyRemove unused type import +1/-1

Remove unused type import

• Stops importing 'FilePatchInfo' from 'pr_agent.algo.types' when only 'EDIT_TYPE' is used. Pure lint clean-up.

pr_agent/algo/git_patch_processing.py

pr_processing.pyImport reformatting and no-placeholder f-string cleanup +7/-6

Import reformatting and no-placeholder f-string cleanup

• Reformats multi-line imports for Ruff and removes unused type imports. Converts a couple logging f-strings without placeholders to plain strings.

pr_agent/algo/pr_processing.py

token_handler.pyNormalize imports and whitespace per Ruff +3/-2

Normalize imports and whitespace per Ruff

• Reorders standard-library imports and adds a blank line after a dynamic import for Ruff formatting expectations. No logic changes intended.

pr_agent/algo/token_handler.py

utils.pyRemove unused import and simplify constant f-strings +40/-41

Remove unused import and simplify constant f-strings

• Drops an unused 'ast' import and replaces numerous f-strings without placeholders with plain string literals. This reduces noise and satisfies Ruff F541.

pr_agent/algo/utils.py

config_loader.pyReorder imports to satisfy linting +1/-1

Reorder imports to satisfy linting

• Adjusts the order of dynamic imports inside 'apply_secrets_manager_config()' to align with Ruff import rules. No behavior intended to change.

pr_agent/config_loader.py

custom_merge_loader.pyFix tomllib import comment spacing/order +1/-1

Fix tomllib import comment spacing/order

• Moves 'tomllib' import to the top and normalizes inline comment spacing. This is a lint-only change.

pr_agent/custom_merge_loader.py

__init__.pyRemove duplicate provider import and clean line continuation +1/-3

Remove duplicate provider import and clean line continuation

• Reformats BitbucketServerProvider import to a single line and removes a duplicate 'GiteaProvider' import. No runtime behavior change intended.

pr_agent/git_providers/init.py

azuredevops_provider.pyRuff import formatting and f-string cleanup in logs +18/-5

Ruff import formatting and f-string cleanup in logs

• Reformats multi-imports (including azure SDK imports) and converts a no-placeholder log f-string to a plain string. Intended as mechanical lint compliance.

pr_agent/git_providers/azuredevops_provider.py

bitbucket_provider.pySimplify no-placeholder f-strings in logs +2/-2

Simplify no-placeholder f-strings in logs

• Replaces a couple f-strings without placeholders in logging statements with plain strings. No functional change intended.

pr_agent/git_providers/bitbucket_provider.py

bitbucket_server_provider.pyReorder imports and simplify runtime error string +5/-7

Reorder imports and simplify runtime error string

• Normalizes import ordering (stdlib vs third-party) and compresses a utility import into one line. Converts 'RuntimeError(f"...")' with no placeholders into 'RuntimeError("...")'.

pr_agent/git_providers/bitbucket_server_provider.py

codecommit_client.pyReplace constant f-strings in exception messages +4/-4

Replace constant f-strings in exception messages

• Converts several 'ValueError(f"...")' occurrences without placeholders into plain strings. Keeps exception chaining semantics unchanged.

pr_agent/git_providers/codecommit_client.py

git_provider.pyImport reordering and constant f-string cleanup in logs +11/-11

Import reordering and constant f-string cleanup in logs

• Moves ABC imports to the proper location and simplifies multiple logging f-strings without placeholders. Intended to be mechanical lint compliance.

pr_agent/git_providers/git_provider.py

gitea_provider.pyCollapse multi-line imports to Ruff-preferred style +2/-5

Collapse multi-line imports to Ruff-preferred style

• Reformats utility and provider imports into single-line imports where appropriate. No behavior change intended.

pr_agent/git_providers/gitea_provider.py

github_provider.pyImport normalization and constant f-string cleanup +17/-13

Import normalization and constant f-string cleanup

• Reorders and reformats imports and converts several log f-strings without placeholders to plain strings. No functional changes intended.

pr_agent/git_providers/github_provider.py

gitlab_provider.pyRemove unused imports and simplify strings +7/-13

Remove unused imports and simplify strings

• Drops unused imports (e.g., hashlib/requests/extra typing names) and tightens import lists. Converts a constant f-string to a plain string in a fallback message.

pr_agent/git_providers/gitlab_provider.py

utils.pySimplify custom_merge_loader imports +1/-2

Simplify custom_merge_loader imports

• Collapses a multi-line import from 'custom_merge_loader' into a single line to satisfy Ruff formatting rules. No behavior change intended.

pr_agent/git_providers/utils.py

__init__.pyRemove backslash line continuation in import +1/-2

Remove backslash line continuation in import

• Reformats DefaultIdentityProvider import into a single line. Pure lint/style change.

pr_agent/identity_providers/init.py

default_identity_provider.pyCollapse multi-line import for identity types +1/-2

Collapse multi-line import for identity types

• Reformats the import of 'Eligibility' and 'IdentityProvider' into a single line. No logic change intended.

pr_agent/identity_providers/default_identity_provider.py

__init__.pyAdd blank line for import grouping +1/-0

Add blank line for import grouping

• Adds a blank line between imports and environment variable setup to satisfy Ruff formatting. No behavior change intended.

pr_agent/log/init.py

card.pyReformat a2a.types import list +1/-2

Reformat a2a.types import list

• Converts a multi-line parenthesized import into a single-line import consistent with Ruff. No runtime behavior change intended.

pr_agent/mosaico/card.py

executor.pyNormalize imports and remove backslash continuation +2/-5

Normalize imports and remove backslash continuation

• Collapses observability imports into one line and removes a backslash line continuation when importing LiteLLMAIHandler in 'health_check()'. No behavior change intended.

pr_agent/mosaico/executor.py

server.pyRemove stray blank line after config_loader import +0/-1

Remove stray blank line after config_loader import

• Deletes an extra blank line following the intentional import-order hack comment/import. Pure formatting.

pr_agent/mosaico/server.py

__init__.pyRemove backslash line continuation in dynamic imports +2/-4

Remove backslash line continuation in dynamic imports

• Reformats dynamic imports for secret providers into single-line imports. No logic change intended.

pr_agent/secret_providers/init.py

aws_secrets_manager_provider.pyRemove unused botocore ClientError import +1/-1

Remove unused botocore ClientError import

• Drops an unused 'ClientError' import and keeps the module otherwise unchanged. This aligns with Ruff unused-import rules.

pr_agent/secret_providers/aws_secrets_manager_provider.py

azuredevops_server_webhook.pyConvert constant log f-string to plain string +1/-1

Convert constant log f-string to plain string

• Simplifies an exception log call by removing an f-string with no placeholders. No behavior change intended.

pr_agent/servers/azuredevops_server_webhook.py

bitbucket_app.pySimplify constant log f-strings +3/-3

Simplify constant log f-strings

• Replaces f-strings without placeholders in debug/info/exception logs with plain strings. No logic change intended.

pr_agent/servers/bitbucket_app.py

bitbucket_server_webhook.pySimplify constant log f-string +1/-1

Simplify constant log f-string

• Replaces a constant f-string in an info log with a plain string. No behavior change intended.

pr_agent/servers/bitbucket_server_webhook.py

gitea_app.pyRemove constant f-strings and use literal config keys +4/-4

Remove constant f-strings and use literal config keys

• Converts constant f-strings in logs to plain strings and replaces 'get_settings().get(f"gitea.*")' with direct string keys. This is a readability/lint cleanup with no intended behavior change.

pr_agent/servers/gitea_app.py

github_app.pyImport cleanup and constant f-string simplification +8/-10

Import cleanup and constant f-string simplification

• Collapses multi-line imports and converts multiple constant f-strings in logs to plain strings. Keeps existing request handling logic unchanged.

pr_agent/servers/github_app.py

github_polling.pyRemove unused import and simplify debug strings +7/-8

Remove unused import and simplify debug strings

• Drops an unused 'time' import and converts several constant f-string debug logs to plain strings. No behavior change intended.

pr_agent/servers/github_polling.py

gitlab_webhook.pyImport reorder and use literal config keys +3/-3

Import reorder and use literal config keys

• Moves 'get_git_provider_with_context' import alongside other imports and replaces 'get_settings().get(f"gitlab.*")' with literal string keys. Intended as lint/readability cleanup.

pr_agent/servers/gitlab_webhook.py

help.pyReplace constant f-strings in help text +5/-5

Replace constant f-strings in help text

• Converts several constant f-string concatenations into plain strings for Ruff F541 compliance. No content change intended.

pr_agent/servers/help.py

pr_add_docs.pyRemove constant f-string in suggestion body +1/-1

Remove constant f-string in suggestion body

• Replaces 'f"..."' with a plain string when building a suggestion header that has no placeholders. No behavior change intended.

pr_agent/tools/pr_add_docs.py

pr_code_suggestions.pyImport reformatting and constant log/message string cleanup +44/-33

Import reformatting and constant log/message string cleanup

• Reformats imports into Ruff-preferred blocks and simplifies numerous constant f-strings in logs/HTML assembly to plain strings. No algorithmic changes intended.

pr_agent/tools/pr_code_suggestions.py

pr_config.pySimplify constant f-strings and logging message +2/-2

Simplify constant f-strings and logging message

• Replaces a constant f-string used for markdown assembly with a plain string and simplifies a log message string. No functional change intended.

pr_agent/tools/pr_config.py

pr_description.pyImport reformatting and constant string cleanup +30/-23

Import reformatting and constant string cleanup

• Reformats imports and simplifies several constant f-strings used in logs/HTML generation. Also trims unused imports from ticket compliance helpers (keeps only what is referenced).

pr_agent/tools/pr_description.py

pr_generate_labels.pyRemove unused imports and narrow typing +1/-2

Remove unused imports and narrow typing

• Drops unused 're' and unused typing names, keeping only 'List'. Pure lint cleanup.

pr_agent/tools/pr_generate_labels.py

pr_help_docs.pyImport ordering cleanup and constant f-string fixes +23/-23

Import ordering cleanup and constant f-string fixes

• Normalizes import ordering (stdlib/third-party/local) and replaces multiple constant f-string log messages with plain strings. No functional changes intended.

pr_agent/tools/pr_help_docs.py

pr_help_message.pyImport reorder and constant string cleanup in help rendering +11/-11

Import reorder and constant string cleanup in help rendering

• Reorders imports and replaces constant f-strings used to build markdown/HTML with plain strings. No behavior change intended.

pr_agent/tools/pr_help_message.py

pr_line_questions.pyRemove unused imports and tighten dependency list +3/-5

Remove unused imports and tighten dependency list

• Drops unused argparse and unused patch/diff imports, keeping only the helpers that are referenced. This reduces optional dependency surface and satisfies Ruff unused-import rules.

pr_agent/tools/pr_line_questions.py

pr_questions.pyImport order and constant f-string cleanup in logs +6/-6

Import order and constant f-string cleanup in logs

• Reorders imports and converts constant f-string debug/error logs to plain strings. No behavior change intended.

pr_agent/tools/pr_questions.py

pr_reviewer.pyImport cleanup and constant log-string simplification +17/-19

Import cleanup and constant log-string simplification

• Removes unused imports, collapses some multi-imports, and converts constant f-strings in logs to plain strings. Leaves review generation flow unchanged.

pr_agent/tools/pr_reviewer.py

pr_similar_issue.pyRemove unused optional import and adjust qdrant model imports +1/-5

Remove unused optional import and adjust qdrant model imports

• Removes an unused 'pandas' import in the pinecone path and narrows qdrant model imports to the subset actually referenced. Works with new per-file Ruff ignore for F821 due to optional deps.

pr_agent/tools/pr_similar_issue.py

pr_update_changelog.pyDrop unused provider import and simplify log f-strings +4/-4

Drop unused provider import and simplify log f-strings

• Removes an unused 'GithubProvider' import and converts constant f-string logs to plain strings. No behavior change intended.

pr_agent/tools/pr_update_changelog.py

ticket_pr_compliance_check.pyConsolidate provider imports +1/-2

Consolidate provider imports

• Combines AzureDevopsProvider and GithubProvider imports into a single statement. No functional changes intended.

pr_agent/tools/ticket_pr_compliance_check.py

Tests (22) +47 / -66
langchain_ai_handler.pyReplace constant print f-string +1/-1

Replace constant print f-string

• Converts 'print(f"...")' with no placeholders into 'print("...")'. No test behavior change intended.

tests/e2e_tests/langchain_ai_handler.py

test_bitbucket_app.pyRemove unused imports and simplify constant log strings +3/-9

Remove unused imports and simplify constant log strings

• Drops unused imports and replaces constant f-string logging calls with plain strings. Test logic remains the same.

tests/e2e_tests/test_bitbucket_app.py

test_gitea_app.pyRemove unused imports and simplify constant log strings +2/-5

Remove unused imports and simplify constant log strings

• Removes unused constants from imports and replaces constant f-string logs with plain strings. No behavior change intended.

tests/e2e_tests/test_gitea_app.py

test_github_app.pySimplify constant log string +1/-1

Simplify constant log string

• Converts a constant f-string in logger output to a plain string. No behavior change intended.

tests/e2e_tests/test_github_app.py

test_gitlab_webhook.pyRemove unused import and simplify constant log string +1/-2

Remove unused import and simplify constant log string

• Drops an unused provider import and replaces a constant f-string logger line with a plain string. No behavior change intended.

tests/e2e_tests/test_gitlab_webhook.py

main.pyRemove unused imports and simplify constant log f-strings +6/-10

Remove unused imports and simplify constant log f-strings

• Removes unused CLI/path imports and converts constant f-string log messages to plain strings. Keeps the health test flow unchanged.

tests/health_test/main.py

test_aws_secrets_manager_provider.pyRemove unused ClientError import +0/-1

Remove unused ClientError import

• Drops an unused 'ClientError' import from the unit test. No behavior change intended.

tests/unittest/test_aws_secrets_manager_provider.py

test_clip_tokens.pyRemove unused pytest import +0/-2

Remove unused pytest import

• Removes an unused 'pytest' import. No test behavior change intended.

tests/unittest/test_clip_tokens.py

test_codecommit_provider.pyRemove unused FilePatchInfo import +1/-1

Remove unused FilePatchInfo import

• Stops importing 'FilePatchInfo' from algo types when only 'EDIT_TYPE' is used. Pure lint cleanup.

tests/unittest/test_codecommit_provider.py

test_extract_issue_from_branch.pyRemove unused pytest import +0/-1

Remove unused pytest import

• Removes unused pytest import from the test module. No behavior change intended.

tests/unittest/test_extract_issue_from_branch.py

test_gitlab_provider.pyRemove unused imports and narrow GitLab object imports +1/-2

Remove unused imports and narrow GitLab object imports

• Drops unused imports (e.g., Gitlab client object) and keeps only required GitLab object types. No behavior change intended.

tests/unittest/test_gitlab_provider.py

test_handle_patch_deletions.pyRemove unused imports +0/-2

Remove unused imports

• Drops unused logging and config imports from the test module. No behavior change intended.

tests/unittest/test_handle_patch_deletions.py

test_litellm_reasoning_effort.pyRemove unused mock import names +1/-1

Remove unused mock import names

• Removes unused 'call' from unittest.mock imports. No test behavior change intended.

tests/unittest/test_litellm_reasoning_effort.py

test_mosaico_a2a_roundtrip.pyReorder imports to satisfy linting +2/-3

Reorder imports to satisfy linting

• Reorders 'a2a.types' and 'pr_agent.config_loader' imports to align with import-order expectations. No behavioral changes intended.

tests/unittest/test_mosaico_a2a_roundtrip.py

test_mosaico_card.pyCollapse multi-line import +1/-2

Collapse multi-line import

• Reformats card imports into a single line. No behavior change intended.

tests/unittest/test_mosaico_card.py

test_mosaico_env_bridge.pyCollapse multi-line imports +2/-4

Collapse multi-line imports

• Reformats env bridge and observability imports into single-line imports. No behavior change intended.

tests/unittest/test_mosaico_env_bridge.py

test_mosaico_metadata.pyCollapse multi-line import +1/-3

Collapse multi-line import

• Reformats observability imports into a single line. No behavior change intended.

tests/unittest/test_mosaico_metadata.py

test_mosaico_provider.pyReorder local import within helper +1/-1

Reorder local import within helper

• Adjusts import ordering inside a test helper function to satisfy Ruff. No behavior change intended.

tests/unittest/test_mosaico_provider.py

test_mosaico_router.pyImport reordering and narrowing +8/-5

Import reordering and narrowing

• Reorders pytest import and collapses dispatch imports into a formatted block. Removes unused imported names to satisfy Ruff.

tests/unittest/test_mosaico_router.py

test_mosaico_smoke.pyReorder imports to satisfy linting +1/-1

Reorder imports to satisfy linting

• Moves 'a2a.types' imports to the top import section and removes a duplicate later import. No behavior change intended.

tests/unittest/test_mosaico_smoke.py

test_progress_comment.pyReformat imports into Ruff-preferred block style +7/-5

Reformat imports into Ruff-preferred block style

• Reformats the progress_comment imports into a parenthesized multi-line block with trailing commas. No behavior change intended.

tests/unittest/test_progress_comment.py

test_skills_loader.pyReformat skills_loader imports +7/-4

Reformat skills_loader imports

• Reformats the skills loader imports into a multi-line import block consistent with Ruff formatting. No behavior change intended.

tests/unittest/test_skills_loader.py

Documentation (1) +2 / -2
AGENTS.mdUpdate contributor guidance to run Ruff instead of flake8 +2/-2

Update contributor guidance to run Ruff instead of flake8

• Updates coding style instructions to reflect Ruff enforcement via pre-commit. Replaces the flake8 guidance with 'uv run ruff check --fix'.

AGENTS.md

Other (2) +40 / -26
.pre-commit-config.yamlSwitch pre-commit linting/import sorting to Ruff +5/-19

Switch pre-commit linting/import sorting to Ruff

• Replaces the isort hook with the ruff-pre-commit hook pinned to v0.15.20 and enables '--fix'. Removes commented legacy ruff/autoflake blocks and documents that Ruff handles import sorting.

.pre-commit-config.yaml

pyproject.tomlReplace flake8 with Ruff and expand Ruff config/ignore ledger +35/-7

Replace flake8 with Ruff and expand Ruff config/ignore ledger

• Replaces 'flake8' with 'ruff==0.15.20' in the dev dependency group. Expands 'tool.ruff' configuration to enable safe fixers (I001/F401/F541), adds a documented 'lint.ignore' ledger for deferred legacy violations, and introduces per-file ignores for '__init__.py' and the optional-deps similar-issue tool.

pyproject.toml

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. #tomllib violates ruff E265 📘 Rule violation ⚙ Maintainability
Description
The inline comment #tomllib ... lacks a space after #, which violates Ruff/pycodestyle comment
formatting and will fail linting when Ruff is enforced. This breaks the requirement that Python
changes conform to the repository’s Ruff configuration.
Code

pr_agent/custom_merge_loader.py[1]

+import tomllib  #tomllib should be used instead of Py toml for Python 3.11+
Evidence
PR Compliance ID 12 requires new/changed Python code to conform to Ruff rules. The modified line
adds import tomllib  #tomllib ..., which violates Ruff's comment formatting expectations (space
required after #).

AGENTS.md: Python Code Must Conform to Ruff Configuration (Line Length 120, Import Ordering, Lint Rules)
pr_agent/custom_merge_loader.py[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pr_agent/custom_merge_loader.py` has an inline comment that starts with `#tomllib` (no space after `#`), which violates Ruff's pycodestyle comment formatting (e.g., E265).

## Issue Context
This PR enables/enforces Ruff in CI via pre-commit, so new Ruff violations will cause PR checks to fail.

## Fix Focus Areas
- pr_agent/custom_merge_loader.py[1-1]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Missing vectordb imports 🐞 Bug ≡ Correctness
Description
PRSimilarIssue removed the Pinecone/LanceDB dependency imports (pandas, pinecone_datasets) but
still uses pd, Dataset, and DatasetMetadata later, which will raise NameError at runtime
when those vectordb modes are selected. Ruff won't catch this because the file is now exempted from
F821 undefined-name checks.
Code

pr_agent/tools/pr_similar_issue.py[L38-40]

-                import pandas as pd
                import pinecone
-                from pinecone_datasets import Dataset, DatasetMetadata
Evidence
The PR removed the imports for pandas and pinecone_datasets in the Pinecone initialization
block, but the Pinecone/LanceDB indexing helpers still reference pd, DatasetMetadata, and
Dataset without importing them anywhere else. Additionally, ruff is configured to ignore F821
for this file, preventing lint from detecting the undefined names.

pr_agent/tools/pr_similar_issue.py[36-40]
pr_agent/tools/pr_similar_issue.py[397-474]
pr_agent/tools/pr_similar_issue.py[111-147]
pr_agent/tools/pr_similar_issue.py[501-549]
pyproject.toml[168-173]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pr_agent/tools/pr_similar_issue.py` now imports only `pinecone` in the Pinecone init path, but later code paths still reference `pd` (pandas) and `Dataset`/`DatasetMetadata` (from `pinecone_datasets`). This causes runtime `NameError` when `pr_similar_issue.vectordb` is set to `pinecone` or `lancedb`.

## Issue Context
- The Pinecone path calls `_update_index_with_issues()`, which uses `pd.DataFrame`, `DatasetMetadata.empty()`, and `Dataset.from_pandas(...)`.
- The LanceDB path calls `_update_table_with_issues()`, which also uses `pd.DataFrame`.
- `pyproject.toml` adds a per-file ignore for `F821` on this file, so ruff will not flag the undefined names.

## Fix Focus Areas
- pr_agent/tools/pr_similar_issue.py[36-40]
- pr_agent/tools/pr_similar_issue.py[397-489]
- pr_agent/tools/pr_similar_issue.py[492-580]
- pyproject.toml[168-173]

## Suggested fix
1. Add **local (lazy) imports** in the functions that actually use these optional deps:
  - At the top of `_update_index_with_issues`: `import pandas as pd` and `from pinecone_datasets import Dataset, DatasetMetadata` (wrap in try/except and raise a clear "install X" error if missing).
  - At the top of `_update_table_with_issues`: `import pandas as pd` (similarly guarded).
2. Optionally tighten/adjust the `F821` per-file ignore after the imports are fixed, so future undefined-name regressions aren’t hidden.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Qodo Logo

@@ -1,5 +1,5 @@
import tomllib #tomllib should be used instead of Py toml for Python 3.11+

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. #tomllib violates ruff e265 📘 Rule violation ⚙ Maintainability

The inline comment #tomllib ... lacks a space after #, which violates Ruff/pycodestyle comment
formatting and will fail linting when Ruff is enforced. This breaks the requirement that Python
changes conform to the repository’s Ruff configuration.
Agent Prompt
## Issue description
`pr_agent/custom_merge_loader.py` has an inline comment that starts with `#tomllib` (no space after `#`), which violates Ruff's pycodestyle comment formatting (e.g., E265).

## Issue Context
This PR enables/enforces Ruff in CI via pre-commit, so new Ruff violations will cause PR checks to fail.

## Fix Focus Areas
- pr_agent/custom_merge_loader.py[1-1]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines -38 to 40
import pandas as pd
import pinecone
from pinecone_datasets import Dataset, DatasetMetadata
except:
raise Exception("Please install 'pinecone' and 'pinecone_datasets' to use pinecone as vectordb")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

2. Missing vectordb imports 🐞 Bug ≡ Correctness

PRSimilarIssue removed the Pinecone/LanceDB dependency imports (pandas, pinecone_datasets) but
still uses pd, Dataset, and DatasetMetadata later, which will raise NameError at runtime
when those vectordb modes are selected. Ruff won't catch this because the file is now exempted from
F821 undefined-name checks.
Agent Prompt
## Issue description
`pr_agent/tools/pr_similar_issue.py` now imports only `pinecone` in the Pinecone init path, but later code paths still reference `pd` (pandas) and `Dataset`/`DatasetMetadata` (from `pinecone_datasets`). This causes runtime `NameError` when `pr_similar_issue.vectordb` is set to `pinecone` or `lancedb`.

## Issue Context
- The Pinecone path calls `_update_index_with_issues()`, which uses `pd.DataFrame`, `DatasetMetadata.empty()`, and `Dataset.from_pandas(...)`.
- The LanceDB path calls `_update_table_with_issues()`, which also uses `pd.DataFrame`.
- `pyproject.toml` adds a per-file ignore for `F821` on this file, so ruff will not flag the undefined names.

## Fix Focus Areas
- pr_agent/tools/pr_similar_issue.py[36-40]
- pr_agent/tools/pr_similar_issue.py[397-489]
- pr_agent/tools/pr_similar_issue.py[492-580]
- pyproject.toml[168-173]

## Suggested fix
1. Add **local (lazy) imports** in the functions that actually use these optional deps:
   - At the top of `_update_index_with_issues`: `import pandas as pd` and `from pinecone_datasets import Dataset, DatasetMetadata` (wrap in try/except and raise a clear "install X" error if missing).
   - At the top of `_update_table_with_issues`: `import pandas as pd` (similarly guarded).
2. Optionally tighten/adjust the `F821` per-file ignore after the imports are fixed, so future undefined-name regressions aren’t hidden.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants