Skip to content

Add Copilot code review instructions#171

Merged
agners merged 2 commits into
home-assistant-libs:mainfrom
heikkih:chore/add-copilot-instructions
May 12, 2026
Merged

Add Copilot code review instructions#171
agners merged 2 commits into
home-assistant-libs:mainfrom
heikkih:chore/add-copilot-instructions

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented May 12, 2026

Why

GitHub Copilot's PR reviewer fires on this repo (we saw it on #167) but it has no project-specific guidance, so it sometimes suggests things that don't match our conventions (e.g. swapping cast() for pydantic, commenting on style that CI already enforces). Adding .github/copilot-instructions.md is the standard way to give it that guidance.

What's in the file

  • Review-style rules at the top — one-sentence summaries, no style/lint comments, suggest fixes at the right layer, dependency-bump PRs stay focused.
  • Project context — thin async wrapper, primary consumer is HA, source of truth is the Prusa-Link-Web OpenAPI spec.
  • Public API conventionsTypedDicts with cast() at JSON boundaries is deliberate (not a gap to fill with pydantic/msgspec), NotRequired[T] over T | None, T | None for return types where the resource may be absent.
  • Test conventionsrespx for HTTP mocking, pytest.mark.integration opt-in, deps in pyproject.toml.
  • Versioning policy — semver, TypedDict shape changes count as breaking.

Timing note

Some of the conventions described (mypy strict, the cast() pattern, PrinterInfo migrating to NotRequired, get_job() -> JobInfo | None) are landing as part of the upcoming 3.0.0 release in #167 / #169 / #170. The file describes the end state; everything in it will be true on main once those merge. Happy to wait on this PR until after 3.0.0 lands if you'd prefer — but the file is harmless before then, and waiting just means Copilot keeps reviewing PRs without context.

Suggested follow-up: enable automatic review

Right now Copilot review fires on this repo on demand but not automatically — for example #169 and #170 (both just opened) haven't been reviewed by Copilot. If you'd like reviews to run on every new PR, it can be enabled in repo Settings → Code & automationCopilot code review → "Automatically review new pull requests". Up to you whether the trade-off is worth it.

Test plan

Captures the conventions Copilot's PR reviewer should follow when
reviewing this repo: review-style rules at the top (avoid commenting
on lint/formatting since CI already enforces it), public API
conventions (TypedDicts + cast at JSON boundaries is intentional,
NotRequired over T | None, T | None reserved for "no data" return
paths), test layout (respx + optional integration marker), and
semver expectations for TypedDict shape changes.

Standalone — no generator script like home-assistant/core has; the
file is small enough to maintain by hand.

Some of the conventions described (mypy strict, cast() pattern,
PrinterInfo NotRequired migration, get_job() -> JobInfo | None) are
landing as part of the upcoming 3.0.0 release in home-assistant-libs#167 / home-assistant-libs#169 / home-assistant-libs#170.
The file describes the end state; once 3.0.0 ships, everything in
here will be true on main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
- Drop "PrusaLink v2 API" framing — agners pointed out that the
  endpoints aren't versioned that way and the library also covers a
  few legacy paths (/api/version, /api/printer). Replace with
  "PrusaLink HTTP API" and explicitly mention both endpoint families.
- Drop the blanket "suggest fixes at the library level" rule. As
  agners noted, that's case-by-case rather than a general principle.
- Drop "thin wrapper" framing in favour of "the shape is weighted
  toward what serves the HA integration best".
- Add concrete examples of helpful vs unhelpful Copilot feedback so
  the rule list isn't just abstract dos/don'ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@agners agners merged commit 938c2cd into home-assistant-libs:main May 12, 2026
2 checks passed
@heikkih heikkih deleted the chore/add-copilot-instructions branch May 13, 2026 09:22
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.

2 participants