Skip to content

Fix calling stream generator#224

Merged
phracek merged 3 commits intomasterfrom
fix_calling_stream_generator
Mar 12, 2026
Merged

Fix calling stream generator#224
phracek merged 3 commits intomasterfrom
fix_calling_stream_generator

Conversation

@phracek
Copy link
Member

@phracek phracek commented Mar 12, 2026

Summary by CodeRabbit

  • Chores
    • Updated pre-commit configuration: removed flake8 and upgraded mypy to v1.2.0.
    • Minor internal adjustments to module loading and test formatting (no user-facing behavior changes).

phracek added 2 commits March 12, 2026 15:27
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

Updates pre-commit configuration (mypy version bump, flake8 removal) and adds module search-path adjustment in the stream generator; a minor formatting cleanup was made to a test file.

Changes

Cohort / File(s) Summary
Pre-commit config
\.pre-commit-config.yaml
Removed the flake8 hook entry and updated mypy hook revision from v0.711 to v1.2.0 (other hooks preserved; blocks reordered slightly).
Module path adjustment
ocp-stream-generator/ocp_stream_generator/stream_generator.py
Added pathlib import and sys.path.append(str(Path(__file__).parent.parent.absolute())) to modify the Python module search path at runtime.
Test formatting
ocp-stream-generator/tests/test_imagestream_file.py
Removed an extraneous blank line between the shebang and imports (formatting-only change).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nudged a path, I nudged a line,
Hooks grew newer, flake8 resigns.
Tests are tidy, imports clear,
A little hop — the code draws near. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix calling stream generator' is specific and directly related to the main changes, which add sys.path modification to the stream_generator.py module to fix module import issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_calling_stream_generator
📝 Coding Plan for PR comments
  • Generate coding plan

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

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.50%. Comparing base (26fc90b) to head (422440f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
+ Coverage   35.38%   35.50%   +0.12%     
==========================================
  Files           7        7              
  Lines        1009     1011       +2     
==========================================
+ Hits          357      359       +2     
  Misses        652      652              
Flag Coverage Δ
daily-tests-unit 26.23% <ø> (ø)
ocp-stream-generator-unit 84.47% <100.00%> (+0.19%) ⬆️

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

Files with missing lines Coverage Δ
...generator/ocp_stream_generator/stream_generator.py 84.17% <100.00%> (+0.20%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ocp-stream-generator/ocp_stream_generator/stream_generator.py (1)

29-32: Consider moving sys.path manipulation inside if __name__ == "__main__" block.

Modifying sys.path at module load time affects all imports of this module, not just direct script execution. This can cause unintended side effects when the module is imported as part of a larger application.

♻️ Suggested refactor: Move path manipulation to main guard
 import yaml
 import json
 import sys
-
-from pathlib import Path
-
-sys.path.append(str(Path(__file__).parent.parent.absolute()))
-
 from ocp_stream_generator.distribution_data import (

Then at the bottom of the file:

 if __name__ == "__main__":
+    from pathlib import Path
+    sys.path.insert(0, str(Path(__file__).parent.parent.absolute()))
     main()

Alternatively, if the package is properly installed (e.g., via pip install -e .), the sys.path manipulation becomes unnecessary entirely.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ocp-stream-generator/ocp_stream_generator/stream_generator.py` around lines
29 - 32, The current module mutates sys.path at import time via
sys.path.append(str(Path(__file__).parent.parent.absolute())), which can cause
side effects when imported; move that manipulation inside an if __name__ ==
"__main__": guard (or remove it entirely if the package is installed properly)
so sys.path is only changed when running the script directly; locate the
sys.path.append call and the Path(__file__).parent.parent usage and relocate it
into the main guard (or eliminate it) and ensure any code that depended on it is
executed from within that guard as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ocp-stream-generator/ocp_stream_generator/stream_generator.py`:
- Around line 29-32: The current module mutates sys.path at import time via
sys.path.append(str(Path(__file__).parent.parent.absolute())), which can cause
side effects when imported; move that manipulation inside an if __name__ ==
"__main__": guard (or remove it entirely if the package is installed properly)
so sys.path is only changed when running the script directly; locate the
sys.path.append call and the Path(__file__).parent.parent usage and relocate it
into the main guard (or eliminate it) and ensure any code that depended on it is
executed from within that guard as well.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 594054ca-a529-4284-92c2-96e1f5bf1e86

📥 Commits

Reviewing files that changed from the base of the PR and between 26fc90b and 763066e.

📒 Files selected for processing (3)
  • .pre-commit-config.yaml
  • ocp-stream-generator/ocp_stream_generator/stream_generator.py
  • ocp-stream-generator/tests/test_imagestream_file.py
💤 Files with no reviewable changes (1)
  • ocp-stream-generator/tests/test_imagestream_file.py

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

22-26: Verify the codebase passes mypy checks with the updated version.

This is a significant version jump from v0.711 (July 2019) to v1.2.0 (April 2023) spanning multiple years and a major version boundary. Newer mypy versions often introduce stricter type checking that may surface new errors. Ensure the codebase passes mypy checks locally or in CI before merging.

Additionally, consider upgrading to a more recent stable release. The latest available version is v1.19.x, which includes improvements and bug fixes from the past three years.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 22 - 26, Update and verify the mypy
hook change: run mypy using the updated hook (rev: v1.2.0) or upgrade the hook
to a more recent stable release (e.g., rev: v1.19.x) and run full type checks,
then fix any new type errors surfaced across the codebase (adjust annotations,
add casts or TypedDicts, update stubs or ignore rules) until mypy passes locally
and in CI; ensure the pre-commit hook entry (the mypy hook and its args:
--no-strict-optional, --ignore-missing-imports) remains consistent with your
chosen mypy version.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.pre-commit-config.yaml:
- Around line 22-26: Update and verify the mypy hook change: run mypy using the
updated hook (rev: v1.2.0) or upgrade the hook to a more recent stable release
(e.g., rev: v1.19.x) and run full type checks, then fix any new type errors
surfaced across the codebase (adjust annotations, add casts or TypedDicts,
update stubs or ignore rules) until mypy passes locally and in CI; ensure the
pre-commit hook entry (the mypy hook and its args: --no-strict-optional,
--ignore-missing-imports) remains consistent with your chosen mypy version.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed51805b-dc63-4706-b61a-ed4136b4293e

📥 Commits

Reviewing files that changed from the base of the PR and between 763066e and 422440f.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml

@phracek phracek merged commit e16f175 into master Mar 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant