diff --git a/README.md b/README.md index 010b5b2a..a2b481d7 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,13 @@ The rules enforced are all rules documented in the written convention, which are `ni-python-styleguide` aims to keep the configuration to a bare minimum (none wherever possible). However there are some situations you might need to configure the tool. +### Fix + +`ni-python-styleguide` has a subcommand `fix` which will run [black](https://pypi.org/project/black/) and [isort](https://pycqa.github.io/isort/). + +Additionally, you can run `fix` with the `--aggressive` option and it will add acknowledgements (# noqa) for the remaining linting errors +it cannot fix, in addition to running black and isort. + #### When using `setup.py` If you're using `setup.py`, you'll need to set your app's import names for import sorting. diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index cc2ef138..7e347df2 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -29,7 +29,7 @@ Additionally rules might be suffixed with one of the below: > đŸ’ģ - The convention is automatically enforced by `ni-python-styleguide` (By running `ni-python-styleguide lint ...`) > -> ✨ - The convention is automatically fixed by `ni-python-stylgeuide` (`ni-python-styleguide` command doesn't exist yet) +> ✨ - The convention is automatically fixed by `ni-python-styleguide` (By running `ni-python-styleguide fix ...`) # This vs. other guides (like PEPs) @@ -62,6 +62,8 @@ This document is applicable to all Python versions which are not end-of-life. ### [F.1.1] âœ”ī¸ **DO** Use `black` to format your code đŸ’ģ > đŸ’ģ This rule is enforced by error code BLK100 + +> ✨ This is automatically fixed by running `ni-python-styleguide fix` `black`'s style is well-documented and can be found [here](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html). @@ -690,6 +692,8 @@ This includes packages, modules, classes, functions, attributes and other names. > đŸ’ģ This rule is enforced by error code E401 +> ✨ This is automatically fixed by running `ni-python-styleguide fix` + ```python # Bad import sys, os @@ -732,6 +736,8 @@ URL = "http://python.org" > đŸ’ģ This rule is enforced by error codes I201, I202 +> ✨ This is automatically fixed by running `ni-python-styleguide fix` + Additionally, you should put a single blank line between each group of imports. ```python @@ -765,6 +771,8 @@ import my_app.utils > đŸ’ģ This rule is enforced by error code I100 +> ✨ This is automatically fixed by running `ni-python-styleguide fix` + `from X import Y` imports should follow `import X` imports and be alphabetized by module name. ```python @@ -1002,6 +1010,8 @@ Each documented object should have a one-line summary (with less detail than the > 🐍 This rule stems from [PEP 257](https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings) +â„šī¸ An exception is made for tests as they should already have a very descriptive name + This includes (if applicable) the function's: - arguments (including optional arguments, and keyword arguments) @@ -1246,6 +1256,8 @@ class CheeseShop(object): > 🐍 This rule stems from [PEP 8](https://www.python.org/dev/peps/pep-0008) +> ✨ This is automatically fixed by running `ni-python-styleguide fix` + ```python # Good order = ["egg", "sausage", "bacon"] # The client doesn't want any spam