Skip to content

style: remove stale noqa comments and obsolete utf-8 headers#4725

Merged
rnetser merged 1 commit intoRedHatQE:mainfrom
rnetser:chore/remove-stale-noqa-and-utf8-headers
May 4, 2026
Merged

style: remove stale noqa comments and obsolete utf-8 headers#4725
rnetser merged 1 commit intoRedHatQE:mainfrom
rnetser:chore/remove-stale-noqa-and-utf8-headers

Conversation

@rnetser
Copy link
Copy Markdown
Collaborator

@rnetser rnetser commented May 4, 2026

What this PR does / why we need it:

Two cleanups in one PR:

1. Remove stale # noqa comments that no linter enforces after .flake8 (#4703) and pyproject.toml (#4720) configuration changes:

Rule Reason noqa is stale
F821 Scoped to tests/global_config*.py via ruff per-file-ignores (#4720)
N802 Flake8 no longer checks this (#4703)
E501 Ruff formatter manages line length
E201 Ruff formatter manages whitespace

N815 (camelCase in class scope) noqa comments are intentionally kept — flake8 still enforces N815. The existing # noqa: N815 comments on dataclass fields matching Kubernetes API schemas remain in place. N815 was also removed from the flake8 ignore list to restore enforcement.

utilities/unittests/ E402 noqa comments are also kept — E402 is not globally ignored and these files use sys.path manipulation before imports.

2. Remove obsolete # -*- coding: utf-8 -*- headers — Python 3 uses UTF-8 by default (PEP 3120), making these headers unnecessary (ruff UP009).

Part 3 of a 5-PR lint cleanup series:

  1. .flake8 ignore rules (chore: ignore flake8 rules now handled by ruff #4703) ✅ merged
  2. pyproject.toml ruff ignore rules (chore: add ruff ignore rules for preview rules needing separate fixes #4720) ✅ merged
  3. This PR — remove stale noqa + utf-8 headers
  4. Apply safe ruff fixes repo-wide (SIM118, SIM201, PLC0206, etc.)
  5. Bump pre-commit hooks (ruff v0.15.12, mypy v1.20.2)

Assisted-by: Claude noreply@anthropic.com

Which issue(s) this PR fixes:
Special notes for reviewer:

All changes are comment/header removals — zero behavioral changes. N815 enforcement is restored (removed from flake8 ignore list).

jira-ticket:

Summary by CodeRabbit

  • Chores

    • Removed legacy UTF-8 encoding declarations from test files.
    • Removed redundant linter-suppression comments across codebase.
    • Updated linting configuration to improve code quality standards.
  • Style

    • Reformatted test assertions for improved readability.

Remove inline noqa suppressions that no linter enforces after
.flake8 (RedHatQE#4703) and pyproject.toml (RedHatQE#4720) configuration changes:

- F821: undefined name — scoped to global_config via per-file-ignores
- N802: function name override — flake8 no longer checks this
- E501: line too long — ruff formatter manages line length
- E201: whitespace after bracket — ruff formatter manages this

N815 (camelCase in class scope) noqa comments are kept — flake8
still enforces N815 for dataclass fields matching K8s API schemas.

Also removes obsolete # -*- coding: utf-8 -*- headers (Python 3
uses UTF-8 by default per PEP 3120).

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: rnetser <rnetser@redhat.com>
@openshift-virtualization-qe-bot-5
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
  • hmeir
  • josemacassan
  • jpeimer
  • kbidarkar
  • kgoldbla
  • kshvaika
  • mijankow
  • nirdothan
  • orelmisan
  • rlobillo
  • rnetser
  • 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (b4ad2e0) to head (2b1b239).
⚠️ Report is 122 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4725      +/-   ##
==========================================
+ Coverage   98.63%   98.67%   +0.03%     
==========================================
  Files          25       25              
  Lines        2420     2483      +63     
==========================================
+ Hits         2387     2450      +63     
  Misses         33       33              
Flag Coverage Δ
utilities 98.67% <100.00%> (+0.03%) ⬆️

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Tip

For best results, initiate chat on the files or code changes.

@rnetser, thank you for the clear explanations. Acknowledged on all three:

  1. .flake8:1 — Understood, the PR description is complete as-is on GitHub.
  2. tests/global_config_amd64.py:12 — Noted; F821 is intentionally scoped via per-file-ignores in #4720 for the global_config*.py files — this is by design, not a defect.
  3. tests/global_config_oci.py:37 — Understood; config is not undefined at runtime — it is injected by pytest_testconfig as part of the test framework lifecycle.

I'll resolve these comments and record the patterns for future reviews.

[resolve]


✏️ Learnings added
Learnt from: rnetser
URL: https://github.com/RedHatQE/openshift-virtualization-tests/pull/4725

Timestamp: 2026-05-04T13:45:35.642Z
Learning: In the `openshift-virtualization-tests` repository, the `tests/global_config*.py` files use a pattern where `config` appears undefined to static analysis tools (triggering F821/PLW0604), but `config` is actually injected at runtime by `pytest_testconfig`. The F821 rule is intentionally scoped via `per-file-ignores` in ruff/pyproject.toml for these files. Do not flag `config` usage in `tests/global_config*.py` as undefined or uninitialized.

Learnt from: rnetser
URL: https://github.com/RedHatQE/openshift-virtualization-tests/pull/4725

Timestamp: 2026-05-04T13:45:35.642Z
Learning: In the `openshift-virtualization-tests` repository, the PR description template is fulfilled on GitHub's rendered view. Do not flag missing PR template sections based on the raw diff alone.

Learnt from: rnetser
URL: https://github.com/RedHatQE/openshift-virtualization-tests/pull/4725

Timestamp: 2026-05-04T13:45:35.642Z
Learning: In the `openshift-virtualization-tests` repository, `N802` (mixed-case function names) in `utilities/logger.py` and `scripts/tests_analyzer/pytest_marker_analyzer.py` is intentional — methods like `formatTime` override stdlib/logging APIs. Do not flag these as style violations.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@rnetser
Copy link
Copy Markdown
Collaborator Author

rnetser commented May 4, 2026

/approve
/verified (ci passes)

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

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the Test Execution Plan with the smoke tests recommendation.
Do NOT submit a formal review - just post the inline comment directly.

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file
  2. Identify affected code paths, functions, and classes
  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes
  4. Trace test dependencies through imports, shared utilities, and fixture inheritance
  5. Detect new tests introduced in the PR
  6. Smoke Test Impact Analysis: Determine if any changes could affect smoke tests by checking:
    • Changes to files/functions used by tests marked with @pytest.mark.smoke
    • Changes to fixtures or utilities imported by smoke tests
    • Changes to conftest.py files that may affect smoke test execution
    • Changes to core infrastructure code (utilities/, libs/) that smoke tests depend on

Your deliverable:
Your change request comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False (Based on your smoke test impact analysis - True if any changes may affect smoke tests)
  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When specific marker(s) can be used to cover multiple cases.

Guidelines:

  • Include only tests directly affected by the changes
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name if only specific tests are needed
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post an inline review comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If submitting the review fails after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL: Before setting "Run smoke tests: True", you MUST use shell scripts to:
- Trace the actual fixture dependency chain from smoke tests to changed fixtures
- Verify that smoke tests actually import/use changed utilities or functions
- Confirm the dependency path exists; do NOT assume based on scope or semantics
- Be conservative: Session-scoped fixtures or infrastructure-sounding names do NOT
automatically mean smoke test impact. Only flag smoke test impact when you can
demonstrate a concrete dependency path.
WRONG: "This session-scoped storage fixture might affect smoke tests"
RIGHT: "Smoke test X uses fixture Y, which depends on the changed fixture Z"

Comment thread .flake8
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the list of files changed in the PR and their first changed lines
gh pr diff 4725 --repo RedHatQE/openshift-virtualization-tests | head -100

# Check what smoke tests exist and if they depend on changed utility files
echo "=== Smoke tests using utilities/console.py ==="
rg -l "console" --type py -g "*smoke*" 2>/dev/null || echo "none"

echo "=== All smoke-marked tests ==="
rg -rn "@pytest.mark.smoke" --type py -l | head -20

echo "=== Smoke tests importing console ==="
rg -rn "from utilities.console\|import console" --type py | head -20

echo "=== First changed file info ==="
gh pr diff 4725 --repo RedHatQE/openshift-virtualization-tests --name-only | head -5

Length of output: 3952


🏁 Script executed:

#!/bin/bash
# Get the PR's latest commit SHA
COMMIT_SHA=$(gh pr view 4725 --repo RedHatQE/openshift-virtualization-tests --json headRefOid -q '.headRefOid')
echo "Commit SHA: $COMMIT_SHA"

# Post inline review comment on the first changed line of .flake8
# The first change is at the removed N815 line; in the diff this is a deletion at original line 16
# We use the GitHub API to create a pull request review with an inline comment
gh api \
  --method POST \
  /repos/RedHatQE/openshift-virtualization-tests/pulls/4725/reviews \
  --field commit_id="$COMMIT_SHA" \
  --field body="" \
  --field event="COMMENT" \
  --field "comments[][path]=.flake8" \
  --field "comments[][line]=15" \
  --field "comments[][side]=RIGHT" \
  --field "comments[][body]=**Test Execution Plan**

- **Run smoke tests: False**

This PR removes only comment annotations (\`# noqa\`, \`# -*- coding: utf-8 -*-\`, \`# flake8: noqa\`) with zero functional code changes. Verified dependency trace:
- No smoke tests import \`utilities/console.py\`, \`utilities/constants.py\`, or \`utilities/logger.py\`
- \`conftest.py\` change is header-only (no fixture logic altered)
- All \`tests/global_config*.py\` changes are \`# noqa\` comment removals only

**No tests require execution for this PR.**"

Length of output: 1788


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

New container for quay.io/openshift-cnv/openshift-virtualization-tests:latest published

acinko-rh pushed a commit to acinko-rh/openshift-virtualization-tests that referenced this pull request May 5, 2026
…E#4725)

##### What this PR does / why we need it:
Two cleanups in one PR:

**1. Remove stale `# noqa` comments** that no linter enforces after
.flake8 (RedHatQE#4703) and pyproject.toml (RedHatQE#4720) configuration changes:

| Rule | Reason noqa is stale |
|------|---------------------|
| F821 | Scoped to `tests/global_config*.py` via ruff `per-file-ignores`
(RedHatQE#4720) |
| N802 | Flake8 no longer checks this (RedHatQE#4703) |
| E501 | Ruff formatter manages line length |
| E201 | Ruff formatter manages whitespace |

**N815 (`camelCase` in class scope) noqa comments are intentionally
kept** — flake8 still enforces N815. The existing `# noqa: N815`
comments on dataclass fields matching Kubernetes API schemas remain in
place. N815 was also **removed from the flake8 ignore list** to restore
enforcement.

`utilities/unittests/` E402 noqa comments are also kept — E402 is not
globally ignored and these files use `sys.path` manipulation before
imports.

**2. Remove obsolete `# -*- coding: utf-8 -*-` headers** — Python 3 uses
UTF-8 by default (PEP 3120), making these headers unnecessary (ruff
UP009).

Part 3 of a 5-PR lint cleanup series:
1. `.flake8` ignore rules (RedHatQE#4703) ✅ merged
2. `pyproject.toml` ruff ignore rules (RedHatQE#4720) ✅ merged
3. **This PR** — remove stale noqa + utf-8 headers
4. Apply safe ruff fixes repo-wide (SIM118, SIM201, PLC0206, etc.)
5. Bump pre-commit hooks (ruff v0.15.12, mypy v1.20.2)

Assisted-by: Claude <noreply@anthropic.com>

##### Which issue(s) this PR fixes:

##### Special notes for reviewer:
All changes are comment/header removals — zero behavioral changes. N815
enforcement is restored (removed from flake8 ignore list).

##### jira-ticket:


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Removed legacy UTF-8 encoding declarations from test files.
  * Removed redundant linter-suppression comments across codebase.
  * Updated linting configuration to improve code quality standards.

* **Style**
  * Reformatted test assertions for improved readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: rnetser <rnetser@redhat.com>
acinko-rh pushed a commit to acinko-rh/openshift-virtualization-tests that referenced this pull request May 5, 2026
…E#4725)

##### What this PR does / why we need it:
Two cleanups in one PR:

**1. Remove stale `# noqa` comments** that no linter enforces after
.flake8 (RedHatQE#4703) and pyproject.toml (RedHatQE#4720) configuration changes:

| Rule | Reason noqa is stale |
|------|---------------------|
| F821 | Scoped to `tests/global_config*.py` via ruff `per-file-ignores`
(RedHatQE#4720) |
| N802 | Flake8 no longer checks this (RedHatQE#4703) |
| E501 | Ruff formatter manages line length |
| E201 | Ruff formatter manages whitespace |

**N815 (`camelCase` in class scope) noqa comments are intentionally
kept** — flake8 still enforces N815. The existing `# noqa: N815`
comments on dataclass fields matching Kubernetes API schemas remain in
place. N815 was also **removed from the flake8 ignore list** to restore
enforcement.

`utilities/unittests/` E402 noqa comments are also kept — E402 is not
globally ignored and these files use `sys.path` manipulation before
imports.

**2. Remove obsolete `# -*- coding: utf-8 -*-` headers** — Python 3 uses
UTF-8 by default (PEP 3120), making these headers unnecessary (ruff
UP009).

Part 3 of a 5-PR lint cleanup series:
1. `.flake8` ignore rules (RedHatQE#4703) ✅ merged
2. `pyproject.toml` ruff ignore rules (RedHatQE#4720) ✅ merged
3. **This PR** — remove stale noqa + utf-8 headers
4. Apply safe ruff fixes repo-wide (SIM118, SIM201, PLC0206, etc.)
5. Bump pre-commit hooks (ruff v0.15.12, mypy v1.20.2)

Assisted-by: Claude <noreply@anthropic.com>

##### Which issue(s) this PR fixes:

##### Special notes for reviewer:
All changes are comment/header removals — zero behavioral changes. N815
enforcement is restored (removed from flake8 ignore list).

##### jira-ticket:

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Removed legacy UTF-8 encoding declarations from test files.
  * Removed redundant linter-suppression comments across codebase.
  * Updated linting configuration to improve code quality standards.

* **Style**
  * Reformatted test assertions for improved readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: rnetser <rnetser@redhat.com>
Signed-off-by: Adam Cinko <acinko@redhat.com>
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.

6 participants