python
)Isort
which is part of the Python extensions Python Refactor
toolkit (Python Refactor: Sort Imports
).isort
by pressing SHIFT+CMD+P and selecting Python Refactor: Sort Imports
.You probably noticed the peculiar default line length. Black defaults to 88 characters per line, which happens to be 10% over 80. This number was found to produce significantly shorter files than sticking with 80 (the most popular), or even 79 (used by the standard library). In general, 90-ish seems like the wise choice.
Isort
defaults to 79 to match PEP-8, so a line length must be configured to avoid style conflicts."""
which deviates from standard practice (per PEP-8). Further, the use of grave accents, asterisks ( * ), and colons ( : ). are all purposeful and important. Django and docutils
convert these symbols into formatting for the auto-generated documentation in the admin panel.flake8
to lint Ghostwriter's code. The VSCode Python extension natively supports linting and a variety of linters.PyLint
to flake8
because this linter is much faster and snappier – especially with some of Ghostwriter's longer Python files (e.g., a views.py). The flake8
linter is logical and stylistic, like PyLint
. Black should handle most of the linting, but it won't flag unused imports.Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements. By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks.
pip install pre-commit
for your local development environment. .pre-commit-config.yaml
file to the project's root directory. Use the example below as a model for this file.pre-commit install
to hook future git commits.