Skip to content

Commit 9030803

Browse files
Merge pull request #344 from robbievanleeuwen/mypy
Implement `mypy`
2 parents 7ee9a82 + fe6349b commit 9030803

File tree

19 files changed

+501
-362
lines changed

19 files changed

+501
-362
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
20+
- { python: "3.11", os: "ubuntu-latest", session: "mypy" }
21+
- { python: "3.10", os: "ubuntu-latest", session: "mypy" }
22+
- { python: "3.9", os: "ubuntu-latest", session: "mypy" }
2023
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
2124
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
2225
- { python: "3.9", os: "ubuntu-latest", session: "tests" }

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ __pycache__/
4444

4545
# benchmark results
4646
.benchmarks/
47+
48+
# mypy cache
49+
.mypy_cache/

noxfile.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
nox.needs_version = ">= 2021.6.6"
2727
nox.options.sessions = (
2828
"pre-commit",
29+
"mypy",
2930
"tests",
3031
"docs-build",
3132
)
@@ -137,6 +138,21 @@ def precommit(session: Session) -> None:
137138
activate_virtualenv_in_precommit_hooks(session)
138139

139140

141+
@session(python=python_versions)
142+
def mypy(session: Session) -> None:
143+
"""Type-check using mypy.
144+
145+
Args:
146+
session: Nox session
147+
"""
148+
args = session.posargs or ["src", "docs/conf.py"]
149+
session.install(".")
150+
session.install("mypy", "pytest")
151+
session.run("mypy", *args)
152+
if not session.posargs:
153+
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
154+
155+
140156
@session(python=python_versions)
141157
def tests(session: Session) -> None:
142158
"""Run the test suite.

poetry.lock

Lines changed: 47 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ ipykernel = "^6.25.2"
7676
ipython = "^8.16.1"
7777
ipywidgets = "^8.1.1"
7878
isort = "^5.12.0"
79+
mypy ="^1.6.0"
7980
nbconvert = "^7.9.2"
8081
nbsphinx = "^0.9.3"
8182
notebook = "^7.0.4"
@@ -117,6 +118,26 @@ show_missing = true
117118
profile = "black"
118119
lines_after_imports = 2
119120

121+
[tool.mypy]
122+
strict = true
123+
# output formatting
124+
pretty = true
125+
show_column_numbers = true
126+
show_error_context = true
127+
128+
[[tool.mypy.overrides]]
129+
module = [
130+
"cad_to_shapely.*",
131+
"mpl_toolkits.*",
132+
"numba.*",
133+
"pypardiso.*",
134+
"rhino_shapely_interop.*",
135+
"scipy.*",
136+
"shapely.*",
137+
"triangle.*",
138+
]
139+
ignore_missing_imports = true
140+
120141
[tool.pytest.ini_options]
121142
markers = [
122143
"benchmark_suite: entire benchmark test suite (select with '-m benchmark_suite')",

0 commit comments

Comments
 (0)