Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse.ArgumentError: argument --black: conflicting option string: --black #1

Closed
jaraco opened this issue Sep 9, 2020 · 0 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Sep 9, 2020

After employing the 'allow' technique in the 3.0 release, I merged the changes into jaraco/skeleton and then into irc, but when running the tests, I encountered this error:

Traceback (most recent call last):
  File "/Users/jaraco/code/main/irc/.tox/python/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 180, in console_main
    code = main()
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 136, in main
    config = _prepareconfig(args, plugins)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 313, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/helpconfig.py", line 99, in pytest_cmdline_parse
    config = outcome.get_result()  # type: Config
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 932, in pytest_cmdline_parse
    self.parse(args)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1204, in parse
    self._preparse(args, addopts=addopts)
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1099, in _preparse
    self.known_args_namespace = ns = self._parser.parse_known_args(
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/argparsing.py", line 147, in parse_known_args
    return self.parse_known_and_unknown_args(args, namespace=namespace)[0]
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/argparsing.py", line 157, in parse_known_and_unknown_args
    optparser = self._getparser()
  File "/Users/jaraco/code/main/irc/.tox/python/lib/python3.8/site-packages/_pytest/config/argparsing.py", line 121, in _getparser
    arggroup.add_argument(*n, **a)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1386, in add_argument
    return self._add_action(action)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1590, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1400, in _add_action
    self._check_conflict(action)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1539, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1548, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --black: conflicting option string: --black

I was afraid this might happen. It seems that the order that plugins happen to load can affect the behavior, so if jaraco.test loads first, then pytest-black loads, pytest-black will fail to register its command-line option because jaraco.test already has registered it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant