Setup¶
Remember that wemake-python-styleguide
is just a flake8
plugin.
Installation¶
pip install wemake-python-styleguide
We also recommend to use poetry
instead of a default pip
.
Running¶
To run our linter you will need to run flake8
in any way you like:
flake8 . # runs on all python files in the current directory (recommended)
flake8 your_module.py # runs on a single file
flake8 your_package # runs on a single your_package
See the flake8
docs for options
and usage examples.
Golden rule is to run your linter on each commit locally and inside the CI. And to fail the build if there are any style violations.
Check out how we do it in our django
and gitlab-ci
template:
https://github.com/wemake-services/wemake-django-template
Ignoring violations¶
We know that people might not agree with 100% of our rules. But we still want to provide the best experience for all users.
So, you can disable some checks, that you are not ok with. Note: you might accidentally break the consistency of this project, when you disable some checks. Report these cases.
There are three ways to ignore some specific violations:
Inline ignore with
# noqa:
comment and comma separated violation codesCommand line argument
--ignore
with comma separated violation codesConfiguration line inside
setup.cfg
ortox.ini
, example
You can ignore:
Whole
WPS
letters, this will completely turn off all our custom checksSome specific group (naming, complexity, consistency, best practices, etc) with
WPS
and the first number of this groupSome specific violation with the full violation code
Use per-file-ignores option, so it is possible to ignore violations on a per-file bases. It means, that you can have different set of violations ignored for different files.
Example:
# contents of setup.cfg
[flake8]
per-file-ignores =
# There are multiple `assert`s in tests, we allow them:
tests/*.py: S101
Read more about ignoring violations in the official docs.