Skip to content

Commit c21e5a1

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

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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")

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ rdflib
44
requests
55
schema-salad >= 8.8.20250205075315,<9
66
ruamel.yaml >= 0.17.6, < 0.19
7+
typing_extensions >= 4.10.0

0 commit comments

Comments
 (0)