Skip to content

Add black and ruff to fix lint/pep/ and other issues automatically#634

Merged
otc-zuul[bot] merged 3 commits intomainfrom
auto_fix_lint_errors
Mar 3, 2026
Merged

Add black and ruff to fix lint/pep/ and other issues automatically#634
otc-zuul[bot] merged 3 commits intomainfrom
auto_fix_lint_errors

Conversation

@shhovhan
Copy link
Copy Markdown
Contributor

@shhovhan shhovhan commented Mar 2, 2026

Summary

This PR modernizes and stabilizes the linting and formatting pipeline while keeping OpenStack standards.


What Was Done

  • Integrated Ruff for:

    • Import sorting
    • Unused import removal
    • General lint auto-fixes (E, F, I rules)
  • Integrated Black as the canonical code formatter (default line length = 88)

  • Kept flake8 + hacking to enforce OpenStack-specific standards

  • Kept doc8 for documentation validation

  • Updated tox configuration:

    • pep8 environment → CI check-only (no file modifications)
    • fix-pep8 environment → local auto-fix (modifies files)
  • Disabled E501 and E203 in flake8 to avoid conflicts with Black formatting (as recommended by Black documentation)


Why to much files changed

The large diff is intentional.

Black reformatted the entire codebase to a consistent style:

  • Normalized indentation
  • Adjusted line wrapping (88 characters)
  • Standardized slice spacing
  • Reformatted long imports
  • Removed trailing whitespace
  • Applied consistent multiline formatting

Ruff additionally:

  • Removed unused imports
  • Sorted imports
  • Cleaned up minor style inconsistencies

No functional or behavioral changes were introduced.
All changes are formatting and lint normalization only.


Why This Is Beneficial

  • Eliminates inconsistent formatting across the repository
  • Reduces CI noise caused by minor style differences
  • Aligns with modern Python tooling practices
  • Provides a single command to auto-fix issues locally

CI Behavior

CI now runs linting in read-only mode.
If formatting is incorrect, CI fails without modifying files.


Impact

  • No runtime changes
  • No API changes
  • No test logic changes
  • Formatting and lint normalization only

@otc-zuul
Copy link
Copy Markdown
Contributor

otc-zuul Bot commented Mar 3, 2026

Build succeeded.
https://zuul.otc-service.com/t/eco/buildset/cb30e0228ba8479da99b17368b19898e

✔️ test-release SUCCESS in 3m 46s
✔️ otc-tox-docs SUCCESS in 14m 57s
✔️ build-otc-releasenotes SUCCESS in 4m 36s
✔️ otc-tox-py310 SUCCESS in 4m 41s
✔️ otc-tox-pep8 SUCCESS in 3m 23s
✔️ tox-functional-eu-de SUCCESS in 16m 22s
✔️ otce-upload-image SUCCESS in 4m 04s

@otc-zuul otc-zuul Bot merged commit 31a76bd into main Mar 3, 2026
4 checks passed
@otc-zuul otc-zuul Bot deleted the auto_fix_lint_errors branch March 3, 2026 12:08
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