@@ -144,6 +144,58 @@ reportOverlappingOverload = false
144144reportImportCycles = false
145145reportPrivateUsage = false
146146
147+ [tool .mypy ]
148+ pretty = true
149+ show_error_codes = true
150+
151+ # Exclude _files.py because mypy isn't smart enough to apply
152+ # the correct type narrowing and as this is an internal module
153+ # it's fine to just use Pyright.
154+ #
155+ # We also exclude our `tests` as mypy doesn't always infer
156+ # types correctly and Pyright will still catch any type errors.
157+ exclude = [' src/gradient/_files.py' , ' _dev/.*.py' , ' tests/.*' ]
158+
159+ strict_equality = true
160+ implicit_reexport = true
161+ check_untyped_defs = true
162+ no_implicit_optional = true
163+
164+ warn_return_any = true
165+ warn_unreachable = true
166+ warn_unused_configs = true
167+
168+ # Turn these options off as it could cause conflicts
169+ # with the Pyright options.
170+ warn_unused_ignores = false
171+ warn_redundant_casts = false
172+
173+ disallow_any_generics = true
174+ disallow_untyped_defs = true
175+ disallow_untyped_calls = true
176+ disallow_subclassing_any = true
177+ disallow_incomplete_defs = true
178+ disallow_untyped_decorators = true
179+ cache_fine_grained = true
180+
181+ # By default, mypy reports an error if you assign a value to the result
182+ # of a function call that doesn't return anything. We do this in our test
183+ # cases:
184+ # ```
185+ # result = ...
186+ # assert result is None
187+ # ```
188+ # Changing this codegen to make mypy happy would increase complexity
189+ # and would not be worth it.
190+ disable_error_code = " func-returns-value,overload-cannot-match"
191+
192+ # https://github.com/python/mypy/issues/12162
193+ [[tool .mypy .overrides ]]
194+ module = " black.files.*"
195+ ignore_errors = true
196+ ignore_missing_imports = true
197+
198+
147199[tool .ruff ]
148200line-length = 120
149201output-format = " grouped"
0 commit comments