From 38a2d8fe938a30dfdfb0c6eb2cf20ce65ffad9f8 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 10 May 2021 18:12:18 -0700 Subject: [PATCH] Add information about black and mypy. --- Developer's-Guide.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Developer's-Guide.md b/Developer's-Guide.md index 83cbab5..0cde0f8 100644 --- a/Developer's-Guide.md +++ b/Developer's-Guide.md @@ -66,6 +66,22 @@ You can run DCS Liberation from source with this configuration: (Adapt it to you ![](https://imgur.com/oXRAZpz.png) +## Type checkers and linters + +We use [black](https://github.com/psf/black) for auto-formatting. The pre-commit hook will automatically run the formatter when you make a commit. See their docs for instructions on configuring black to run in your editor. + +We use [mypy](https://mypy.readthedocs.io/en/stable/) for type checking. Python has built-in support for type annotations but does not perform any checking; that work is delegated to tools like mypy. All new code should include type annotations, and it's generally a good idea to add type annotations to any function you touch. + +To check for type errors, run: + +``` +mypy game gen +``` + +This only checks the `game` and `gen` packages. `qt_ui` will probably never be checkable because `PySide2` (the Python Qt API) contains many patterns that do not play well with the type checker, but it's good to add the annotations anyway as they help the reader. + +The type checker is **not** run as part of pre-commit, since that makes it harder to create WIP commits, but is run as a part of the PR and build checks, so it's best to run before uploading a PR, and definitely should be run before a push to develop. + ## Making a release https://github.com/Khopa/dcs_liberation/wiki/Release-process