Skip to content

Commit 5a22c7c

Browse files
committed
refactor: embed type hints, check with mypy
1 parent 3284901 commit 5a22c7c

File tree

10 files changed

+432
-490
lines changed

10 files changed

+432
-490
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ jobs:
8989
- name: ruff format
9090
run: ruff format --check
9191

92+
type:
93+
name: Type
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v6
97+
- name: Setup Python
98+
uses: actions/setup-python@v6
99+
with:
100+
python-version: 3.14
101+
- name: Install dependencies
102+
run: python -m pip install -r requirements-type.txt
103+
- name: Create _version.py
104+
run: echo '__version__ = ""' > src/pyzstd/_version.py
105+
- name: mypy
106+
run: mypy
107+
92108
publish:
93109
name: Publish to PyPI
94110
if: startsWith(github.ref, 'refs/tags')

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111
- Remove git submodule usage
1212
- Drop support for Python 3.9 and below
1313
- Use `ruff` as formatter and linter
14+
- Embed type hints in Python code, and check with `mypy`
1415

1516
## 0.18.0 (October 5, 2025)
1617

pyproject.toml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,60 @@ version-file = "src/pyzstd/_version.py"
6060
source = "vcs"
6161

6262

63+
#
64+
# mypy
65+
#
66+
67+
[tool.mypy]
68+
# Import discovery
69+
files = "src"
70+
ignore_missing_imports = false
71+
follow_imports = "normal"
72+
# Platform configuration
73+
python_version = "3.14"
74+
# Disallow dynamic typing
75+
disallow_any_unimported = true
76+
disallow_any_decorated = true
77+
disallow_any_generics = true
78+
disallow_subclassing_any = true
79+
# Untyped definitions and calls
80+
disallow_untyped_calls = true
81+
disallow_untyped_defs = true
82+
disallow_incomplete_defs = true
83+
check_untyped_defs = true
84+
disallow_untyped_decorators = true
85+
# None and Optional handling
86+
no_implicit_optional = true
87+
strict_optional = true
88+
# Configuring warning
89+
warn_redundant_casts = true
90+
warn_unused_ignores = true
91+
warn_no_return = true
92+
warn_return_any = true
93+
warn_unreachable = true
94+
# Suppressing errors
95+
ignore_errors = false
96+
# Miscellaneous strictness flags
97+
strict_equality = true
98+
# Configuring error messages
99+
show_error_context = true
100+
show_error_codes = true
101+
# Miscellaneous
102+
warn_unused_configs = true
103+
104+
63105
#
64106
# ruff
65107
#
66108

67109
[tool.ruff]
68110
src = ["src"]
69111
target-version = "py310"
70-
extend-exclude = [
71-
"tests",
72-
'*.pyi', # FIXME
73-
]
112+
extend-exclude = ["tests"]
74113

75114
[tool.ruff.lint]
76115
select = ["ALL"]
77116
ignore = [
78-
"ANN", # FIXME
79117
"C901",
80118
"COM812",
81119
"D",

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-e .
22

33
-r requirements-lint.txt
4+
-r requirements-type.txt

requirements-type.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mypy==1.19.0

0 commit comments

Comments
 (0)