Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Feb 14, 2021
1 parent ae6c82d commit 4e80999
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions src/attrs_strict/_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(self, value, attribute):
def __str__(self):
if self.attribute.type is None:
error = (
"attrs-strict error: AttributeTypeError was "
"raised on an attribute ({}) with no defined type".format(
"attrs-strict error: AttributeTypeError was raised on an"
" attribute ({}) with no defined type".format(
self.attribute.name
)
)
Expand Down Expand Up @@ -66,14 +66,14 @@ def __init__(

def __str__(self):
error_msg = (
"Error with: {} . Expected Callable "
"signature: {} got: {}. {} should be {}"
).format(
self.attribute.name,
self.expected_signature,
self.callable_signature,
self.mismatch_callable_arg,
self.expected_callable_arg,
"Error with: {} . Expected Callable signature: {} "
"got: {}. {} should be {}".format(
self.attribute.name,
self.expected_signature,
self.callable_signature,
self.mismatch_callable_arg,
self.expected_callable_arg,
)
)
return self._render(error_msg)

Expand All @@ -87,8 +87,8 @@ def __init__(self, container, attribute):
def __str__(self):
if self.attribute.type is None:
error = (
"attrs-strict error: AttributeTypeError was "
"raised on an attribute ({}) with no defined type".format(
"attrs-strict error: AttributeTypeError was raised on an"
" attribute ({}) with no defined type".format(
self.attribute.name
)
)
Expand All @@ -111,14 +111,14 @@ def __init__(self, container, attribute, tuple_types):

def __str__(self):
error = (
"Element {} has {} elements than types "
"specified in {}. Expected {} received {}"
).format(
self.container,
self._more_or_less(),
self.attribute,
len(self.tuple_types),
len(self.container),
"Element {} has {} elements than types specified in {}. "
"Expected {} received {}".format(
self.container,
self._more_or_less(),
self.attribute,
len(self.tuple_types),
len(self.container),
)
)

return self._render(error)
Expand All @@ -135,9 +135,8 @@ def __init__(self, container, attribute, expected_type):
self.expected_type = expected_type

def __str__(self):
error = "Value of {} {} is not of type {}".format(
self.attribute, self.container, self.expected_type
)
msg = "Value of {} {} is not of type {}"
error = msg.format(self.attribute, self.container, self.expected_type)

return self._render(error)

Expand All @@ -150,10 +149,8 @@ def __init__(self, attribute, value, literals):
self.literals = literals

def __str__(self):
error = "Value of {} {} is not any of the literals specified {}".format(
self.attribute, self.value, self.literals
)

msg = "Value of {} {} is not any of the literals specified {}"
error = msg.format(self.attribute, self.value, self.literals)
return self._render(error)


Expand All @@ -163,10 +160,6 @@ def __init__(self, unsupported_literals):
self.unsupported_literals = unsupported_literals

def __str__(self):
error = (
"Type checking not supported for literals specified in {}".format(
self.unsupported_literals
)
)

msg = "Type checking not supported for literals specified in {}"
error = msg.format(self.unsupported_literals)
return self._render(error)

0 comments on commit 4e80999

Please sign in to comment.