Skip to content

Adapt to ruff 0.16.0 - #53

Merged
sgallagher merged 30 commits into
fedora-eln:mainfrom
sgallagher:ruff
Jul 27, 2026
Merged

Adapt to ruff 0.16.0#53
sgallagher merged 30 commits into
fedora-eln:mainfrom
sgallagher:ruff

Conversation

@sgallagher

@sgallagher sgallagher commented Jul 24, 2026

Copy link
Copy Markdown
Member

CI: display 'ruff check' output inline

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Apply 'safe' fixes

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Clean up TRY401 issues

Assisted-by: Cursor 3.12.29
Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Clean up SIM117 issues

Assisted-by: Cursor 3.12.29
Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Clean up SIM115 issues

Assisted-By: Cursor 3.12.29
Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Configuration fixes

  • Treat import elnbuildsync as first-party
  • Ignore except Exception violations. We need to ensure that the
    service never crashes.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Remove shebangs

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

C408: Replace dict() and list() with literals

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Don't block reading the status page template

The status page will now only be read and the template applied during
service startup. Once upon a time, it needed to be applied at each
request, but when we switched to using the JSON feed to populate the
results, that stopped being the case. Now the only templatized variable
is the ELNBuildSync version, and that won't change throughout the
runtime, so we can just apply the template once at startup and save it.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

SIM118: Use more efficient key lookup

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

FA102: Import annotations

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Drop redundant assignment

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

I001: Missing empty line

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

UP037: Drop quotes on types thanks to future.annotaions

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

C403: Use set comprehension

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

UP045: Replace Optional[] with |

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

SIM103: Simpler return

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

UP028: Simpler yield loop

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

SIM401: Simpler get()

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

B006: Use cleaner default

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

RUF012: Explicitly annotate that these are class variables

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ASYNC230: Use deferToThread() for open() operations

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Read the template file asynchronously

Also drop the executable portion of web.py, which hasn't actually
supported it for a long time.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Avoid circular dependencies

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Fix flake8 issues

The ruff and flake8 commands differ in their opinions around E203 and
E402, so we'll pick a winner (ruff) and tell flake8 to ignore it.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Simplify asyncio reactor setup

All launches of EBS now go through the entrypoint rather than calling
daemon.py directly, so we can keep the reactor setup in one place.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

DB: Match nullable and optional keys

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

PendingNVRTags: implement contains()

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

ruff: Ignore E402 in init.py

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Assisted-by: Cursor 3.12.29
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Assisted-by: Cursor 3.12.29
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Assisted-By: Cursor 3.12.29
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
* Treat `import elnbuildsync` as first-party
* Ignore `except Exception` violations. We need to ensure that the
  service never crashes.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
The status page will now only be read and the template applied during
service startup. Once upon a time, it needed to be applied at each
request, but when we switched to using the JSON feed to populate the
results, that stopped being the case. Now the only templatized variable
is the ELNBuildSync version, and that won't change throughout the
runtime, so we can just apply the template once at startup and save it.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sgallagher, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ae9934ab-4d24-49b0-b0da-3e3b0d858c3b

📥 Commits

Reviewing files that changed from the base of the PR and between 2812db9 and 6e1e36a.

📒 Files selected for processing (1)
  • README.md
📝 Walkthrough

Walkthrough

The change installs Twisted’s asyncio reactor during package startup, centralizes asynchronous YAML loading, caches rendered status HTML, modernizes type annotations and runtime helpers, adjusts exception handling, and updates lint configuration and configuration-loading tests.

Changes

Runtime modernization

Layer / File(s) Summary
Asyncio bootstrap and cached status rendering
elnbuildsync/__init__.py, elnbuildsync/daemon.py, elnbuildsync/web.py
Startup installs the asyncio reactor; status templates are loaded asynchronously, cached, and served from memory.
Shared asynchronous YAML loading
elnbuildsync/utils.py, elnbuildsync/config/*
Static and dynamic YAML parsing uses the shared threaded loader, with related configuration formatting updates.
Runtime helpers and error handling
elnbuildsync/auth.py, elnbuildsync/batching.py, elnbuildsync/kojihelpers/*, elnbuildsync/listener.py, elnbuildsync/rebuild*.py, elnbuildsync/status.py, elnbuildsync/email.py
Imports, container initialization, lazy listener imports, exception logging, routing checks, and status lookup implementations are updated.
Model and shared-state typing
elnbuildsync/db_models.py, elnbuildsync/state.py
ORM relationships and shared state use postponed annotations, built-in generics, nullable unions, and explicit class-variable annotations.
Lint workflow and configuration tests
.flake8, .github/workflows/ci.yml, pyproject.toml, tests/test_parse_config.py, tests/smoketest.py
Lint rules and workflow commands are updated; configuration tests use shared temporary-file helpers and grouped patches.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main goal of updating the project for Ruff 0.16.0.
✨ 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.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Also drop the executable portion of web.py, which hasn't actually
supported it for a long time.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
The ruff and flake8 commands differ in their opinions around E203 and
E402, so we'll pick a winner (ruff) and tell flake8 to ignore it.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
@sgallagher

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@elnbuildsync/__init__.py`:
- Around line 19-30: Centralize asyncio reactor bootstrap in
elnbuildsync/__init__.py: install it when no reactor exists, ignore only an
already-installed AsyncioSelectorReactor, and propagate or fail for any other
reactor type. In elnbuildsync/daemon.py, remove the duplicate installation or
make its direct-import bootstrap a no-op when the shared initialization has
already completed, while preserving correct setup for direct daemon imports.
Apply these changes in elnbuildsync/__init__.py lines 19-30 and
elnbuildsync/daemon.py lines 19-35.

In `@elnbuildsync/db_models.py`:
- Around line 94-97: Update DBTagMessage.slice_id and DBTagMessage.slice
annotations to Optional types, matching the nullable ForeignKey and allowing tag
messages without a reachable RebuildBatchSlice association; preserve the
existing mapped_column and relationship configuration.

In `@elnbuildsync/listener.py`:
- Around line 119-120: Update PendingNVRTags to support direct membership by
adding a __contains__ implementation that checks self._data, or change the
membership test in the listener’s tag-handling branch to use
pending_nvr_tags.keys(). Preserve the existing awaited-tag handling behavior.

In `@pyproject.toml`:
- Around line 48-53: Update the Ruff configuration near [tool.ruff.lint] to add
a per-file ignore for elnbuildsync/__init__.py covering E402, preserving the
existing .flake8 suppression and allowing the intentional post-bootstrap imports
to pass ruff check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0ddec43d-aeac-4485-98ee-3e2de121ba94

📥 Commits

Reviewing files that changed from the base of the PR and between c4c092c and 74d5268.

📒 Files selected for processing (29)
  • .flake8
  • .github/workflows/ci.yml
  • elnbuildsync/__init__.py
  • elnbuildsync/auth.py
  • elnbuildsync/batching.py
  • elnbuildsync/cleanup.py
  • elnbuildsync/config/__init__.py
  • elnbuildsync/config/dynamic.py
  • elnbuildsync/config/static.py
  • elnbuildsync/daemon.py
  • elnbuildsync/db_models.py
  • elnbuildsync/decorators.py
  • elnbuildsync/email.py
  • elnbuildsync/kojihelpers/__init__.py
  • elnbuildsync/kojihelpers/builds.py
  • elnbuildsync/kojihelpers/connection.py
  • elnbuildsync/kojihelpers/tags.py
  • elnbuildsync/listener.py
  • elnbuildsync/rebuildattempt.py
  • elnbuildsync/rebuildbatch.py
  • elnbuildsync/rebuildbatchslice.py
  • elnbuildsync/state.py
  • elnbuildsync/status.py
  • elnbuildsync/tagmessage.py
  • elnbuildsync/utils.py
  • elnbuildsync/web.py
  • pyproject.toml
  • tests/smoketest.py
  • tests/test_parse_config.py
💤 Files with no reviewable changes (2)
  • tests/smoketest.py
  • elnbuildsync/kojihelpers/init.py

Comment thread elnbuildsync/__init__.py Outdated
Comment thread elnbuildsync/db_models.py Outdated
Comment thread elnbuildsync/listener.py
Comment thread pyproject.toml
All launches of EBS now go through the entrypoint rather than calling
daemon.py directly, so we can keep the reactor setup in one place.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
elnbuildsync/daemon.py (1)

1-1: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update the README to match the removed direct CLI path.

daemon.py no longer has a shebang or if __name__ == "__main__": main(), but the README still describes it as a CLI entry and shows elnbuildsync/daemon.py as start/feedback documentation. Either restore that direct execution path or update the remaining daemon.py/README references to point at the installed elnbuildsync package entrypoint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@elnbuildsync/daemon.py` at line 1, Update the README and any remaining
daemon.py references to use the installed elnbuildsync package entrypoint
instead of presenting daemon.py as a directly executable CLI; keep documentation
examples and start/feedback guidance consistent with the current entrypoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@elnbuildsync/daemon.py`:
- Line 1: Update the README and any remaining daemon.py references to use the
installed elnbuildsync package entrypoint instead of presenting daemon.py as a
directly executable CLI; keep documentation examples and start/feedback guidance
consistent with the current entrypoint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c210110-fa18-4597-94a5-2fc54fd30e82

📥 Commits

Reviewing files that changed from the base of the PR and between 74d5268 and 2812db9.

📒 Files selected for processing (5)
  • elnbuildsync/__init__.py
  • elnbuildsync/daemon.py
  • elnbuildsync/db_models.py
  • elnbuildsync/state.py
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (3)
  • elnbuildsync/state.py
  • elnbuildsync/init.py
  • elnbuildsync/db_models.py

Use the elnbuildsync script instead.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
@sgallagher
sgallagher merged commit 0924462 into fedora-eln:main Jul 27, 2026
6 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