Isortwhich is part of the Python extensions
Python Refactortoolkit (
Python Refactor: Sort Imports).
isortby 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.
Isortdefaults 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
docutilsconvert these symbols into formatting for the auto-generated documentation in the admin panel.
flake8to lint Ghostwriter's code. The VSCode Python extension natively supports linting and a variety of linters.
flake8because this linter is much faster and snappier – especially with some of Ghostwriter's longer Python files (e.g., a views.py). The
flake8linter 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-commitfor your local development environment.
.pre-commit-config.yamlfile to the project's root directory. Use the example below as a model for this file.
pre-commit installto hook future git commits.