@@ -267,8 +267,8 @@ def file_path_to_url(path: str) -> str:
267
267
268
268
269
269
def get_compression_method (
270
- compression : Optional [Union [str , Mapping [str , str ]]]
271
- ) -> Tuple [Optional [str ], Dict [str , str ]]:
270
+ compression : Optional [Union [str , Mapping [str , Any ]]]
271
+ ) -> Tuple [Optional [str ], Dict [str , Any ]]:
272
272
"""
273
273
Simplifies a compression argument to a compression method string and
274
274
a mapping containing additional arguments.
@@ -282,21 +282,23 @@ def get_compression_method(
282
282
Returns
283
283
-------
284
284
tuple of ({compression method}, Optional[str]
285
- {compression arguments}, Dict[str, str ])
285
+ {compression arguments}, Dict[str, Any ])
286
286
287
287
Raises
288
288
------
289
289
ValueError on mapping missing 'method' key
290
290
"""
291
+ compression_method : Optional [str ]
291
292
if isinstance (compression , Mapping ):
292
293
compression_args = dict (compression )
293
294
try :
294
- compression = compression_args .pop ("method" )
295
+ compression_method = compression_args .pop ("method" )
295
296
except KeyError as err :
296
297
raise ValueError ("If mapping, compression must have key 'method'" ) from err
297
298
else :
298
299
compression_args = {}
299
- return compression , compression_args
300
+ compression_method = compression
301
+ return compression_method , compression_args
300
302
301
303
302
304
def infer_compression (
@@ -434,28 +436,19 @@ def get_handle(
434
436
435
437
if compression :
436
438
437
- # GH33398 the type ignores here seem related to mypy issue #5382;
438
- # it may be possible to remove them once that is resolved.
439
-
440
439
# GZ Compression
441
440
if compression == "gzip" :
442
441
if is_path :
443
- f = gzip .open (
444
- path_or_buf , mode , ** compression_args # type: ignore
445
- )
442
+ f = gzip .open (path_or_buf , mode , ** compression_args )
446
443
else :
447
- f = gzip .GzipFile (
448
- fileobj = path_or_buf , ** compression_args # type: ignore
449
- )
444
+ f = gzip .GzipFile (fileobj = path_or_buf , ** compression_args )
450
445
451
446
# BZ Compression
452
447
elif compression == "bz2" :
453
448
if is_path :
454
- f = bz2 .BZ2File (
455
- path_or_buf , mode , ** compression_args # type: ignore
456
- )
449
+ f = bz2 .BZ2File (path_or_buf , mode , ** compression_args )
457
450
else :
458
- f = bz2 .BZ2File (path_or_buf , ** compression_args ) # type: ignore
451
+ f = bz2 .BZ2File (path_or_buf , ** compression_args )
459
452
460
453
# ZIP Compression
461
454
elif compression == "zip" :
0 commit comments