6
6
7
7
import os
8
8
import shutil
9
+ import sys
9
10
import tarfile
10
- from typing import Any , Dict , Generator , Tuple , Union
11
+ from typing import TYPE_CHECKING , Any , Dict , Generator , Tuple , Union , cast
11
12
12
13
import pytest
13
14
import requests
20
21
21
22
from .util import get_data
22
23
24
+ if TYPE_CHECKING :
25
+ from http .client import HTTPResponse
26
+
27
+
23
28
test_dir_name = "tests/"
24
29
25
30
SchemaType = Tuple [Loader , Union [Names , SchemaParseException ], Dict [str , Any ], Loader ]
@@ -30,12 +35,18 @@ def cwl_v1_2_schema(
30
35
tmp_path_factory : TempPathFactory ,
31
36
) -> Generator [SchemaType , None , None ]:
32
37
tmp_path = tmp_path_factory .mktemp ("cwl_v1_2_schema" )
33
- with requests .get (
34
- "https://github.com/common-workflow-language/cwl-v1.2/archive/v1.2.0.tar.gz" ,
35
- stream = True ,
36
- ).raw as specfileobj :
38
+ with cast (
39
+ "HTTPResponse" ,
40
+ requests .get (
41
+ "https://github.com/common-workflow-language/cwl-v1.2/archive/v1.2.0.tar.gz" ,
42
+ stream = True ,
43
+ ).raw ,
44
+ ) as specfileobj :
37
45
tf = tarfile .open (fileobj = specfileobj )
38
- tf .extractall (path = tmp_path ) # this becomes cwl-v1.2-1.2.0
46
+ if sys .version_info > (3 , 12 ):
47
+ tf .extractall (path = tmp_path , filter = "data" ) # this becomes cwl-v1.2-1.2.0
48
+ else :
49
+ tf .extractall (path = tmp_path ) # this becomes cwl-v1.2-1.2.0
39
50
path = str (tmp_path / "cwl-v1.2-1.2.0/CommonWorkflowLanguage.yml" )
40
51
yield load_schema (path )
41
52
shutil .rmtree (os .path .join (tmp_path ))
0 commit comments