Skip to content

Commit

Permalink
Removed BadArgumentFormat's redundant 'param' parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
epsy committed Mar 12, 2015
1 parent f50402e commit 68be29c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 1 addition & 2 deletions clize/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ class CliValueError(ValueError):
class BadArgumentFormat(ArgumentError):
"""Raised when an argument cannot be converted to the correct format."""

def __init__(self, param, text):
self.param = param
def __init__(self, text):
self.text = text

@property
Expand Down
3 changes: 1 addition & 2 deletions clize/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def coerce_value(self, value, ba):
try:
return table[key]
except KeyError:
raise errors.BadArgumentFormat(
_DummyType(repr(self.display_name)), value)
raise errors.BadArgumentFormat(value)

def read_argument(self, ba, i):
try:
Expand Down
4 changes: 2 additions & 2 deletions clize/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ def coerce_value(self, arg, ba):
try:
ret = self.conv(arg)
except errors.CliValueError as e:
exc = errors.BadArgumentFormat(self, e)
exc = errors.BadArgumentFormat(e)
exc.__cause__ = e
raise exc
except ValueError as e:
exc = errors.BadArgumentFormat(self, repr(arg))
exc = errors.BadArgumentFormat(repr(arg))
exc.__cause__ = e
raise exc
else:
Expand Down
15 changes: 11 additions & 4 deletions clize/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,20 @@ def test_show_list_alt(self):
ba.func('name', *ba.args, **ba.kwargs).split())


baf = errors.BadArgumentFormat


@annotated_sigerror_tests
class MappedErrorTests(object):
not_found = RepTests.mapped_basic, ['dog']
forced_scase = RepTests.mapped_force_scase, ['thing']
not_found = RepTests.mapped_basic, ['dog'], baf, 'Bad value for par: dog'
forced_scase = (
RepTests.mapped_force_scase, ['thing'],
baf, 'Bad value for par: thing')
bas_icase = RepTests.mapped_bad_icase, ['anything'], ValueError
alternate = RepTests.mapped_alternate_list, ['list']
none = RepTests.mapped_no_list, ['list']
alternate = (
RepTests.mapped_alternate_list, ['list'],
baf, 'Bad value for par: list')
none = RepTests.mapped_no_list, ['list'], baf, 'Bad value for par: list'


@test_help
Expand Down

0 comments on commit 68be29c

Please sign in to comment.