Skip to content

Commit 3ff165c

Browse files
authored
👷 validate slots and defaults using stubdefaulter (#911)
2 parents 91e060b + 403fc0d commit 3ff165c

File tree

3 files changed

+203
-7
lines changed

3 files changed

+203
-7
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ jobs:
5252
# see https://github.com/microsoft/pyright/issues/10832
5353
version: 1.1.403
5454

55+
stubdefaulter:
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 5
58+
steps:
59+
- uses: actions/[email protected]
60+
61+
- name: setup uv
62+
uses: astral-sh/[email protected]
63+
with:
64+
python-version: "3.13"
65+
66+
# avoid stubdefaulter checking the tests as if they were stubs
67+
- name: exclude tests
68+
run: rm -rf tests
69+
70+
- name: stubdefaulter check
71+
run: uv run stubdefaulter --check --exit-zero --packages .
72+
5573
# NOTE: mypy ignores `uv run --with=...` (and `--isolated` does not help), so we
5674
# manually (re)install the desired version directly in the environment.
5775

@@ -90,7 +108,6 @@ jobs:
90108
run: stubtest --ignore-disjoint-bases --allowlist=.mypyignore scipy
91109

92110
typetest:
93-
# needs: generate-matrix
94111
runs-on: ubuntu-latest
95112
timeout-minutes: 5
96113

‎pyproject.toml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ type = [
6363
"basedpyright==1.31.6",
6464
"mypy[faster-cache]==1.18.2",
6565
"pyrefly==0.35.0",
66+
"stubdefaulter>=0.1.0",
6667
]
6768
dev = [
6869
{ include-group = "lint" },
6970
{ include-group = "type" },
7071
]
7172

73+
# the required stubdefaulter features not released yet (>0.1.0)
74+
[tool.uv.sources.stubdefaulter]
75+
git = "https://github.com/JelleZijlstra/stubdefaulter.git"
76+
rev = "ebe9e31"
77+
7278
[tool.poe.tasks.clean]
7379
cmd = """
7480
rm -rf
@@ -91,6 +97,10 @@ uv run
9197
scipy
9298
"""
9399

100+
[tool.poe.tasks.stubdefaulter]
101+
cmd = "stubdefaulter --packages=. --exit-zero --check"
102+
executor.type = "uv"
103+
94104
[tool.typos.files]
95105
extend-exclude = ["*.pyi", ".mypyignore"]
96106

@@ -232,12 +242,8 @@ runner = "uv-venv-lock-runner"
232242
dependency_groups = ["type"]
233243
uv_sync_flags = ["--no-editable", "--reinstall-package=scipy-stubs"]
234244
commands = [
235-
[
236-
"stubtest",
237-
"--ignore-disjoint-bases",
238-
"--allowlist=.mypyignore",
239-
{ replace = "posargs", default = ["scipy"], extend = true },
240-
],
245+
["stubtest", "--ignore-disjoint-bases", "--allowlist=.mypyignore", "scipy"],
246+
["stubdefaulter", "--packages=.", "--exit-zero", "--check"],
241247
]
242248

243249
[tool.tox.env.lint]

0 commit comments

Comments
 (0)