Skip to content

Commit 8194187

Browse files
Using TypeIs instead of TypeGuard
1 parent 864a1b4 commit 8194187

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

cwl_utils/types.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from collections.abc import Mapping, MutableMapping, MutableSequence
66
from typing import Any, Literal, TypeAlias, TypeGuard, TypedDict
77

8+
if sys.version_info >= (3, 13):
9+
from typing import TypeIs
10+
else:
11+
from typing_extensions import TypeIs
12+
813
if sys.version_info >= (3, 11):
914
from typing import Required
1015
else:
@@ -103,7 +108,7 @@ def is_cwl_parameter_context_key(
103108
return key in ("inputs", "self", "runtime")
104109

105110

106-
def is_directory(value: Any) -> TypeGuard[CWLDirectoryType]:
111+
def is_directory(value: Any) -> TypeIs[CWLDirectoryType]:
107112
return isinstance(value, Mapping) and value.get("class") == "Directory"
108113

109114

@@ -113,7 +118,7 @@ def is_directory_key(
113118
return key in ("class", "location", "path", "basename", "listing")
114119

115120

116-
def is_file(value: Any) -> TypeGuard[CWLFileType]:
121+
def is_file(value: Any) -> TypeIs[CWLFileType]:
117122
return isinstance(value, Mapping) and value.get("class") == "File"
118123

119124

@@ -153,5 +158,5 @@ def is_file_key(
153158

154159
def is_file_or_directory(
155160
value: Any,
156-
) -> TypeGuard[CWLFileType | CWLDirectoryType]:
161+
) -> TypeIs[CWLFileType | CWLDirectoryType]:
157162
return isinstance(value, Mapping) and value.get("class") in ("File", "Directory")

0 commit comments

Comments
 (0)