@@ -117,14 +117,24 @@ def set_testing_mode():
117
117
# set the testing mode filters
118
118
testing_mode = os .environ .get ("PANDAS_TESTING_MODE" , "None" )
119
119
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
+ )
121
126
122
127
123
128
def reset_testing_mode ():
124
129
# reset the testing mode filters
125
130
testing_mode = os .environ .get ("PANDAS_TESTING_MODE" , "None" )
126
131
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
+ )
128
138
129
139
130
140
set_testing_mode ()
@@ -241,16 +251,22 @@ def decompress_file(path, compression):
241
251
if compression is None :
242
252
f = open (path , "rb" )
243
253
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]
245
257
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]
247
261
elif compression == "xz" :
248
262
f = get_lzma_file (lzma )(path , "rb" )
249
263
elif compression == "zip" :
250
264
zip_file = zipfile .ZipFile (path )
251
265
zip_names = zip_file .namelist ()
252
266
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]
254
270
else :
255
271
raise ValueError (f"ZIP file { path } error. Only one file per ZIP." )
256
272
else :
@@ -286,9 +302,15 @@ def write_to_compressed(compression, path, data, dest="test"):
286
302
if compression == "zip" :
287
303
compress_method = zipfile .ZipFile
288
304
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]
290
309
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]
292
314
elif compression == "xz" :
293
315
compress_method = get_lzma_file (lzma )
294
316
else :
@@ -300,7 +322,10 @@ def write_to_compressed(compression, path, data, dest="test"):
300
322
method = "writestr"
301
323
else :
302
324
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]
304
329
method = "write"
305
330
306
331
with compress_method (path , mode = mode ) as f :
@@ -1996,7 +2021,8 @@ def all_timeseries_index_generator(k=10):
1996
2021
"""
1997
2022
make_index_funcs = [makeDateIndex , makePeriodIndex , makeTimedeltaIndex ]
1998
2023
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]
2000
2026
2001
2027
2002
2028
# make series
@@ -2130,7 +2156,8 @@ def makeCustomIndex(
2130
2156
p = makePeriodIndex ,
2131
2157
).get (idx_type )
2132
2158
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]
2134
2161
# but we need to fill in the name
2135
2162
if names :
2136
2163
idx .name = names [0 ]
@@ -2158,7 +2185,8 @@ def keyfunc(x):
2158
2185
2159
2186
# build a list of lists to create the index from
2160
2187
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]
2162
2190
for j in range (div_factor ):
2163
2191
label = f"{ prefix } _l{ i } _g{ j } "
2164
2192
cnt [label ] = ndupe_l [i ]
@@ -2316,7 +2344,14 @@ def _gen_unique_rand(rng, _extra_size):
2316
2344
2317
2345
def makeMissingDataframe (density = 0.9 , random_state = None ):
2318
2346
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
+ )
2320
2355
df .values [i , j ] = np .nan
2321
2356
return df
2322
2357
@@ -2341,7 +2376,10 @@ def dec(f):
2341
2376
is_decorating = not kwargs and len (args ) == 1 and callable (args [0 ])
2342
2377
if is_decorating :
2343
2378
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]
2345
2383
return dec (f )
2346
2384
else :
2347
2385
return dec
@@ -2534,7 +2572,9 @@ def wrapper(*args, **kwargs):
2534
2572
except Exception as err :
2535
2573
errno = getattr (err , "errno" , None )
2536
2574
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]
2538
2578
2539
2579
if errno in skip_errnos :
2540
2580
skip (f"Skipping test due to known errno and error { err } " )
0 commit comments