From 52cb9ab2dfdad334c6cc4174526be8948774b854 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 10 Nov 2023 08:02:03 -0600 Subject: [PATCH] Document how to run mypy; move mypy settings to pyproject.toml --- CONTRIBUTING.md | 15 ++++++++++++++- mypy.ini | 6 ------ pyproject.toml | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) delete mode 100644 mypy.ini diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e0708b..f904457 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ There's no particular roadmap for chap, it was created to scratch the original d If you're looking for a way to contribute, check out the open issues. If you want to discuss a possible enhancement before beginning work, opening a fresh issue is a good way to start a dialog about your idea. -## Code style & linting +## Code style & linting with pre-commit This project uses [pre-commit](https://pre-commit.com/) to maintain the code's style and perform some quality checks. First, install pre-commit: `pip install pre-commit`. @@ -26,3 +26,16 @@ It is acceptable to use hints like `# pylint: ignore=diagnostic-kind` when it's When you create a pull request, `pre-commit run --all` is run in a standardized environment, which occasionally catches things that were not seen locally. That green checkmark in github actions is the final arbiter of whether the code is pre-commit clean. + +## Type checking with mypy + +This project uses [mypy](https://www.mypy-lang.org/) for type-checking. +If your system has `make`, you can type-check the project with: `make`. +Otherwise, you need to perform several setup steps: + * create a virtual environment at "venv": `python -mvenv venv` + * install dependencies in the virtual environment: `venv/bin/pip install -r requirements.txt mypy` + +Then, type check with: `venv/bin/mypy` + +When you create a pull request, mypy is run in a standardized environment, which occasionally catches things that were not seen locally. +That green checkmark in github actions is the final arbiter of whether the code is mypy clean. diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 4dbbc58..0000000 --- a/mypy.ini +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Jeff Epler -# -# SPDX-License-Identifier: MIT - -[mypy] -mypy_path = src diff --git a/pyproject.toml b/pyproject.toml index 6311380..ba7239b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,3 +44,9 @@ readme = {file = ["README.md"], content-type="text/markdown"} dependencies = {file = "requirements.txt"} [tool.setuptools.package-data] "pkgname" = ["py.typed"] +[tool.mypy] +mypy_path = ["src"] +warn_unused_ignores = false +warn_redundant_casts = true +strict = true +packages = ["chap"]