Skip to content

Add core pull request review guide#3113

Draft
MartinHjelmare wants to merge 48 commits into
masterfrom
add-core-pr-review-guide
Draft

Add core pull request review guide#3113
MartinHjelmare wants to merge 48 commits into
masterfrom
add-core-pr-review-guide

Conversation

@MartinHjelmare

@MartinHjelmare MartinHjelmare commented May 21, 2026

Copy link
Copy Markdown
Member

Proposed change

  • Add a pull request review guide for the core repository.
  • The foundation in the guide is generated by AI.

Todo

  • Manually review the generated content.

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features for which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Remove stale or deprecated documentation

Checklist

  • I have read and followed the documentation guidelines.
  • I have verified that my changes render correctly in the documentation.

Additional information

  • This PR fixes or closes issue: fixes #
  • Link to relevant existing code or pull request:

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive PR review guide with a structured reviewer workflow, including first-pass gate checks, triage signals, and detailed category-specific checklists for new integrations, feature changes, bugfixes, code-quality, and dependency-only PRs.
    • Includes testing guidance, entity-pattern recommendations, code-style/error-handling best practices, and git/PR hygiene steps.
    • Updated documentation navigation to include the new guide.

Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
@home-assistant home-assistant Bot marked this pull request as draft May 22, 2026 16:51
@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Note the per-entity polling exception to using DataUpdateCoordinator,
and that raising ConfigEntryAuthFailed requires async_step_reauth to
be implemented in the config flow.
Link to the entity description docs and note that other patterns
described there are also accepted.
A duplicated list risks falling out of sync with the source of truth.
Drop the draft-PR bullet, trim the wordy intro and per-bullet
extended commentary, and remove the confusing closure quote on
the AI-generated PR signals bullet.
- Drop the checkboxes from every bullet.
- Drop the 🤖 (automatable) and ✅ (CI-checked) markers; keep 👁️ to
  highlight items that need human judgment.
- Apply sentence case to all headings.
- Switch em-dashes to the no-space Merriam-Webster style.
- Drop the statistical numbers (PR counts, percentages) sprinkled
  through the bullets and section intros.
@MartinHjelmare MartinHjelmare marked this pull request as ready for review May 25, 2026 15:45
@home-assistant home-assistant Bot requested a review from abmantis May 25, 2026 15:45

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
docs/core/pr_review_guide.md (2)

143-143: 💤 Low value

Consider clarifying "many comments" for readability.

The phrase "generate many comments per reviewed PR" is ambiguous without a comparative reference. Consider "generate the most review comments" or "typically generate many review comments" to improve clarity.

✏️ Optional phrasing improvement
-Bugfixes generate many comments per reviewed PR despite being conceptually simpler than other changes—because reviewers scrutinize whether the fix is actually correct and complete.
+Bugfixes typically generate many review comments despite being conceptually simpler than other changes—because reviewers scrutinize whether the fix is actually correct and complete.
🤖 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 `@docs/core/pr_review_guide.md` at line 143, Edit the sentence that reads
"Bugfixes generate many comments per reviewed PR despite being conceptually
simpler than other changes." and replace it with a clearer phrasing such as
"Bugfixes typically generate many review comments per reviewed PR despite being
conceptually simpler than other changes" or "Bugfixes generate the most review
comments per reviewed PR despite being conceptually simpler than other changes"
to remove ambiguity; update the string in the same paragraph where that sentence
appears (the sentence starting with "Bugfixes generate many comments per
reviewed PR") to one of the suggested alternatives.

303-304: 💤 Low value

Clarify connection cleanup vs memory release.

The statement "Memory is automatically released when the Home Assistant process terminates" might be misread to suggest that connection cleanup isn't necessary. Consider emphasizing that connections (network sockets, file handles) require explicit cleanup via EVENT_HOMEASSISTANT_STOP, even though Python memory is auto-released on process exit.

✏️ Suggested clarification
-- 👁️ **Close connections on shutdown.** When Home Assistant stops connections should be closed. Listen for the `EVENT_HOMEASSISTANT_STOP` event to schedule the cleanup. Memory is automatically released when the Home Assistant process terminates.
+- 👁️ **Close connections on shutdown.** When Home Assistant stops, connections should be closed. Listen for the `EVENT_HOMEASSISTANT_STOP` event to schedule the cleanup. This is necessary for network sockets and file handles even though Python memory is automatically released when the process terminates.
🤖 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 `@docs/core/pr_review_guide.md` around lines 303 - 304, Update the "Close
connections on shutdown" guidance to explicitly distinguish connection cleanup
from memory release: state that while Python memory is reclaimed by the OS when
the process ends, network sockets, file handles, open DB connections and similar
resources must be explicitly closed on shutdown by listening for
EVENT_HOMEASSISTANT_STOP and performing teardown (close(), await
client.disconnect(), cancel tasks, etc.), and give a short example suggestion
text that callers should schedule their cleanup there. Use the heading "Close
connections on shutdown" and the EVENT_HOMEASSISTANT_STOP symbol to locate where
to change the wording.
🤖 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.

Nitpick comments:
In `@docs/core/pr_review_guide.md`:
- Line 143: Edit the sentence that reads "Bugfixes generate many comments per
reviewed PR despite being conceptually simpler than other changes." and replace
it with a clearer phrasing such as "Bugfixes typically generate many review
comments per reviewed PR despite being conceptually simpler than other changes"
or "Bugfixes generate the most review comments per reviewed PR despite being
conceptually simpler than other changes" to remove ambiguity; update the string
in the same paragraph where that sentence appears (the sentence starting with
"Bugfixes generate many comments per reviewed PR") to one of the suggested
alternatives.
- Around line 303-304: Update the "Close connections on shutdown" guidance to
explicitly distinguish connection cleanup from memory release: state that while
Python memory is reclaimed by the OS when the process ends, network sockets,
file handles, open DB connections and similar resources must be explicitly
closed on shutdown by listening for EVENT_HOMEASSISTANT_STOP and performing
teardown (close(), await client.disconnect(), cancel tasks, etc.), and give a
short example suggestion text that callers should schedule their cleanup there.
Use the heading "Close connections on shutdown" and the EVENT_HOMEASSISTANT_STOP
symbol to locate where to change the wording.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 858dd427-fe18-4c27-a653-2a1c7767804c

📥 Commits

Reviewing files that changed from the base of the PR and between 04e4e84 and b47a5f8.

📒 Files selected for processing (1)
  • docs/core/pr_review_guide.md

@Markus98 Markus98 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.

Besides the comments I left, it looks pretty good to me.

I am not sure if we all aligned yet on whether this is something we want to include in the devdocs, so maybe we should confirm if the majority are onboard with merging this before doing it.

Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
@home-assistant home-assistant Bot marked this pull request as draft June 5, 2026 18:21
@MartinHjelmare MartinHjelmare marked this pull request as ready for review June 17, 2026 15:43
@home-assistant home-assistant Bot requested a review from Markus98 June 17, 2026 15:43

@Markus98 Markus98 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.

Just a comment on the emoji tag on the review bullet points. After that has been resolved I am good to approve this. I would ideally want this to have at least one more approval in addition to mine before we merge this so that there is some show of a consensus.


A practical guide for reviewing pull requests on `home-assistant/core`.

Items marked 👁️ require human judgment and are often the hardest to get right when relying on automated checks. The remaining items may be partially covered by linters, hassfest, CI, or automated reviewers, but are listed here as useful context for reviewers.

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.

Maybe we should just get rid of this and the inline emojis altogether? This made sense when we had the other categories, but right now it seems really arbitrary which ones the eye emoji is added to. There are several points which require human judgement that are not marked as such.

@home-assistant home-assistant Bot marked this pull request as draft June 18, 2026 07:34
Comment thread docs/core/pr_review_guide.md Outdated
Comment thread docs/core/pr_review_guide.md Outdated
### 6.3 License compliance

- **License hasn't changed between versions.** A license change (e.g., MIT → GPL-3.0) between the old and new version would be a critical issue. Compare the `license` field on PyPI for both versions.
- **License is still Apache-2.0-compatible.** Same rules as new integrations: GPL-2.0/3.0/AGPL are incompatible with HA Core's Apache-2.0 license.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that already a rule? I don't think we enforce this and it is document nowhere else

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The dependency license must obviously not be incompatible with our own license.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That does make sense logically. All I am saying we don’t really consider this at the moment and it’s not written explicitly anywhere. I recently asked frenck about this and he said they (you?) were working on solution 🤷‍♂️

Comment thread docs/core/pr_review_guide.md Outdated

### 7.3 Mocking

- 👁️ **Mock the library, not HA internals.** Mocks should target the third-party library's API calls, not Home Assistant's internal mechanisms.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could use some more details & examples (coordinator, etc.) because "HA internals" is an abstract concept

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's follow up with that, in that case.

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Comment thread docs/core/pr_review_guide.md
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.

8 participants