@@ -16,19 +16,6 @@ dependencies = [
1616]
1717
1818[project .optional-dependencies ]
19- tests = [
20- " pytest>=6.2.1" ,
21- " pytest-cov>=2.10.1" ,
22- ]
23- docs = [
24- " sphinx>=7" ,
25- " sphinx-gallery>=0.8.2" ,
26- " sphinx-book-theme>=1.1.0" ,
27- " sphinx-issues>=1.2.0" ,
28- " numpydoc>=1.1.0" ,
29- " matplotlib>=3.3.3" ,
30- " scanpydoc" ,
31- ]
3219annoy = [
3320 " annoy>=1.17.0,<2.0.0" ,
3421]
@@ -49,6 +36,26 @@ annlibs = [
4936 " sklearn-ann[annoy,faiss,hannoy,pynndescent,nmslib]" ,
5037]
5138
39+ [dependency-groups ]
40+ docs = [
41+ " sphinx>=7" ,
42+ " sphinx-gallery>=0.8.2" ,
43+ " sphinx-book-theme>=1.1.0" ,
44+ " sphinx-issues>=1.2.0" ,
45+ " numpydoc>=1.1.0" ,
46+ " matplotlib>=3.3.3" ,
47+ " scanpydoc" ,
48+ ]
49+ tests = [
50+ " pytest>=6.2.1" ,
51+ " pytest-cov>=2.10.1" ,
52+ ]
53+ typing = [
54+ " mypy" ,
55+ " matplotlib" , # examples are type checked, too
56+ " scipy-stubs" ,
57+ ]
58+
5259[tool .hatch .version ]
5360source = " vcs"
5461
@@ -77,6 +84,7 @@ select = [
7784 " PTH" , # Pathlib
7885 " RUF" , # Ruff’s own rules
7986 " T20" , # print statements
87+ " TC" , # type checking
8088]
8189ignore = [
8290 # Don’t complain about “confusables”
@@ -87,19 +95,51 @@ ignore = [
8795"tests/*.py" = [" T20" ]
8896[tool .ruff .lint .isort ]
8997known-first-party = [" sklearn_ann" ]
98+ required-imports = [" from __future__ import annotations" ]
99+ [tool .ruff .lint .flake8-type-checking ]
100+ exempt-modules = []
101+ strict = true
90102
91103[tool .hatch .envs .docs ]
92104installer = " uv"
93- features = [" docs" , " annlibs" ]
105+ features = [" annlibs" ]
106+ dependency-groups = [" docs" ]
94107scripts.build = " sphinx-build -M html docs docs/_build"
95108
109+ [tool .hatch .envs .hatch-check-types ]
110+ features = [" annlibs" ]
111+ dependency-groups = [" tests" , " typing" ]
112+ scripts.check = " mypy {args:.}"
113+
96114[tool .hatch .envs .hatch-test ]
97115default-args = []
98- features = [" tests" , " annlibs" ]
116+ features = [" annlibs" ]
117+ dependency-groups = [" tests" ]
99118
100119[tool .hatch .build .targets .wheel ]
101120packages = [" src/sklearn_ann" ]
102121
122+ [tool .mypy ]
123+ python_version = " 3.12"
124+ mypy_path = [" src" , " tests" ]
125+ strict = true
126+ explicit_package_bases = true # pytest doesn’t do __init__.py
127+ no_implicit_optional = true
128+ disallow_untyped_decorators = false # e.g. pytest.mark.parametrize
129+ follow_untyped_imports = true
130+ # follow_untyped_imports makes these readable, but not annotated
131+ untyped_calls_exclude = [" sklearn" , " joblib" , " pynndescent" ]
132+
133+ [[tool .mypy .overrides ]]
134+ # pynndescent has no __all__, so its re-exports are implicit
135+ module = [" pynndescent" ]
136+ no_implicit_reexport = false
137+
138+ [[tool .mypy .overrides ]]
139+ # nmslib is a compiled extension module without stubs
140+ module = [" nmslib" ]
141+ ignore_missing_imports = true
142+
103143[tool .uv .sources ]
104144hannoy.git = " https://github.com/nnethercott/hannoy.git" # TODO: remove once 0.1.4/0.2 is released
105145
0 commit comments