Skip to content

fix: align backend protocol with frozen adapters#337

Merged
vinitkumar merged 1 commit into
masterfrom
codex/fix-ty-typecheck
Jul 11, 2026
Merged

fix: align backend protocol with frozen adapters#337
vinitkumar merged 1 commit into
masterfrom
codex/fix-ty-typecheck

Conversation

@vinitkumar

@vinitkumar vinitkumar commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • model BackendAdapter.name as a read-only protocol property
  • align the protocol with the frozen Rust and Python adapter dataclasses
  • document the adapter metadata contract in lat.md

Root cause

BackendAdapter declared name as a writable string attribute. The concrete adapters are frozen dataclasses, so ty correctly rejected them as protocol implementations because their name fields cannot be written.

Impact

The ty typecheck passes without weakening diagnostics or changing runtime behavior.

Validation

  • VIRTUAL_ENV="$PWD/.venv" uvx ty check json2xml tests
  • uvx ruff check json2xml tests
  • .venv/bin/pytest --cov=json2xml --cov-report=xml:coverage/reports/coverage.xml --cov-report=term -q tests (312 passed, 94 skipped, 100% coverage)
  • cargo test --manifest-path rust/Cargo.toml (46 passed)
  • lat check

Summary by Sourcery

Model backend adapter names as read-only protocol properties to match frozen adapter implementations and update architecture docs accordingly.

Bug Fixes:

  • Make the BackendAdapter protocol compatible with frozen Rust and Python adapter implementations by exposing name as a read-only property.

Documentation:

  • Document the backend adapter metadata contract and its read-only diagnostic name property in the architecture overview.

Model backend names as read-only protocol properties so ty accepts the frozen Rust and Python adapter implementations.
@sourcery-ai

sourcery-ai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Aligns the BackendAdapter protocol with existing frozen Rust/Python adapter implementations by making the adapter name a read-only property and updating architecture docs to describe the backend adapter metadata contract.

File-Level Changes

Change Details Files
Model backend adapter names as read-only properties to match frozen adapter implementations.
  • Change BackendAdapter.name from a writable attribute to a read-only @Property on the protocol.
  • Define the name property signature to return str and raise NotImplementedError in the protocol to indicate implementors must provide it.
json2xml/backend_selector.py
Document the backend adapter metadata contract in the architecture notes.
  • Describe that backend adapter exposes its diagnostic name as a read-only property.
  • Clarify that this protocol matches frozen adapter implementations while still allowing selector code to inspect backend metadata.
lat.md/architecture.md

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

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (21fa5a4) to head (79be41f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #337   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          729       730    +1     
=========================================
+ Hits           729       730    +1     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

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

@vinitkumar vinitkumar marked this pull request as ready for review July 11, 2026 08:22

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


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.

@vinitkumar vinitkumar merged commit ea80fc6 into master Jul 11, 2026
62 of 63 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