tholo / pytest-flake8

pytest plugin to run flake8
Other
117 stars 47 forks source link

Deactivating the plugin #80

Open m-aciek opened 3 years ago

m-aciek commented 3 years ago

Hi, I have pytest-flake8 installed, and in my pytest.ini file I have addopts: --flake8. In my CI I'd like to disable flake8 checks (I have separate job for them), but reuse other parts of the config. If I add -p no:flake8, the pytest invocation fails with:

% pytest tests -p no:flake8       
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --flake8
  inifile: …/pytest.ini
  rootdir: …

I didn't find any other way to disable the plugin using command line option. Is there any? If not, should it be fixed on pytest side or potentially added on pytest-flake8 side?

m-aciek commented 3 years ago

For what is worth I was able to disable the plugin by prepending pytest invocation on CI with:

- sed -i "s/--flake8//" pytest.ini  # removes --flake8 from pytest.ini
- pytest tests
jaraco commented 2 years ago

I have a similar issue. I've worked around the issue by using pytest-enabler. See https://github.com/jaraco/skeleton/blob/aae281a9ff6c9a1fa9daad82c79457e8770a1c7e/pyproject.toml#L16-L17. This plugin allows pytest-flake8 to be enabled when the plugin is enabled, but not when the plugin is not. By default, it's enabled, but one can pass -p no:flake8 to disable the plugin. Please give it a try.