Skip to content

Commit 408d9c9

Browse files
committed
Fix mypy strict unused-ignore across Python versions
annotationlib was added to stdlib in 3.14; the type: ignore[assignment] is needed on 3.14 (where mypy knows the module type) but flagged as unused on 3.12/3.13 (where mypy treats it as Any). Add a per-module mypy override to suppress warn_unused_ignores for document_base and restore the original try/except pattern.
1 parent 6b0aa4e commit 408d9c9

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

elasticsearch/dsl/document_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
try:
4040
import annotationlib
4141
except ImportError:
42-
annotationlib = None
42+
annotationlib = None # type: ignore[assignment]
4343

4444
try:
4545
from types import UnionType

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,7 @@ exclude_lines = [
143143
[tool.mypy]
144144
plugins = ["pydantic.mypy"]
145145
ignore_missing_imports = true
146+
147+
[[tool.mypy.overrides]]
148+
module = "elasticsearch.dsl.document_base"
149+
warn_unused_ignores = false

0 commit comments

Comments
 (0)