55from collections .abc import Mapping , MutableMapping , MutableSequence
66from 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+
813if sys .version_info >= (3 , 11 ):
914 from typing import Required
1015else :
@@ -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
154159def 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