Merge pull request #28 from jepler/document-mypy

Document how to run mypy; move mypy settings to pyproject.toml
This commit is contained in:
Jeff Epler 2023-11-10 12:09:50 -06:00 committed by GitHub
commit b548797858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 9 deletions

View file

@ -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!=1.7.0'`
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.

View file

@ -4,11 +4,12 @@
.PHONY: mypy
mypy: venv/bin/mypy
venv/bin/mypy --strict --no-warn-unused-ignores -p chap
venv/bin/mypy
# Update CONTRIBUTING.md if these commands change
venv/bin/mypy:
python -mvenv venv
venv/bin/pip install -r requirements.txt mypy
venv/bin/pip install -r requirements.txt 'mypy!=1.7.0'
.PHONY: clean
clean:

View file

@ -1,6 +0,0 @@
# SPDX-FileCopyrightText: 2023 Jeff Epler <jepler@gmail.com>
#
# SPDX-License-Identifier: MIT
[mypy]
mypy_path = src

View file

@ -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"]