From 8b400a7ad343968f0d535d31ce1a3ef79f3433d8 Mon Sep 17 00:00:00 2001 From: Michelle Narus Date: Mon, 27 Mar 2023 16:21:39 -0400 Subject: [PATCH 1/7] Fix BLK100 issue --- .gitignore | 3 +++ docs/Coding-Conventions.md | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 16aef961..84ea0c65 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ dist/ # Can show up during `poetry install` setup.py + +# If the user uses Visual Studio +/.vs diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index fdcccc8d..80377189 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -1149,17 +1149,17 @@ class CheeseShop(object): > 🐍 This rule stems from [PEP 257](https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings) -> đŸ’ģ This rule is enforced by error codes D201, D211 +> đŸ’ģ This rule is enforced by error codes D201, D211, BLK100 ```python -# Bad - will produce D211 +# Bad - will produce D211, BLK100 class CheeseShop(object): """Finest cheese shop in the district, offering a wide variety of cheeses.""" ``` ```python -# Bad - will produce D201 +# Bad - will produce D201, BLK100 class CheeseShop(object): def sell(self, type_): From 058fe95bc30d4f8a467292010b6c6fd0823e01be Mon Sep 17 00:00:00 2001 From: Michelle Narus Date: Mon, 24 Apr 2023 16:53:18 -0400 Subject: [PATCH 2/7] make some doc changes for fix --- README.md | 5 +++++ docs/Coding-Conventions.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 010b5b2a..a7f9835c 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ 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 + +To `fix` issues `ni-python-styleguide` can generically fix, run with `fix` subcommand. This will run black and sort imports. +Alternatively, you can run `fix` with the `--aggressive` option and it is the same as fix except it is run multiple times...\. + #### 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 80377189..befb2493 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-stylgeuide` (By running `ni-python-styleguide fix ...`) # This vs. other guides (like PEPs) From d0ba3a4db3ae1f9136ccb2aed00ee42889f94003 Mon Sep 17 00:00:00 2001 From: Michelle Narus Date: Thu, 27 Apr 2023 17:25:25 -0400 Subject: [PATCH 3/7] Update docs for fix --- README.md | 6 ++++-- docs/Coding-Conventions.md | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7f9835c..4f16db4b 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,10 @@ However there are some situations you might need to configure the tool. ### Fix -To `fix` issues `ni-python-styleguide` can generically fix, run with `fix` subcommand. This will run black and sort imports. -Alternatively, you can run `fix` with the `--aggressive` option and it is the same as fix except it is run multiple times...\. +`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 exclusions (# noqa) for the linting errors +it cannot fix, in addition to running black and isort. #### When using `setup.py` diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index befb2493..c24477a4 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -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 rule is covered by running `ni-python-stylgeuide 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 rule is covered by running `ni-python-stylgeuide fix` + ```python # Bad import sys, os @@ -732,6 +736,8 @@ URL = "http://python.org" > đŸ’ģ This rule is enforced by error codes I201, I202 +> ✨ This rule is covered by running `ni-python-stylgeuide 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 rule is covered by running `ni-python-stylgeuide 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 + This includes (if applicable) the function's: - arguments (including optional arguments, and keyword arguments) @@ -1275,6 +1285,8 @@ class CheeseShop(object): > 🐍 This rule stems from [PEP 8](https://www.python.org/dev/peps/pep-0008) +> ✨ This rule is covered by running `ni-python-stylgeuide fix` + ```python # Good order = ["egg", "sausage", "bacon"] # The client doesn't want any spam From f46c0c5bf26859d157738f37c719e4f7afd6bedf Mon Sep 17 00:00:00 2001 From: mnarus <128721532+mnarus@users.noreply.github.com> Date: Fri, 28 Apr 2023 12:01:33 -0400 Subject: [PATCH 4/7] Update docs/Coding-Conventions.md Co-authored-by: mshafer-NI --- docs/Coding-Conventions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index 7a94558b..fef79971 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -1010,7 +1010,7 @@ 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 +â„šī¸ An exception is made for tests as they should already have a very descriptive name This includes (if applicable) the function's: From f9bd24c157602fbd271349668b4a326364d127f2 Mon Sep 17 00:00:00 2001 From: mnarus <128721532+mnarus@users.noreply.github.com> Date: Fri, 28 Apr 2023 12:01:49 -0400 Subject: [PATCH 5/7] Update README.md Co-authored-by: mshafer-NI --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f16db4b..a2b481d7 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ However there are some situations you might need to configure the tool. `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 exclusions (# noqa) for the linting errors +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` From 6b455085b852cbcae109705864d9165b5f53005c Mon Sep 17 00:00:00 2001 From: Michelle Narus Date: Fri, 28 Apr 2023 12:32:27 -0400 Subject: [PATCH 6/7] address feedback --- docs/Coding-Conventions.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index 7a94558b..749319d7 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -63,7 +63,7 @@ This document is applicable to all Python versions which are not end-of-life. > đŸ’ģ This rule is enforced by error code BLK100 -> ✨ This rule is covered by running `ni-python-stylgeuide fix` +> ✨ 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). @@ -692,7 +692,7 @@ This includes packages, modules, classes, functions, attributes and other names. > đŸ’ģ This rule is enforced by error code E401 -> ✨ This rule is covered by running `ni-python-stylgeuide fix` +> ✨ This is automatically fixed by running `ni-python-styleguide fix` ```python # Bad @@ -736,7 +736,7 @@ URL = "http://python.org" > đŸ’ģ This rule is enforced by error codes I201, I202 -> ✨ This rule is covered by running `ni-python-stylgeuide fix` +> ✨ This is automatically fixed by running `ni-python-styleguide fix` Additionally, you should put a single blank line between each group of imports. @@ -771,7 +771,7 @@ import my_app.utils > đŸ’ģ This rule is enforced by error code I100 -> ✨ This rule is covered by running `ni-python-stylgeuide fix` +> ✨ 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. @@ -1256,7 +1256,7 @@ class CheeseShop(object): > 🐍 This rule stems from [PEP 8](https://www.python.org/dev/peps/pep-0008) -> ✨ This rule is covered by running `ni-python-stylgeuide fix` +> ✨ This is automatically fixed by running `ni-python-styleguide fix` ```python # Good From 833dc49b7fa46d81ee953c9631c7b5ae7203689e Mon Sep 17 00:00:00 2001 From: Michelle Narus Date: Fri, 28 Apr 2023 12:34:47 -0400 Subject: [PATCH 7/7] typo --- docs/Coding-Conventions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index 0caa71b5..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` (By running `ni-python-styleguide fix ...`) +> ✨ - The convention is automatically fixed by `ni-python-styleguide` (By running `ni-python-styleguide fix ...`) # This vs. other guides (like PEPs)