@@ -11,24 +11,24 @@ hygiene = ["ruff ==0.11.*"]
1111tests = [
1212 # Tools used for testing
1313 " docopt-ng" ,
14- " mypy ==1.13 .*" ,
14+ " mypy ==1.16 .*" ,
1515 " pyright" ,
1616
17- # Typed libraries and stubs
17+ # External type stubs and optional dependencies
1818 " matplotlib >=3.8" ,
1919 " pandas-stubs" ,
20+ " PyOpenGL" ,
2021 " pytest" ,
2122 " scipy-stubs" ,
22- " typing_extensions" ,
23-
24- # Untyped libraries, used to prevent "reportMissingImports" and get inferred typing
25- " joblib" ,
2623 " types-networkx" ,
27- " PyOpenGL" ,
24+ " typing_extensions" ,
25+
26+ # The libraries we're stubbing.
27+ # Needed for stubtest and downloads their dependencies to get known import symbols
28+ " scikit-image" ,
2829 " scikit-learn" ,
2930 " sympy" ,
30- " traitlets" ,
31- " transformers" ,
31+ " vispy" ,
3232]
3333dev = [{ include-group = " hygiene" }, { include-group = " tests" }]
3434
@@ -44,7 +44,6 @@ dev = [{ include-group = "hygiene" }, { include-group = "tests" }]
4444"skimage-stubs" = " stubs/skimage"
4545"sklearn-stubs" = " stubs/sklearn"
4646"sympy-stubs" = " stubs/sympy-stubs"
47- "transformers-stubs" = " stubs/transformers-stubs"
4847"vispy-stubs" = " stubs/vispy"
4948
5049[tool .ruff ]
@@ -56,10 +55,13 @@ target-version = "py39"
5655extend-select = [
5756 " FA" , # flake8-future-annotations
5857 " I" , # isort
58+ " PGH" , # pygrep-hooks
59+ " PGH" , # pygrep-hooks and blanket-noqa
60+ " PIE790" , # unnecessary-placeholder
5961 " PYI" , # flake8-pyi
62+ " RUF" , # Ruff-specific and unused-noqa
6063 " UP" , # pyupgrade
6164 " W" , # pycodestyle Warning
62- " PIE790" , # unnecessary-placeholder
6365]
6466ignore = [
6567 # ##
@@ -76,16 +78,17 @@ ignore = [
7678 " PYI014" ,
7779 " PYI053" ,
7880
79- # TODO: Fixing these would change which symbols are even visible for Pylance.
80- # Which may negatively affect users, especially if the symbol wasn't meant to be re-exported.
81- # Manually evaluate each violation.
82- " F401" ,
83-
8481 # TODO: Investigate and fix or configure
8582 " PYI051" , # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
8683]
84+
8785[tool .ruff .lint .per-file-ignores ]
8886"*.pyi" = [
87+ # Ruff 0.8.0 added sorting of __all__ and __slots_.
88+ # There is no consensus in typeshed on whether they want to apply this to stubs, so keeping the status quo.
89+ # See https://github.com/python/typeshed/pull/13108
90+ " RUF022" , # `__all__` is not sorted
91+ " RUF023" , # `{}.__slots__` is not sorted
8992 # ##
9093 # Rules that are out of the control of stub authors:
9194 # ##
@@ -99,6 +102,13 @@ ignore = [
99102# We keep docstrings in sklearn
100103"stubs/sklearn/**" = [" PYI021" ]
101104
105+ # TODO: For public modules, manually evaluate each violation.
106+ # Removing unused imports change which symbols are even visible for Pylance.
107+ # Which may negatively affect users, especially if the symbol wasn't meant to be re-exported.
108+ # We do assume no public re-exports were meant from private modules
109+ "!_*.pyi" = [" F401" ]
110+ "__init__.pyi" = [" F401" ]
111+
102112[tool .ruff .lint .isort ]
103113combine-as-imports = true
104114extra-standard-library = [
@@ -108,7 +118,7 @@ extra-standard-library = [
108118]
109119
110120[tool .pyright ]
111- exclude = [" build" , " .git" ]
121+ exclude = [" build" , " .git" , " .venv* " ]
112122stubPath = " ./stubs"
113123pythonversion = " 3.9" # Target oldest supported Python version
114124typeCheckingMode = " standard"
@@ -134,24 +144,46 @@ reportSelfClsParameterName = false
134144reportUnsupportedDunderAll = " error"
135145
136146[tool .mypy ]
137- python_version = " 3.9" # Target oldest supported Python version
138147strict = true
139148check_untyped_defs = true # Strict check on all defs
140149show_column_numbers = true
150+ # Not all imports in these stubs are gonna be typed
151+ # Don't infer symbols from untyped packages as Any
152+ follow_untyped_imports = true
141153warn_unused_ignores = false # Change from pandas
142154# Partial stubs are acceptable
143155disallow_any_generics = false
144156disallow_incomplete_defs = false
145157disallow_untyped_defs = false
146158# Suppressing errors
147159disable_error_code = [
148- # Not all imports in these stubs are gonna be typed
149- " import-untyped" ,
160+ # mypy's overload implementation differs from pyright
161+ # `assert-type` issues is tests mostly comme from checking overloads
162+ # Since this project is specific to Pylance, just ignore them
163+ " assert-type" ,
164+ # Incompatible overrides are out of our stubs' control
165+ # as they are inherited from the implementation.
166+ " override" ,
150167 # TODO
151- " valid-type" , # 967 errors in 115 files
152- " override" , # 790 errors in 220 files
153- " assignment" , # 773 errors in 172 files
154- " misc" , # 692 errors in 132 files
155- " attr-defined" , # 202 errors in 75 files
156- " assert-type" , # 6 errors in 1 file
168+ " assignment" , # 744 errors in 155 files
169+ ]
170+
171+ [[tool .mypy .overrides ]]
172+ # follow_untyped_imports = true will cause stubtest to run mypy on the source
173+ # So disable it for partial stubs
174+ module = [" sympy.*" ]
175+ follow_untyped_imports = false
176+ disable_error_code = [" import-untyped" , " misc" ]
177+
178+ [[tool .mypy .overrides ]]
179+ # These modules are to be removed soon, not worth solving many issues
180+ module = [" matplotlib.*" , " networkx.*" ]
181+ disable_error_code = [
182+ " assignment" ,
183+ " misc" ,
157184]
185+ [[tool .mypy .overrides ]]
186+ module = [" skimage.*" , " sklearn.*" ]
187+ # TODO: Too many untyped decorators still left
188+ # https://github.com/python/mypy/issues/19148
189+ disable_error_code = [" misc" ]
0 commit comments