Skip to content

Commit c5347b6

Browse files
chore(internal): move mypy configurations to pyproject.toml file
1 parent 7967d15 commit c5347b6

File tree

2 files changed

+55
-53
lines changed

2 files changed

+55
-53
lines changed

mypy.ini

Lines changed: 0 additions & 53 deletions
This file was deleted.

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,61 @@ reportOverlappingOverload = false
147147
reportImportCycles = false
148148
reportPrivateUsage = false
149149

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

0 commit comments

Comments
 (0)