Skip to content

Commit

Permalink
Bounded raises an appropriate error if bound and values are incompatible
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Jul 29, 2018
1 parent 84da593 commit 9e32b87
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions graphi/types/bounded.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ def __init_mapping__(self, mapping, **kwargs):
super(Bounded, self).__init_mapping__(mapping, **kwargs)

def _ensure_bounds(self):
value = None # in case anything else raises that TypeError
blacklist = []
for tail, head, value in self.items():
if value > self.value_bound:
blacklist.append((tail, head))
try:
for tail, head, value in self.items():
if value > self.value_bound:
blacklist.append((tail, head))
except TypeError as err:
raise ValueError('cannot bound %r to %r: %s' % (value, self.value_bound, err))
if self.undirected:
blacklist = {{tail, head} for tail, head in blacklist}
for tail, head in blacklist:
Expand Down

0 comments on commit 9e32b87

Please sign in to comment.