Skip to content

Release prep 0.1.2#119

Merged
Kilo59 merged 7 commits intomainfrom
release-prep/0.1.2
Mar 22, 2026
Merged

Release prep 0.1.2#119
Kilo59 merged 7 commits intomainfrom
release-prep/0.1.2

Conversation

@Kilo59
Copy link
Copy Markdown
Owner

@Kilo59 Kilo59 commented Mar 22, 2026

Summary by Sourcery

Prepare the 0.1.2 release by refining pre-commit drift handling, updating documentation diagrams, and bumping project metadata.

Bug Fixes:

  • Ensure configuration drift (exit 1) takes precedence over pre-commit hook drift (exit 2) when both are out of sync in ruff-sync check.

Enhancements:

  • Adjust check command logic to only perform and report pre-commit hook drift checks when the Ruff configuration is already in sync.
  • Improve visual styling and clarity of the Ruff sync and check logic flowcharts in the README and usage documentation.

Build:

  • Bump package version to 0.1.2 and update project metadata, including keywords and development status classifier.

Documentation:

  • Refresh README and usage docs to reflect the updated check/pre-commit behavior and improve diagram styling.

Tests:

  • Add an async test to verify that configuration drift is prioritized over pre-commit drift and that only configuration differences are reported in that scenario.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 22, 2026

Reviewer's Guide

Adjusts check behavior so Ruff config drift takes precedence over pre-commit hook drift, adds a regression test for this exit-code behavior, updates documentation diagrams and styling to match the new logic and Tailwind-inspired palette, and bumps project metadata for the 0.1.2 release.

Sequence diagram for ruff sync check with pre-commit precedence

sequenceDiagram
    actor User
    participant CLI as ruff_sync_check_CLI
    participant Core as core_check
    participant Upstream as upstream_merge
    participant PreCommit as sync_pre_commit

    User->>CLI: invoke_check_command(args)
    CLI->>Core: check(args)

    Core->>Upstream: merge_multiple_upstreams(source_doc)
    Upstream-->>Core: merged_doc

    Core->>Core: compare_semantic_or_text(source_doc, merged_doc)
    alt Ruff_config_out_of_sync
        Core-->>CLI: return_exit_code(1)
        CLI-->>User: Exit 1 (Out of Sync)
    else Ruff_config_in_sync
        alt pre_commit_flag_not_set
            Core-->>CLI: return_exit_code(0)
            CLI-->>User: Exit 0 (In Sync)
        else pre_commit_flag_set
            Core->>PreCommit: sync_pre_commit(cwd, dry_run=True)
            alt hook_version_in_sync
                Core-->>CLI: return_exit_code(0)
                CLI-->>User: Exit 0 (In Sync)
            else hook_version_out_of_sync
                Core-->>CLI: print_warning_and_return(2)
                CLI-->>User: Exit 2 (Hook Drift)
            end
        end
    end
Loading

Flow diagram for ruff sync check exit-code precedence

flowchart TD
    Start([Start check]) --> Compare{Ruff config in sync?}

    Compare -- No --> Exit1([Exit 1: Ruff config out of sync])

    Compare -- Yes --> PCFlag{--pre-commit flag set?}
    PCFlag -- No --> Exit0a([Exit 0: In sync])

    PCFlag -- Yes --> HookMatch{Hook version in sync?}
    HookMatch -- Yes --> Exit0b([Exit 0: In sync])
    HookMatch -- No --> Exit2([Exit 2: Hook drift])

    %% Styling
    style Start fill:#2563eb,color:#fff,stroke:#1d4ed8
    style Compare fill:#ca8a04,color:#fff,stroke:#a16207
    style PCFlag fill:#ca8a04,color:#fff,stroke:#a16207
    style HookMatch fill:#ca8a04,color:#fff,stroke:#a16207
    style Exit0a fill:#16a34a,color:#fff,stroke:#15803d
    style Exit0b fill:#16a34a,color:#fff,stroke:#15803d
    style Exit1 fill:#dc2626,color:#fff,stroke:#b91c1c
    style Exit2 fill:#ea580c,color:#fff,stroke:#c2410c
Loading

File-Level Changes

Change Details Files
Ensure config drift takes precedence over pre-commit hook drift in check and only evaluate pre-commit when configuration is in sync.
  • Remove early pre-commit drift detection flag from the check function and associated out_of_sync branching.
  • Reorder logic so semantic/string equality of Ruff config is evaluated first, returning exit 0 when in sync.
  • When config is in sync and --pre-commit is enabled, run sync_pre_commit in dry-run mode, print a warning if the hook is out of sync, and return exit 2.
  • Maintain existing diff and exit 1 behavior when Ruff configuration differs, without reporting pre-commit drift in that case.
src/ruff_sync/core.py
Add a regression test to validate exit codes and messaging when both Ruff config and pre-commit hooks are out of sync.
  • Set up a local pyproject.toml and remote upstream with differing Ruff target-version values to induce config drift.
  • Create mismatched uv.lock and .pre-commit-config.yaml to simulate pre-commit hook version drift.
  • Invoke ruff_sync.check with pre_commit=True and assert that exit code 1 is returned, config diff is printed, and pre-commit drift is not mentioned.
tests/test_check.py
Update user-facing documentation and diagrams to reflect the simplified check flow and new pre-commit behavior, and refresh styling.
  • Simplify the check flowchart to show a single Fetch & Merge Upstream step and a direct config comparison leading to exit codes 0,1,2, including pre-commit hook version checks only after a config match.
  • Add or update Mermaid style directives in usage and README diagrams to use a consistent Tailwind-like color scheme and highlight comparison/pre-commit nodes.
  • Ensure documentation now labels exit 1 as generic 'Out of Sync' / 'Ruff Config Out of Sync' and exit 2 as 'Hook Drift' while matching the new logic.
docs/usage.md
README.md
Prepare packaging metadata for the 0.1.2 release.
  • Set project version from 0.1.2.dev1 to 0.1.2.
  • Add pre-commit to the project keywords list to improve discoverability.
  • Update classifier from 'Development Status :: 3 - Alpha' to '4 - Beta' to reflect maturity.
  • Regenerate or update uv.lock to match the new release state.
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Kilo59 Kilo59 self-assigned this Mar 22, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The check function now duplicates the pre-commit drift check and message in both the semantic and string-equality branches; consider extracting this into a small helper to keep the control flow and messaging consistent and easier to maintain.
  • The flowchart in docs/usage.md still describes the pre-commit branch, while the simplified flowchart in README.md now omits it; it may be worth aligning these diagrams so the high-level behavior around --pre-commit is described consistently across docs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `check` function now duplicates the pre-commit drift check and message in both the semantic and string-equality branches; consider extracting this into a small helper to keep the control flow and messaging consistent and easier to maintain.
- The flowchart in `docs/usage.md` still describes the pre-commit branch, while the simplified flowchart in `README.md` now omits it; it may be worth aligning these diagrams so the high-level behavior around `--pre-commit` is described consistently across docs.

## Individual Comments

### Comment 1
<location path="src/ruff_sync/core.py" line_range="913" />
<code_context>
         if source_val == merged_val:
             print("✅ Ruff configuration is semantically in sync.")
-            return 2 if out_of_sync else 0
+            if getattr(args, "pre_commit", False) and not sync_pre_commit(
+                pathlib.Path.cwd(), dry_run=True
+            ):
+                print("⚠️ Pre-commit hook version is out of sync!")
+                return 2
+            return 0
     elif source_doc.as_string() == merged_doc.as_string():
         print("✅ Ruff configuration is in sync.")
-        return 2 if out_of_sync else 0
+        if getattr(args, "pre_commit", False) and not sync_pre_commit(
+            pathlib.Path.cwd(), dry_run=True
+        ):
</code_context>
<issue_to_address>
**suggestion:** Avoid duplicating the pre-commit sync check logic in both success branches.

The `getattr(args, "pre_commit", False) and not sync_pre_commit(..., dry_run=True)` block is duplicated in both branches, which risks them diverging and requires double edits for any future behavior changes. Extract this into a shared helper or a single block at the end of the function (e.g., a small function or a final `if getattr(args, "pre_commit", False): ...` before returning) so the pre-commit behavior stays consistent and non-duplicated.

Suggested implementation:

```python
def _check_pre_commit_sync(args) -> int | None:
    """Return exit code 2 if pre-commit hook version is out of sync, otherwise None.

    Shared helper to avoid duplicating the pre-commit synchronization logic.
    """
    if getattr(args, "pre_commit", False) and not sync_pre_commit(
        pathlib.Path.cwd(), dry_run=True
    ):
        print("⚠️ Pre-commit hook version is out of sync!")
        return 2
    return None

    async with httpx.AsyncClient() as client:
        merged_doc = await _merge_multiple_upstreams(
            merged_doc,

```

```python
        if source_val == merged_val:
            print("✅ Ruff configuration is semantically in sync.")
            exit_code = _check_pre_commit_sync(args)
            if exit_code is not None:
                return exit_code
            return 0

```

```python
    elif source_doc.as_string() == merged_doc.as_string():
        print("✅ Ruff configuration is in sync.")
        exit_code = _check_pre_commit_sync(args)
        if exit_code is not None:
            return exit_code

```
</issue_to_address>

### Comment 2
<location path="tests/test_check.py" line_range="369-370" />
<code_context>
+        assert "is out of sync!" in captured.out
+        assert '-target-version = "py310"' in captured.out
+        assert '+target-version = "py311"' in captured.out
+        # Pre-commit drift should NOT be reported if config drift was found and resulted in exit 1
+        assert "pre-commit Ruff hook is out of sync" not in captured.out
+
+
</code_context>
<issue_to_address>
**issue (testing):** The assertion is checking for the absence of an outdated message string and might not protect against regressions in the new behavior.

This test is still keyed to the old warning text (`"pre-commit Ruff hook is out of sync"`), while the implementation now emits `"⚠️ Pre-commit hook version is out of sync!"`. As a result, it won’t fail if the new warning appears. To properly guard against regressions, assert that the current warning string is not present in `captured.out` instead.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/ruff_sync/core.py Outdated
Comment thread tests/test_check.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 22, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.52%. Comparing base (542eb24) to head (11c75d2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/ruff_sync/core.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
- Coverage   90.58%   90.52%   -0.06%     
==========================================
  Files           4        4              
  Lines         722      728       +6     
==========================================
+ Hits          654      659       +5     
- Misses         68       69       +1     

☔ 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.

@github-actions
Copy link
Copy Markdown
Contributor

╒═══════════════╤══════════════╤═════════════════╤════════════╤═════════════════╕
│ File          │ Cyclomatic   │ Maintainabili   │ Unique     │ Lines of Code   │
│               │ Complexity   │ ty Index        │ Operands   │                 │
╞═══════════════╪══════════════╪═════════════════╪════════════╪═════════════════╡
│ tests/test_ch │ 7 -> 8       │ 48.5389 ->      │ 2 -> 3     │ 329 -> 374      │
│ eck.py        │              │ 46.2002         │            │                 │
╘═══════════════╧══════════════╧═════════════════╧════════════╧═════════════════╛

@Kilo59 Kilo59 enabled auto-merge (squash) March 22, 2026 21:13
@Kilo59 Kilo59 merged commit 5e4243b into main Mar 22, 2026
23 of 25 checks passed
@Kilo59 Kilo59 deleted the release-prep/0.1.2 branch March 22, 2026 21:13
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