Modernize typing syntax in entity and platform doc examples#3199
Conversation
📝 WalkthroughWalkthroughDocumentation code examples in ChangesType annotation modernization in docs examples
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@docs/core/entity/fan.md`:
- Around line 155-172: The code example for the `turn_on` and `async_turn_on`
method signatures uses the `Any` type annotation in the `**kwargs: Any`
parameter, but the documentation does not show where `Any` is imported from. Add
either an import statement at the beginning of the code example showing `from
typing import Any`, or add a clarifying note in the documentation text
explaining that `Any` must be imported from the `typing` module (or from
`builtins` in Python 3.11+).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bdb2d640-a8f2-423b-8f09-a06b6978f5c8
📒 Files selected for processing (3)
docs/core/entity/conversation.mddocs/core/entity/fan.mddocs/core/platform/reproduce_state.md
| # Implement one of these methods. | ||
|
|
||
| def turn_on(self, speed: Optional[str] = None, percentage: Optional[int] = None, preset_mode: Optional[str] = None, **kwargs: Any) -> None: | ||
| def turn_on( |
There was a problem hiding this comment.
the signature seems to be different - there is no speed argument in the original FanEnity
Proposed change
A few entity and platform documentation examples still used the legacy typing syntax (
Optional[...]andtyping.Iterable). This updates them to the modern syntax that Home Assistant uses: PEP 604 unions (X | None) andcollections.abcfor the abstract base classes.fan.md:percentageproperties and theturn_on/async_turn_onsignatures (the latter split to one argument per line).conversation.md: theconversation_idtype in theConversationInputtable.reproduce_state.md: the import line and thecontextparameter.Type of change
Checklist
Additional information
Summary by CodeRabbit
str | Noneinstead ofOptional[str]).