Skip to content

Commit

Permalink
style: Adds mypy configuration and pre-commit repo
Browse files Browse the repository at this point in the history
Closes #49
Closes #52

- [MY100: Uses MyPy (pyproject config)](https://learn.scientific-python.org/development/guides/style#MY100)
- [PC140: Uses a type checker](https://learn.scientific-python.org/development/guides/style#PC140)

Adds configuration of [mypy](https://mypy.readthedocs.io/) to
[`pyproject.toml`](https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file) and the related
`pre-commit` hook.

May need tweaking.
  • Loading branch information
ns-rse committed Nov 20, 2024
1 parent f94c379 commit 0486e32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
files: isoslam
args: ["--ignore-without-code", "--redundant-expr", "--truthy-bool"]

- repo: local
hooks:
- id: pylint
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ docs = [
dev = [
"black",
"ipython",
"mypy",
"pre-commit",
"pylint",
"pyupgrade",
Expand Down Expand Up @@ -255,3 +256,17 @@ override_SS05 = [ # override SS05 to allow docstrings starting with these words
"^Assess ",
"^Access ",
]

[tool.mypy]
files = [
"isoslam",
"tests"
]
python_version = "3.9"
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true

[[tool.mypy.overrides]]
module = [ "numpy.*", ]
ignore_missing_imports = true

0 comments on commit 0486e32

Please sign in to comment.