Skip to content

chore: bump ruff v0.15.1 → v0.15.12 and fix all new violations#4954

Merged
dshchedr merged 3 commits into
RedHatQE:mainfrom
rnetser:pre-commit/ruff-update
Jun 1, 2026
Merged

chore: bump ruff v0.15.1 → v0.15.12 and fix all new violations#4954
dshchedr merged 3 commits into
RedHatQE:mainfrom
rnetser:pre-commit/ruff-update

Conversation

@rnetser
Copy link
Copy Markdown
Collaborator

@rnetser rnetser commented May 20, 2026

What this PR does / why we need it:

Bumps ruff-pre-commit from v0.15.1 to v0.15.12 and fixes all new lint violations introduced by the version bump.

Config changes:

  • pyproject.toml: add N815 to extend-select (k8s camelCase field names), add SIM118/PERF102 to ignore (k8s resource objects need .keys()/.items())
  • .flake8: add N815 to ignore list
  • .pre-commit-config.yaml: ruff v0.15.1 → v0.15.12

Code fixes (36 manual + 118 auto-fixed):
UP031, UP037, SIM103, SIM113, SIM201, SIM210, PIE810, C403, C408, C409, C411, C414, TRY002, TRY201, TRY203, TRY401, DTZ003, PLC0206, PLE0704, LOG015, B008, B026

Split from #4910 for easier review.

Which issue(s) this PR fixes:

Supersedes part of #4910

Special notes for reviewer:

All pre-commit hooks and unit tests pass. 75 files changed — bulk is ruff auto-fixes (quoted type annotations, import cleanups). Manual fixes are straightforward mechanical transformations.

jira-ticket:

Assisted-by: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Refactor

    • Modernized type hints and generator signatures across the codebase; removed quoted forward-references.
    • Centralized UTC handling by switching to datetime.UTC.
  • Style

    • Converted many formatting patterns to f-strings and simplified boolean/conditional expressions.
    • Simplified class declarations and import organization.
  • Chores

    • Updated Ruff/pre-commit lint configurations and cleaned up lint suppression comments.
  • Bug Fixes

    • Improved exception re-raising to preserve original tracebacks and tightened exception logging.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

Warning

Review limit reached

@rnetser, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c49cc4d7-3528-4acc-9d0e-25cef71af9b0

📥 Commits

Reviewing files that changed from the base of the PR and between 64791b0 and 1594e01.

📒 Files selected for processing (1)
  • tests/infrastructure/vm_console_proxy/utils.py
📝 Walkthrough

Walkthrough

Modernize typing and style across the repo: migrate Generator imports, simplify Generator return annotations, adopt PEP 604 unions and built-in generics, replace quoted enter returns with Self, migrate to datetime.UTC, preserve tracebacks with bare raise, switch some I/O to writelines, and align ruff/flake8/pre-commit configuration.

Changes

Python 3.11+ Modernization and Linting Alignment

Layer / File(s) Summary
Linting & pre-commit tooling
.flake8, pyproject.toml, .pre-commit-config.yaml
Clarify flake8 comments and add N815 to ignores; extend Ruff extend-select and global ignores; add per-file ruff ignores; bump ruff-pre-commit rev.
Generator import migration
multiple libs/, tests/, utilities/ files
Move Generator imports from typing to collections.abc, add Self imports where needed, and tidy related typing imports.
Generator return annotation simplification
several context managers and fixtures
Remove explicit None, None trailing type params from Generator[...] annotations for context managers and fixtures.
Context manager return types → Self
libs/net/traffic_generator.py, utilities/oadp.py, tests network files
Replace quoted forward-reference return annotations for __enter__ with Self or direct class types.
PEP 604 unions & built-in generics
tests/*, utilities/*, libs
Replace Optional[T] with `T
Timezone modernization
tests/*, utilities/*
Use datetime.UTC and datetime.now(tz=UTC) instead of timezone.utc/utcnow() for timezone-aware timestamps.
Exception handling & tracebacks
multiple tests/ and utilities/ files
Use bare raise instead of raise e to preserve tracebacks; propagate TimeoutExpiredError without swallowing; catch built-in TimeoutError where appropriate.
I/O chunk writes & defaults
utilities/infra.py, utilities/storage.py
Write response iter_content via writelines(...) and introduce _DEFAULT_DISK_SERIAL_COMMAND default for reuse.
Style and small logic improvements
many files across tests and utilities
F-strings, dict literals, .items() iteration, simplified predicates and conditions, minor test adjustments; all behavioral semantics preserved.
Remove inline import noqa
utilities/unittests/test_*.py
Remove # noqa: E402 and module-level flake8 suppressions where no longer needed due to config updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • vsibirsk
  • dshchedr
  • RoniKishner
  • EdDev
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: bumping ruff and fixing violations. It's under 120 characters (62 chars) and uses a conventional 'chore:' prefix.
Description check ✅ Passed The description is comprehensive, covering all required template sections with specific details about config changes, code fixes, and testing status.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stp Link Required ✅ Passed PR contains no new test files or test functions—it only modifies existing files for ruff linting compliance. STP requirement does not apply per check instructions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (a2dc143) to head (1594e01).
⚠️ Report is 69 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4954      +/-   ##
==========================================
- Coverage   98.67%   98.65%   -0.02%     
==========================================
  Files          25       25              
  Lines        2487     2456      -31     
==========================================
- Hits         2454     2423      -31     
  Misses         33       33              
Flag Coverage Δ
utilities 98.65% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-virtualization-qe-bot
Copy link
Copy Markdown

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: Enabled categories: branch, can-be-merged, cherry-pick, has-conflicts, hold, needs-rebase, size, verified, wip

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest verify-bugs-are-open - verify-bugs-are-open
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 2 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • EdDev
  • dshchedr
  • jpeimer
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Ahmad-Hafe
  • Anatw
  • EdDev
  • OhadRevah
  • RoniKishner
  • SamAlber
  • acinko-rh
  • akri3i
  • albarker-rh
  • azhivovk
  • dalia-frank
  • dshchedr
  • ema-aka-young
  • frenzyfriday
  • geetikakay
  • guchen11
  • hmeir
  • josemacassan
  • jpeimer
  • kgoldbla
  • kshvaika
  • mijankow
  • nirdothan
  • orelmisan
  • rlobillo
  • rnetser
  • sarahbx
  • servolkov
  • vsibirsk
  • yossisegev
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@jpeimer
Copy link
Copy Markdown
Contributor

jpeimer commented Jun 1, 2026

/approve
/lgtm

@rnetser
Copy link
Copy Markdown
Collaborator Author

rnetser commented Jun 1, 2026

/retest build-container

@dshchedr
Copy link
Copy Markdown
Collaborator

dshchedr commented Jun 1, 2026

/approve
/lgtm

This was referenced Jun 1, 2026
@openshift-virtualization-qe-bot-3
Copy link
Copy Markdown
Contributor

Failed to build and push quay.io/openshift-cnv/openshift-virtualization-tests:latest

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants