Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 13 additions & 1 deletion docs/Coding-Conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down