From 2886eec3265d656379399cf2707df162997ac095 Mon Sep 17 00:00:00 2001 From: cyyc1 <114281716+cyyc1@users.noreply.github.com> Date: Mon, 3 Oct 2022 01:46:37 -0700 Subject: [PATCH] Add pre-commit config; update README --- .pre-commit-config.yaml | 34 ++++++++++++++++++++++++++++++++++ README.md | 24 ++++++++++++++---------- setup.cfg | 2 -- 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..de6e7dc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: debug-statements + - id: double-quote-string-fixer + - id: requirements-txt-fixer +- repo: https://github.com/asottile/setup-cfg-fmt + rev: v2.0.0 + hooks: + - id: setup-cfg-fmt +- repo: https://github.com/asottile/add-trailing-comma + rev: v2.3.0 + hooks: + - id: add-trailing-comma + args: [--py36-plus] +- repo: https://github.com/asottile/pyupgrade + rev: v2.38.2 + hooks: + - id: pyupgrade + args: [--py37-plus] +- repo: https://github.com/pre-commit/mirrors-autopep8 + rev: v1.7.0 + hooks: + - id: autopep8 + args: [--in-place, --max-line-length=88] +- repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + args: [--max-line-length=88] diff --git a/README.md b/README.md index a6cc8d5..15919ed 100644 --- a/README.md +++ b/README.md @@ -97,17 +97,8 @@ class MyClass( ``` You can opt out of class inheritence checks by ignoring rules `IND201` and `IND202`. -## Rationale - -When we only indent by 4 spaces in function definitions, it is difficult to visually distinguish function arguments with the function name and the function body. This reduces readability. - -It is similar for base classes in class definitions, but it's less of an issue than function definitions. +### _Notes_ -## Interaction with other style checkers and formatters - -* [`black`](https://github.com/psf/black)-formatted code will cause a style violation here, because `black` authors [explicitly opted for the 4-space indentation and do not plan to change it](https://github.com/psf/black/issues/1178#issuecomment-614050678) -* The style enforced in this plugin contradicts with rule [WPS318](https://wemake-python-styleguide.readthedocs.io/en/latest/pages/usage/violations/consistency.html#wemake_python_styleguide.violations.consistency.ExtraIndentationViolation) enforced by [wemake-python-styleguide](https://github.com/wemake-services/wemake-python-styleguide) ("WPS") - - But WPS is configurable so you can always opt out of WPS318 * This plugin does not check trailing commas, because [flake8-commas](https://github.com/PyCQA/flake8-commas) already does it * This plugin does not forbid grouping arguments (see example below), because [WPS317](https://wemake-python-styleguide.readthedocs.io/en/latest/pages/usage/violations/consistency.html#wemake_python_styleguide.violations.consistency.ParametersIndentationViolation) can enforce it ```python @@ -117,3 +108,16 @@ def some_func( ): pass ``` + +## Rationale + +When we only indent by 4 spaces in function definitions, it is difficult to visually distinguish function arguments with the function name and the function body. This reduces readability. + +It is similar for base classes in class definitions, but it's less of an issue than function definitions. + +## Interaction with other style checkers and formatters + +* By design, [`black`](https://github.com/psf/black)-formatted code will cause a style violation here, because `black` authors [explicitly opted for the 4-space indentation and do not plan to change it](https://github.com/psf/black/issues/1178#issuecomment-614050678) +* The style enforced in this plugin contradicts with rule [WPS318](https://wemake-python-styleguide.readthedocs.io/en/latest/pages/usage/violations/consistency.html#wemake_python_styleguide.violations.consistency.ExtraIndentationViolation) enforced by [wemake-python-styleguide](https://github.com/wemake-services/wemake-python-styleguide) ("WPS") + - But WPS is configurable, so you can always opt out of WPS318 +* You can use [py-def-indent-formatter](https://github.com/cyyc1/py-def-indent-formatter) right after `black` to make your code satisfy the style requirements of this plugin diff --git a/setup.cfg b/setup.cfg index cd6a821..b3dc762 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,8 +5,6 @@ description = A flake8 plugin that enforces 8-space indentation in function/clas long_description = file: README.md long_description_content_type = text/markdown url = https://github.com/cyyc1/flake8-indent-in-def -author = -author_email = license = MIT license_file = LICENSE classifiers =