Skip to content

Commit 6c3ef15

Browse files
committed
2 parents 746a2ad + 988c871 commit 6c3ef15

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

docs/_posts/python/2021-07-01-code-quality-github-actions.markdown

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ permalink: /python/github-actions
99
</div>
1010

1111
<div id="intro" markdown="1">
12-
Python's not the strictest language, so to have any confidence in your code you
13-
need to hit it with a barrage of checks to ensure it meets at least some level
14-
of quality.
12+
Python's not the strictest language, so to have any confidence in your code it needs
13+
to be hit with a barrage of checks to ensure it meets some level of quality.
1514
</div>
1615

1716
I use the following code quality checks:
@@ -51,12 +50,7 @@ jobs:
5150

5251
## Notes
5352

54-
- Be consistent with the Black version across your tooling.
55-
The formatting can change between versions, so what's considered "formatted"
56-
in one version may not be in another. Note as of 2022 Black has a
57-
[Stability Policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html)
58-
which states the formatting will not change in a calendar year.
59-
- If you have an existing project with un-blackened code, _format the entire
60-
project all at once_. Don't do it gradually. Do it in a single dedicated pull request.
53+
- To exclude certain files and directories, use the exclude options to each tool, (usually `--exclude`).
54+
- If you have an existing project with unformatted code, _format the entire project all at once_. Don't do it gradually. I do it in a single dedicated PR, but I've seen others reformat the repository's entire history, to preserve git blame.
6155

6256
See also: [How to use Ruff, Mypy, Black and Isort in Pre-commit?](/python/pre-commit)

docs/_posts/python/2021-07-01-code-quality-pre-commit.markdown

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ redirect_from:
1515
</div>
1616

1717
<div id="intro" markdown="1">
18-
Python's not the strictest language, so to have any confidence in your code you
19-
need to hit it with a barrage of checks to ensure it meets at least some level
20-
of quality.
18+
Python's not the strictest language, so to have any confidence in your code it needs
19+
to be hit with a barrage of checks to ensure it meets some level of quality.
2120
</div>
2221

2322
I use the following code quality checks:
@@ -78,15 +77,11 @@ pre-commit install
7877

7978
## Notes
8079

81-
- Isort needs to know about your project's dependencies, therefore the hook
80+
- Isort needs to know about your project's dependencies in order to determine which groups to put your imports in. Therefore the hook
8281
only works with a local installation of isort, (i.e. it's installed in your
8382
environment).
84-
- Be consistent with the Black version across your tooling.
85-
The formatting can change between versions, so what's considered "formatted"
86-
in one version may not be in another. Note as of 2022 Black has a
87-
[Stability Policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html)
88-
which states the formatting will not change in a calendar year.
89-
- If you have an existing project with un-blackened code, _format the entire
90-
project all at once_. Don't do it gradually. Do it in a single dedicated pull request.
83+
- You may want to run tests in pre-commit as well. I prefer to run them separately.
84+
- To exclude certain files and directories, use the exclude option, e.g. `exclude: ^(docs/|examples/request.py)`.
85+
- If you have an existing project with unformatted code, _format the entire project all at once_. Don't do it gradually. I do it in a single dedicated PR, but I've seen others reformat the repository's entire history, to preserve git blame.
9186

9287
See also: [How to use Ruff, Mypy, Black, Isort and Pytest in Github Actions?](/python/github-actions)

0 commit comments

Comments
 (0)