@@ -117,14 +117,24 @@ def set_testing_mode():
117117 # set the testing mode filters
118118 testing_mode = os .environ .get ("PANDAS_TESTING_MODE" , "None" )
119119 if "deprecate" in testing_mode :
120- warnings .simplefilter ("always" , _testing_mode_warnings )
120+ # pandas\_testing.py:119: error: Argument 2 to "simplefilter" has
121+ # incompatible type "Tuple[Type[DeprecationWarning],
122+ # Type[ResourceWarning]]"; expected "Type[Warning]"
123+ warnings .simplefilter (
124+ "always" , _testing_mode_warnings # type: ignore[arg-type]
125+ )
121126
122127
123128def reset_testing_mode ():
124129 # reset the testing mode filters
125130 testing_mode = os .environ .get ("PANDAS_TESTING_MODE" , "None" )
126131 if "deprecate" in testing_mode :
127- warnings .simplefilter ("ignore" , _testing_mode_warnings )
132+ # pandas\_testing.py:126: error: Argument 2 to "simplefilter" has
133+ # incompatible type "Tuple[Type[DeprecationWarning],
134+ # Type[ResourceWarning]]"; expected "Type[Warning]"
135+ warnings .simplefilter (
136+ "ignore" , _testing_mode_warnings # type: ignore[arg-type]
137+ )
128138
129139
130140set_testing_mode ()
@@ -241,16 +251,22 @@ def decompress_file(path, compression):
241251 if compression is None :
242252 f = open (path , "rb" )
243253 elif compression == "gzip" :
244- f = gzip .open (path , "rb" )
254+ # pandas\_testing.py:243: error: Incompatible types in assignment
255+ # (expression has type "IO[Any]", variable has type "BinaryIO")
256+ f = gzip .open (path , "rb" ) # type: ignore[assignment]
245257 elif compression == "bz2" :
246- f = bz2 .BZ2File (path , "rb" )
258+ # pandas\_testing.py:245: error: Incompatible types in assignment
259+ # (expression has type "BZ2File", variable has type "BinaryIO")
260+ f = bz2 .BZ2File (path , "rb" ) # type: ignore[assignment]
247261 elif compression == "xz" :
248262 f = get_lzma_file (lzma )(path , "rb" )
249263 elif compression == "zip" :
250264 zip_file = zipfile .ZipFile (path )
251265 zip_names = zip_file .namelist ()
252266 if len (zip_names ) == 1 :
253- f = zip_file .open (zip_names .pop ())
267+ # pandas\_testing.py:252: error: Incompatible types in assignment
268+ # (expression has type "IO[bytes]", variable has type "BinaryIO")
269+ f = zip_file .open (zip_names .pop ()) # type: ignore[assignment]
254270 else :
255271 raise ValueError (f"ZIP file { path } error. Only one file per ZIP." )
256272 else :
@@ -286,9 +302,15 @@ def write_to_compressed(compression, path, data, dest="test"):
286302 if compression == "zip" :
287303 compress_method = zipfile .ZipFile
288304 elif compression == "gzip" :
289- compress_method = gzip .GzipFile
305+ # pandas\_testing.py:288: error: Incompatible types in assignment
306+ # (expression has type "Type[GzipFile]", variable has type
307+ # "Type[ZipFile]")
308+ compress_method = gzip .GzipFile # type: ignore[assignment]
290309 elif compression == "bz2" :
291- compress_method = bz2 .BZ2File
310+ # pandas\_testing.py:290: error: Incompatible types in assignment
311+ # (expression has type "Type[BZ2File]", variable has type
312+ # "Type[ZipFile]")
313+ compress_method = bz2 .BZ2File # type: ignore[assignment]
292314 elif compression == "xz" :
293315 compress_method = get_lzma_file (lzma )
294316 else :
@@ -300,7 +322,10 @@ def write_to_compressed(compression, path, data, dest="test"):
300322 method = "writestr"
301323 else :
302324 mode = "wb"
303- args = (data ,)
325+ # pandas\_testing.py:302: error: Incompatible types in assignment
326+ # (expression has type "Tuple[Any]", variable has type "Tuple[Any,
327+ # Any]")
328+ args = (data ,) # type: ignore[assignment]
304329 method = "write"
305330
306331 with compress_method (path , mode = mode ) as f :
@@ -1996,7 +2021,8 @@ def all_timeseries_index_generator(k=10):
19962021 """
19972022 make_index_funcs = [makeDateIndex , makePeriodIndex , makeTimedeltaIndex ]
19982023 for make_index_func in make_index_funcs :
1999- yield make_index_func (k = k )
2024+ # pandas\_testing.py:1986: error: Cannot call function of unknown type
2025+ yield make_index_func (k = k ) # type: ignore[operator]
20002026
20012027
20022028# make series
@@ -2130,7 +2156,8 @@ def makeCustomIndex(
21302156 p = makePeriodIndex ,
21312157 ).get (idx_type )
21322158 if idx_func :
2133- idx = idx_func (nentries )
2159+ # pandas\_testing.py:2120: error: Cannot call function of unknown type
2160+ idx = idx_func (nentries ) # type: ignore[operator]
21342161 # but we need to fill in the name
21352162 if names :
21362163 idx .name = names [0 ]
@@ -2158,7 +2185,8 @@ def keyfunc(x):
21582185
21592186 # build a list of lists to create the index from
21602187 div_factor = nentries // ndupe_l [i ] + 1
2161- cnt = Counter ()
2188+ # pandas\_testing.py:2148: error: Need type annotation for 'cnt'
2189+ cnt = Counter () # type: ignore[var-annotated]
21622190 for j in range (div_factor ):
21632191 label = f"{ prefix } _l{ i } _g{ j } "
21642192 cnt [label ] = ndupe_l [i ]
@@ -2316,7 +2344,14 @@ def _gen_unique_rand(rng, _extra_size):
23162344
23172345def makeMissingDataframe (density = 0.9 , random_state = None ):
23182346 df = makeDataFrame ()
2319- i , j = _create_missing_idx (* df .shape , density = density , random_state = random_state )
2347+ # pandas\_testing.py:2306: error: "_create_missing_idx" gets multiple
2348+ # values for keyword argument "density" [misc]
2349+
2350+ # pandas\_testing.py:2306: error: "_create_missing_idx" gets multiple
2351+ # values for keyword argument "random_state" [misc]
2352+ i , j = _create_missing_idx ( # type: ignore[misc]
2353+ * df .shape , density = density , random_state = random_state
2354+ )
23202355 df .values [i , j ] = np .nan
23212356 return df
23222357
@@ -2341,7 +2376,10 @@ def dec(f):
23412376 is_decorating = not kwargs and len (args ) == 1 and callable (args [0 ])
23422377 if is_decorating :
23432378 f = args [0 ]
2344- args = []
2379+ # pandas\_testing.py:2331: error: Incompatible types in assignment
2380+ # (expression has type "List[<nothing>]", variable has type
2381+ # "Tuple[Any, ...]")
2382+ args = [] # type: ignore[assignment]
23452383 return dec (f )
23462384 else :
23472385 return dec
@@ -2534,7 +2572,9 @@ def wrapper(*args, **kwargs):
25342572 except Exception as err :
25352573 errno = getattr (err , "errno" , None )
25362574 if not errno and hasattr (errno , "reason" ):
2537- errno = getattr (err .reason , "errno" , None )
2575+ # pandas\_testing.py:2521: error: "Exception" has no attribute
2576+ # "reason"
2577+ errno = getattr (err .reason , "errno" , None ) # type: ignore[attr-defined]
25382578
25392579 if errno in skip_errnos :
25402580 skip (f"Skipping test due to known errno and error { err } " )
0 commit comments