Skip to content

Commit c51c212

Browse files
committed
fix(typing): Guard typing_extensions import in test fixtures
Ensures the typing_extensions import in test fixture _types.py is properly guarded to avoid runtime ImportError when typing_extensions is not available.
1 parent c602869 commit c51c212

File tree

1 file changed

+12
-1
lines changed
  • tests/fixtures/pluginsystem/partials

1 file changed

+12
-1
lines changed

tests/fixtures/pluginsystem/partials/_types.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@
1212

1313
from __future__ import annotations
1414

15-
from typing_extensions import NotRequired, TypedDict
15+
import typing as t
16+
17+
if t.TYPE_CHECKING:
18+
from typing_extensions import NotRequired, TypedDict
19+
else:
20+
# Fallback for runtime, though this module should not be imported at runtime
21+
try:
22+
from typing_extensions import NotRequired, TypedDict
23+
except ImportError:
24+
# Create dummy classes for runtime
25+
NotRequired = t.Any # type: ignore[misc, assignment]
26+
TypedDict = type # type: ignore[assignment, misc]
1627

1728

1829
class PluginTestConfigSchema(TypedDict):

0 commit comments

Comments
 (0)