Skip to content

chore: upgrade Ruff configuration and reformat codebase#861

Open
pvital wants to merge 23 commits intomainfrom
ruff_update
Open

chore: upgrade Ruff configuration and reformat codebase#861
pvital wants to merge 23 commits intomainfrom
ruff_update

Conversation

@pvital
Copy link
Copy Markdown
Member

@pvital pvital commented Apr 7, 2026

This PR modernizes the repository’s Ruff setup and applies the resulting formatting and lint cleanup across the codebase and tests.

  • Upgraded pre-commit Ruff integration in .pre-commit-config.yaml
    • bumped Ruff from v0.7.0 to v0.15.9
    • switched the lint hook from ruff to ruff-check
    • extended formatting hook coverage to Python and Markdown files
  • Added Ruff configuration to pyproject.toml
    • set Python target version to 3.9
    • configured repository exclusions for non-source directories
    • enabled preview mode and concise output
    • defined lint rule selection for style, import ordering, simplification, string modernizations, and copyright checks
  • Applied repository-wide Ruff-driven cleanup across source and test files
    • normalized import ordering
    • reformatted multiline logging, context managers, assertions, and long calls
    • simplified membership checks, such as key in dict instead of key in dict.keys()
    • removed unused imports in several tests
    • cleaned whitespace and newline issues
  • Fixed SonarQube failed conditions on new code
    • Deleted src/instana/util/gunicorn.py since the code is duplicated in running_in_gunicorn() function from src/instana/log.py.
    • Adapted code to import running_in_gunicorn() from src/instana/log.py.
    • Add tests for running_in_gunicorn() to increase the coverage on new code.

@pvital pvital self-assigned this Apr 7, 2026
@pvital pvital added the chore label Apr 7, 2026
@pvital pvital changed the title Ruff update chore: upgrade Ruff configuration and reformat codebase Apr 7, 2026
@pvital pvital force-pushed the ruff_update branch 2 times, most recently from 3b107e9 to 3516d15 Compare April 7, 2026 12:39
@pvital pvital marked this pull request as ready for review April 7, 2026 20:14
@pvital pvital requested a review from a team as a code owner April 7, 2026 20:14
Copy link
Copy Markdown
Contributor

@GSVarsha GSVarsha left a comment

Choose a reason for hiding this comment

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

Just a few suggestions

pvital added 18 commits April 9, 2026 16:34
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
used ruff (pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations, like unused imports.
- isort-compatible import sorting.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ormat.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ring join.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
….keys()`.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ead of `try`-`except`-`pass`.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…aders.get(<index>, None)`.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…le contexts instead of nested `with` statements.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…sted `if` statements.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
pvital added 4 commits April 9, 2026 16:34
…directly.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…e`-block.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…se True`.

Used Ruff (vscode and pre-commit) to:
- Black-compatible code formatting.
- fix all auto-fixable violations.
- isort-compatible import sorting.
- flake8-simplify manual fixes.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
- Deleted `src/instana/util/gunicorn.py` since the code is duplicated in `running_in_gunicorn()` function from `src/instana/log.py`.
- Adapted code to import `running_in_gunicorn()` from `src/instana/log.py`.
- Add tests for `running_in_gunicorn()` to increase the coverage on new code.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
@pvital pvital requested a review from GSVarsha April 9, 2026 14:42
- Introduced type hints and code cleanup.
- removed None defaults from .get() calls.
- import reorganization.
- boolean expression formatting.

Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
3.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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