@@ -179,6 +179,67 @@ reportOverlappingOverload = false
179
179
reportImportCycles = false
180
180
reportPrivateUsage = false
181
181
182
+ [tool .mypy ]
183
+ pretty = true
184
+ show_error_codes = true
185
+
186
+ # Exclude _files.py because mypy isn't smart enough to apply
187
+ # the correct type narrowing and as this is an internal module
188
+ # it's fine to just use Pyright.
189
+ #
190
+ # We also exclude our `tests` as mypy doesn't always infer
191
+ # types correctly and Pyright will still catch any type errors.
192
+ #
193
+ # realtime examples use inline `uv` script dependencies
194
+ # which means it can't be type checked
195
+ exclude = [
196
+ ' src/openai/_files.py' ,
197
+ ' _dev/.*.py' ,
198
+ ' tests/.*' ,
199
+ ' src/openai/_utils/_logs.py' ,
200
+ ' examples/realtime/audio_util.py' ,
201
+ ' examples/realtime/push_to_talk_app.py' ,
202
+ ]
203
+
204
+ strict_equality = true
205
+ implicit_reexport = true
206
+ check_untyped_defs = true
207
+ no_implicit_optional = true
208
+
209
+ warn_return_any = true
210
+ warn_unreachable = true
211
+ warn_unused_configs = true
212
+
213
+ # Turn these options off as it could cause conflicts
214
+ # with the Pyright options.
215
+ warn_unused_ignores = false
216
+ warn_redundant_casts = false
217
+
218
+ disallow_any_generics = true
219
+ disallow_untyped_defs = true
220
+ disallow_untyped_calls = true
221
+ disallow_subclassing_any = true
222
+ disallow_incomplete_defs = true
223
+ disallow_untyped_decorators = true
224
+ cache_fine_grained = true
225
+
226
+ # By default, mypy reports an error if you assign a value to the result
227
+ # of a function call that doesn't return anything. We do this in our test
228
+ # cases:
229
+ # ```
230
+ # result = ...
231
+ # assert result is None
232
+ # ```
233
+ # Changing this codegen to make mypy happy would increase complexity
234
+ # and would not be worth it.
235
+ disable_error_code = " func-returns-value,overload-cannot-match"
236
+
237
+ # https://github.com/python/mypy/issues/12162
238
+ [[tool .mypy .overrides ]]
239
+ module = " black.files.*"
240
+ ignore_errors = true
241
+ ignore_missing_imports = true
242
+
182
243
[tool .ruff ]
183
244
line-length = 120
184
245
output-format = " grouped"
0 commit comments