mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-31 11:16:54 +00:00
Handle when dest is provided to Option
This commit is contained in:
parent
a4042d6d69
commit
a7f7bbbeb2
2 changed files with 9 additions and 1 deletions
|
|
@ -93,7 +93,7 @@ class Option(object):
|
|||
if not long_option_name:
|
||||
raise ValueError('When specifying parse_from_config=True, '
|
||||
'a long_option_name must also be specified.')
|
||||
self.config_name = self.dest
|
||||
self.config_name = long_option_name[2:].replace('-', '_')
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
|
|
@ -104,6 +104,9 @@ class Option(object):
|
|||
).format(*self.option_args, **self.option_kwargs)
|
||||
|
||||
def _make_dest(self, dest):
|
||||
if dest:
|
||||
return dest
|
||||
|
||||
if self.long_option_name:
|
||||
return self.long_option_name[2:].replace('-', '_')
|
||||
return self.short_option_name[1]
|
||||
|
|
|
|||
|
|
@ -57,3 +57,8 @@ def test_config_name_needs_long_option_name():
|
|||
"""Show that we error out if the Option should be parsed from config."""
|
||||
with pytest.raises(ValueError):
|
||||
manager.Option('-s', parse_from_config=True)
|
||||
|
||||
|
||||
def test_dest_is_not_overridden():
|
||||
opt = manager.Option('-s', '--short', dest='something_not_short')
|
||||
assert opt.dest == 'something_not_short'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue