fix: remove type: ignore comments that fail on older Python mypy

Use getattr/object.__setattr__ pattern to avoid version-dependent
type: ignore comments that cause unused-ignore errors on Python 3.10/3.11.

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2026-04-15 19:19:27 +00:00
parent 1305bfc7ea
commit 84a72c4350

View File

@@ -677,11 +677,11 @@ _resolving_refs_local = threading.local()
def _get_resolving_refs() -> set[str]:
"""Return the per-thread resolving-refs set, creating it on first access."""
try:
return _resolving_refs_local.refs # type: ignore[no-any-return]
except AttributeError:
_resolving_refs_local.refs = set() # type: ignore[attr-defined]
return _resolving_refs_local.refs # type: ignore[no-any-return]
refs: set[str] | None = getattr(_resolving_refs_local, "refs", None)
if refs is None:
refs = set()
object.__setattr__(_resolving_refs_local, "refs", refs)
return refs
def _safe_replace_refs(json_schema: dict[str, Any]) -> dict[str, Any]: