Merge pull request #28 from jepler/document-mypy
Document how to run mypy; move mypy settings to pyproject.toml
This commit is contained in:
commit
b548797858
4 changed files with 23 additions and 9 deletions
|
|
@ -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.
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -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:
|
||||
|
|
|
|||
6
mypy.ini
6
mypy.ini
|
|
@ -1,6 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2023 Jeff Epler <jepler@gmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
[mypy]
|
||||
mypy_path = src
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue