@@ -53,11 +53,15 @@ def parse_test_cases(
5353 while i < len (p ) and p [i ].id != 'case' :
5454 if p [i ].id == 'file' :
5555 # Record an extra file needed for the test case.
56- files .append ((os .path .join (base_path , p [i ].arg ),
56+ arg = p [i ].arg
57+ assert arg is not None
58+ files .append ((os .path .join (base_path , arg ),
5759 '\n ' .join (p [i ].data )))
5860 elif p [i ].id in ('builtins' , 'builtins_py2' ):
5961 # Use a custom source file for the std module.
60- mpath = os .path .join (os .path .dirname (path ), p [i ].arg )
62+ arg = p [i ].arg
63+ assert arg is not None
64+ mpath = os .path .join (os .path .dirname (path ), arg )
6165 if p [i ].id == 'builtins' :
6266 fnam = 'builtins.pyi'
6367 else :
@@ -66,15 +70,17 @@ def parse_test_cases(
6670 with open (mpath ) as f :
6771 files .append ((os .path .join (base_path , fnam ), f .read ()))
6872 elif p [i ].id == 'stale' :
69- if p [i ].arg is None :
73+ arg = p [i ].arg
74+ if arg is None :
7075 stale_modules = set ()
7176 else :
72- stale_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
77+ stale_modules = {item .strip () for item in arg .split (',' )}
7378 elif p [i ].id == 'rechecked' :
74- if p [i ].arg is None :
79+ arg = p [i ].arg
80+ if arg is None :
7581 rechecked_modules = set ()
7682 else :
77- rechecked_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
83+ rechecked_modules = {item .strip () for item in arg .split (',' )}
7884 elif p [i ].id == 'out' or p [i ].id == 'out1' :
7985 tcout = p [i ].data
8086 if native_sep and os .path .sep == '\\ ' :
@@ -95,7 +101,9 @@ def parse_test_cases(
95101 # If the set of rechecked modules isn't specified, make it the same as the set of
96102 # modules with a stale public interface.
97103 rechecked_modules = stale_modules
98- if stale_modules is not None and not stale_modules .issubset (rechecked_modules ):
104+ if (stale_modules is not None
105+ and rechecked_modules is not None
106+ and not stale_modules .issubset (rechecked_modules )):
99107 raise ValueError (
100108 'Stale modules must be a subset of rechecked modules ({})' .format (path ))
101109
@@ -225,15 +233,15 @@ class TestItem:
225233 """
226234
227235 id = ''
228- arg = ''
236+ arg = '' # type: Optional[str]
229237
230238 # Text data, array of 8-bit strings
231239 data = None # type: List[str]
232240
233241 file = ''
234242 line = 0 # Line number in file
235243
236- def __init__ (self , id : str , arg : str , data : List [str ], file : str ,
244+ def __init__ (self , id : str , arg : Optional [ str ] , data : List [str ], file : str ,
237245 line : int ) -> None :
238246 self .id = id
239247 self .arg = arg
@@ -248,8 +256,8 @@ def parse_test_data(l: List[str], fnam: str) -> List[TestItem]:
248256 ret = [] # type: List[TestItem]
249257 data = [] # type: List[str]
250258
251- id = None # type: str
252- arg = None # type: str
259+ id = None # type: Optional[ str]
260+ arg = None # type: Optional[ str]
253261
254262 i = 0
255263 i0 = 0
0 commit comments