Skip to content
Permalink
Browse files

Drop local_types, resolve missing type annotations

Fall back to typing.Any for the time being until a better solution is
figured out.
  • Loading branch information
lovett committed Jan 14, 2020
1 parent 3512014 commit dfb18385406e6e8495e8fade8c4fb6accf3691e8
Showing with 26 additions and 15 deletions.
  1. +0 −2 local_types.py
  2. +1 −1 plugins/jinja.py
  3. +19 −5 plugins/registry.py
  4. +6 −7 plugins/scheduler.py
@@ -3,8 +3,6 @@
import typing


NegotiableView = typing.Dict[str, typing.Any]

Args = typing.List[typing.Any]

Kwargs = typing.Dict[str, typing.Any]
@@ -85,7 +85,7 @@ def start(self) -> None:
self.bus.subscribe("lookup-template", self.get_template)
self.bus.subscribe("jinja:render", self.render)

def render(self, template_name: str, **kwargs) -> bytes:
def render(self, template_name: str, **kwargs: typing.Any) -> bytes:
"""Populate a Jinja template."""

template = self.env.get_template(template_name)
@@ -85,7 +85,11 @@ def add(
[(key, value) for value in clean_values]
)

def search(self, key: typing.Optional[str] = None, **kwargs) -> typing.Any:
def search(
self,
key: str = "",
**kwargs: typing.Any
) -> typing.Any:
"""Search for records by key or value."""

keys = kwargs.get("keys", ())
@@ -145,7 +149,11 @@ def search(self, key: typing.Optional[str] = None, **kwargs) -> typing.Any:

return result

def search_dict(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
def search_dict(
self,
*args: typing.Any,
**kwargs: typing.Any
) -> typing.Dict[str, typing.Any]:
"""Shape a search result as a key-value dict."""

key_slice = kwargs.get("key_slice", 0)
@@ -159,7 +167,9 @@ def search_dict(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
}

def search_multidict(
self, *args, **kwargs
self,
*args: typing.Any,
**kwargs: typing.Any
) -> typing.Dict[str, typing.List]:
"""Shape a search result as a dict whose values are lists."""

@@ -175,7 +185,11 @@ def search_multidict(

return multi_dict

def search_valuelist(self, *args, **kwargs) -> typing.List:
def search_valuelist(
self,
*args: typing.Any,
**kwargs: typing.Any
) -> typing.List:
"""Shape a result set as a list of values."""

rows = self.search(*args, **kwargs)
@@ -203,7 +217,7 @@ def remove_id(self, rowid: int) -> int:
def first_key(
self,
value: typing.Any = None,
key_prefix: str = None
key_prefix: str = ""
) -> typing.Optional[str]:
"""Perform a search by value and return the key of the first match.
@@ -4,7 +4,6 @@
import sched
import typing
import cherrypy
import local_types


class ScheduledEvent():
@@ -135,17 +134,17 @@ def revive(self) -> None:
@staticmethod
def execute(
name: str,
*args: local_types.Args,
**kwargs: local_types.Kwargs
*args: typing.Any,
**kwargs: typing.Any
) -> None:
"""Run a previously-scheduled job."""
cherrypy.engine.publish(name, *args, **kwargs)

def add(
self,
delay_seconds: int,
*args: local_types.Args,
**kwargs: local_types.Kwargs
*args: typing.Any,
**kwargs: typing.Any
) -> ScheduledEvent:
"""Schedule an event for future execution
@@ -173,8 +172,8 @@ def add(
def persist(
self,
delay_seconds: int,
*args: local_types.Args,
**kwargs: local_types.Kwargs
*args: typing.Any,
**kwargs: typing.Any
) -> ScheduledEvent:
"""Schedule an event and then cache it.

0 comments on commit dfb1838

Please sign in to comment.
You can’t perform that action at this time.