peterjc / flake8-black

flake8 plugin to run black for checking Python coding style
MIT License
165 stars 10 forks source link

Parallel use of `flake8_rst_docstrings` and `flake8_black` broken. #73

Closed tom65536 closed 5 months ago

tom65536 commented 1 year ago

Problem:

When I run pflake8 with both flake8_rst_docstrings and flake8_black plugins active I get a Python exception

    add_options(optmanager)
  File ".../.nox/lint_flake8/lib/python3.9/site-packages/flake8_rst_docstrings.py", line 140, in add_options
    parser.add_option(
  File ".../.nox/lint_flake8/lib/python3.9/site-packages/flake8/options/manager.py", line 415, in add_option
    self._current_group.add_argument(*option_args, **option_kwargs)
  File "/usr/lib/python3.9/argparse.py", line 1446, in add_argument
    return self._add_action(action)
  File "/usr/lib/python3.9/argparse.py", line 1648, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "/usr/lib/python3.9/argparse.py", line 1460, in _add_action
    self._check_conflict(action)
  File "/usr/lib/python3.9/argparse.py", line 1597, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "/usr/lib/python3.9/argparse.py", line 1606, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --rst-directives: conflicting option string: --rst-directives

Running with -vv I can see from the log that both plugins try to register under the same name RST:

...
flake8.plugins.manager    MainProcess     95 DEBUG    Loaded Plugin(name="RST", entry_point="flake8_black:BlackStyleChecker") for plugin "RST".
flake8.plugins.manager    MainProcess     95 DEBUG    Loaded Plugin(name="RST", entry_point="flake8_rst_docstrings:reStructuredTextChecker") for plugin "RST".
...

Solution:

Looking at your pyproject.toml, it looks like you have copy-pasted the wrong name (wasn't it BLK before?):

[project.entry-points]
'flake8.extension' = {RST = 'flake8_black:BlackStyleChecker'}
peterjc commented 1 year ago

Spot the typo :(

Thanks for reporting this...

peterjc commented 1 year ago

Will close this once a new release is up on PyPI...

peterjc commented 1 year ago

https://pypi.org/project/flake8-black/0.3.5/ should fix this. Apologies for the mistake.

peterjc commented 5 months ago

I forgot to close this, I assume it is working since v0.3.5 was released.