Skip to content

Commit

Permalink
Types for consumers part2
Browse files Browse the repository at this point in the history
  • Loading branch information
redaxmedia committed Nov 19, 2019
1 parent 62cc438 commit 5ba2c60
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
10 changes: 6 additions & 4 deletions chroma_feedback/consumer/lifx_light/core.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
from chroma_feedback import wording
from typing import Any, Dict, List
from argparse import ArgumentParser
from chroma_feedback import helper, wording
from .api import get_api
from .group import get_groups, process_groups
from .light import get_lights, process_lights

ARGS = None


def init(program):
def init(program : ArgumentParser) -> None:
global ARGS

if not ARGS:
program.add_argument('--lifx-light-light', action = 'append')
program.add_argument('--lifx-light-group', action = 'append')
ARGS = program.parse_known_args()[0]
ARGS = helper.get_first(program.parse_known_args())


def run(status):
def run(status : str) -> List[Dict[str, Any]]:
api = get_api()

# use groups
Expand Down
9 changes: 5 additions & 4 deletions chroma_feedback/consumer/lifx_light/group.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Any, Dict, List
from chroma_feedback import color
from .api import get_api


def get_groups(group_names):
def get_groups(group_names : List[str]) -> List[Dict[str, Any]]:
api = get_api()
groups = []

Expand All @@ -12,12 +13,12 @@ def get_groups(group_names):
return groups


def get_group_name(group):
def get_group_name(group : Any) -> Any:
for device in group.get_device_list():
return device.get_group_label()


def process_groups(status, groups):
def process_groups(status : str, groups : Any) -> List[Dict[str, Any]]:
result = []

# process groups
Expand Down Expand Up @@ -64,7 +65,7 @@ def process_groups(status, groups):
return result


def static_group(group, state):
def static_group(group : Any, state : Any) -> bool:
return group.set_power('on') is None and group.set_color(
[
state['hue'],
Expand Down
8 changes: 4 additions & 4 deletions chroma_feedback/consumer/lifx_light/light.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Dict, List
import copy

from chroma_feedback import color


def get_lights(lights, light_names):
def get_lights(lights : Any, light_names : List[str]) -> Any:
if light_names:
for light in copy.copy(lights):
light_name = light.get_label()
Expand All @@ -13,7 +13,7 @@ def get_lights(lights, light_names):
return lights


def process_lights(status, lights):
def process_lights(status : str, lights : Any) -> List[Dict[str, Any]]:
result = []

# process lights
Expand Down Expand Up @@ -60,7 +60,7 @@ def process_lights(status, lights):
return result


def static_light(light, state):
def static_light(light : Any, state : Dict[str, Any]) -> bool:
return light.set_power('on') is None and light.set_color(
[
state['hue'],
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ strict_optional = False
warn_return_any = True

[mypy-chroma_feedback.*]

ignore_errors = True

[mypy-tests.*]
ignore_errors = True

0 comments on commit 5ba2c60

Please sign in to comment.