Skip to content

Commit 233baf3

Browse files
FlyingDiverclaude
andcommitted
Explicitly type action dispatch dicts to fix PyCharm false positive
Annotate the action_methods dicts in do_light_action and do_media_player_action as dict[str, Callable[[indigo.PluginAction, indigo.Device, bool], None]] so type checkers don't have to structurally unify bound methods with differing parameter names, which was causing PyCharm to only partially resolve the callable union and flag valid calls as passing unexpected arguments. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 7f958a6 commit 233baf3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • HomeAssistantAgent.indigoPlugin/Contents/Server Plugin

HomeAssistantAgent.indigoPlugin/Contents/Server Plugin/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import websocket
1212
import ssl
1313
from enum import IntFlag
14-
from typing import Any
14+
from typing import Any, Callable
1515
from zeroconf import IPVersion, ServiceBrowser, ServiceStateChange, Zeroconf
1616
from queue import Queue
1717

@@ -934,7 +934,7 @@ def actionControlDimmerRelay(self, action: Any, device: indigo.Device) -> None:
934934
def do_light_action(self, plugin_action: indigo.PluginAction, device: indigo.Device, _callerWaitingForResult: bool) -> None:
935935
self.logger.debug(f"{device.name}: do_light_action: {plugin_action.props}")
936936
action = plugin_action.props.get("action")
937-
action_methods = {
937+
action_methods: dict[str, Callable[[indigo.PluginAction, indigo.Device, bool], None]] = {
938938
"set_effect": self.set_light_effect_action,
939939
}
940940
method = action_methods.get(action)
@@ -1419,7 +1419,7 @@ def set_fan_preset_mode_action(self, plugin_action: indigo.PluginAction, device:
14191419
def do_media_player_action(self, plugin_action: indigo.PluginAction, device: indigo.Device, _callerWaitingForResult: bool) -> None:
14201420
self.logger.debug(f"{device.name}: do_media_player_action: {plugin_action.props}")
14211421
action = plugin_action.props.get("action")
1422-
action_methods = {
1422+
action_methods: dict[str, Callable[[indigo.PluginAction, indigo.Device, bool], None]] = {
14231423
"media_player_on": self.media_player_on_action,
14241424
"media_player_off": self.media_player_off_action,
14251425
"media_player_set_volume": self.media_player_set_volume_action,

0 commit comments

Comments
 (0)