Skip to content

Commit 8e32f9c

Browse files
authored
Type annotations (#460)
* round 1: clean, but lots of ignore * round 2: ignore less * ruff check * ruff format * update and tighten mypy configuration * pipeline fixes
1 parent df98af4 commit 8e32f9c

24 files changed

+1159
-643
lines changed

poetry.lock

Lines changed: 167 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pytest = "^7.2.0"
2828
pytest-cov = "^4.0.0"
2929
PyYAML = "^6.0"
3030
pre-commit = "^2.20.0"
31-
mypy = "^0.990"
31+
mypy = "1.19.1"
3232
Sphinx = "^4.3.2"
3333
furo = "^2022.9.29"
3434

@@ -54,6 +54,15 @@ force-single-line = true
5454
lines-after-imports = 2
5555
lines-between-types = 1
5656

57+
[tool.mypy]
58+
files = "tomlkit, tests"
59+
strict = true
60+
enable_error_code = [
61+
"ignore-without-code",
62+
"redundant-expr",
63+
"truthy-bool",
64+
]
65+
5766
[build-system]
5867
requires = ["poetry-core>=1.0.0a9"]
5968
build-backend = "poetry.core.masonry.api"

tests/conftest.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import os
22

3+
from collections.abc import Callable
4+
35
import pytest
46

57

68
@pytest.fixture
7-
def example():
8-
def _example(name):
9+
def example() -> Callable[[str], str]:
10+
def _example(name: str) -> str:
911
with open(
1012
os.path.join(os.path.dirname(__file__), "examples", name + ".toml"),
1113
encoding="utf-8",
@@ -16,8 +18,8 @@ def _example(name):
1618

1719

1820
@pytest.fixture
19-
def json_example():
20-
def _example(name):
21+
def json_example() -> Callable[[str], str]:
22+
def _example(name: str) -> str:
2123
with open(
2224
os.path.join(os.path.dirname(__file__), "examples", "json", name + ".json"),
2325
encoding="utf-8",
@@ -28,8 +30,8 @@ def _example(name):
2830

2931

3032
@pytest.fixture
31-
def invalid_example():
32-
def _example(name):
33+
def invalid_example() -> Callable[[str], str]:
34+
def _example(name: str) -> str:
3335
with open(
3436
os.path.join(
3537
os.path.dirname(__file__), "examples", "invalid", name + ".toml"

0 commit comments

Comments
 (0)