We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f731daf + 2bd5d7e commit 65d4e66Copy full SHA for 65d4e66
subprojects/robotpy-wpiutil/wpiutil/wpistruct/typing.py
@@ -0,0 +1,23 @@
1
+from typing import ClassVar, Protocol
2
+
3
+try:
4
+ from typing import TypeGuard
5
+except ImportError:
6
+ try:
7
+ from typing_extensions import TypeGuard
8
+ except ImportError:
9
+ # Runtime fallback for Python 3.9 without typing_extensions
10
+ class TypeGuard:
11
+ def __class_getitem__(cls, key):
12
+ return bool
13
14
15
+class StructSerializable(Protocol):
16
+ """Any type that can be serialized or deserialized as a WPILib Struct."""
17
18
+ WPIStruct: ClassVar
19
20
21
+def is_wpistruct_type(cls: type) -> TypeGuard[type[StructSerializable]]:
22
+ """Returns True if the given type supports WPILib Struct serialization."""
23
+ return hasattr(cls, "WPIStruct")
0 commit comments