Skip to content

Use specific rule code on test_log_reader type-ignore#1688

Merged
bdraco merged 1 commit into
mainfrom
fix-log-reader-pgh003
May 20, 2026
Merged

Use specific rule code on test_log_reader type-ignore#1688
bdraco merged 1 commit into
mainfrom
fix-log-reader-pgh003

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 20, 2026

What does this implement/fix?

PGH003 (enabled in #1684) flags bare # type: ignore comments, but the existing one on the protobuf import in tests/test_log_reader.py was missed in the rollout; ruff check now fails on main and on every open PR. Switching the comment to # type: ignore[attr-defined] matches the dynamic-attribute shape of api_pb2.SubscribeLogsResponse and unblocks CI.

One-line change, lint-only.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

  • n/a

Pull request in esphome (if applicable):

  • n/a, no protocol changes.

Checklist:

  • The code change is tested and works locally.
  • If api.proto was modified, a linked pull request has been made to esphome with the same changes.
  • Tests have been added to verify that the new code works (under tests/ folder).

PGH003 (enabled in #1684) flags bare `# type: ignore` comments and
the existing one on the protobuf import in `tests/test_log_reader.py`
was missed in the rollout, so `ruff check` fails on main. Switching
to `# type: ignore[attr-defined]` matches the dynamic-attribute
nature of `api_pb2.SubscribeLogsResponse` and gets CI green again.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1868e05) to head (c1d8656).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1688   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         4159      4159           
=========================================
  Hits          4159      4159           

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 20, 2026

Merging this PR will not alter performance

✅ 40 untouched benchmarks


Comparing fix-log-reader-pgh003 (c1d8656) with main (1868e05)

Open in CodSpeed

@bdraco bdraco marked this pull request as ready for review May 20, 2026 13:18
Copilot AI review requested due to automatic review settings May 20, 2026 13:18
@bdraco bdraco merged commit f12108e into main May 20, 2026
19 checks passed
@bdraco bdraco deleted the fix-log-reader-pgh003 branch May 20, 2026 13:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f619df7-7aa1-40a2-b3a5-0e396b9db9b2

📥 Commits

Reviewing files that changed from the base of the PR and between 1868e05 and c1d8656.

📒 Files selected for processing (1)
  • tests/test_log_reader.py

Walkthrough

A single import line in the test log reader updates its type checker suppression comment to narrow the scope from a generic type: ignore to type: ignore[attr-defined], targeting only the attribute-defined error.

Changes

Type Checker Suppression Refinement

Layer / File(s) Summary
Import type checker suppression narrowing
tests/test_log_reader.py
SubscribeLogsResponse import's # type: ignore comment narrowed from generic suppression to type: ignore[attr-defined] for the specific attribute-defined error.

🎯 1 (Trivial) | ⏱️ ~2 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-log-reader-pgh003

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 and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the tests/test_log_reader.py protobuf import to use a specific # type: ignore[...] code so ruff’s PGH003 rule no longer flags it, restoring CI on main and open PRs.

Changes:

  • Replace a bare # type: ignore with # type: ignore[attr-defined] on the SubscribeLogsResponse import in the log reader test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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