Skip to content

Commit

Permalink
schema: EmptySchema removed
Browse files Browse the repository at this point in the history
`EmptySchema` was used to return the event without any checks against
its values. Noop lambda is a more lightweight solution for that.

Signed-off-by: Gergő Nagy <grigori.grant@gmail.com>
  • Loading branch information
Gergő Nagy committed Sep 21, 2016
1 parent e3c6c0b commit 7d1f013
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
6 changes: 2 additions & 4 deletions ratatoskr/protectron.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import utils
import schema

from internal_logger import LOG


def protectron(input_schema, output_schema=schema.EmptySchema()):
def protectron(input_schema, output_schema=lambda event: event):
"""
Decorator for validating inputs and outputs according to the given
schema.
Expand All @@ -16,8 +15,7 @@ def protectron(input_schema, output_schema=schema.EmptySchema()):
@input `input_schema` is tested against the arguments of the function
@input `output_schema` is tested against the return value of the function
@default `output_schema` is tested against EmptySchema by default that
matches any payload
@default `output_schema` is tested against no schema
"""
def protectron_decorator(func):
Expand Down
10 changes: 0 additions & 10 deletions ratatoskr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
from exceptions import SchemaValidationError


class EmptySchema:
"""
Matches any payload.
"""

@classmethod
def __call__(cls, event):
return event


class ValidOperationRegistryEventSchema:
"""
Matches if the `event` has all the required keys.
Expand Down

0 comments on commit 7d1f013

Please sign in to comment.