|
16 | 16 | from pathlib import Path |
17 | 17 | import struct |
18 | 18 | import sys |
19 | | -from typing import ( |
20 | | - Any, |
21 | | - AnyStr, |
22 | | - BinaryIO, |
23 | | - Dict, |
24 | | - List, |
25 | | - Mapping, |
26 | | - Optional, |
27 | | - Sequence, |
28 | | - Tuple, |
29 | | - Union, |
30 | | -) |
| 19 | +from typing import Any, AnyStr, BinaryIO, Dict, List, Optional, Sequence, Tuple, Union |
31 | 20 | import warnings |
32 | 21 |
|
33 | 22 | from dateutil.relativedelta import relativedelta |
|
58 | 47 | from pandas.core.indexes.base import Index |
59 | 48 | from pandas.core.series import Series |
60 | 49 |
|
61 | | -from pandas.io.common import ( |
62 | | - get_compression_method, |
63 | | - get_filepath_or_buffer, |
64 | | - get_handle, |
65 | | - infer_compression, |
66 | | - stringify_path, |
67 | | -) |
| 50 | +from pandas.io.common import get_filepath_or_buffer, get_handle, stringify_path |
68 | 51 |
|
69 | 52 | _version_error = ( |
70 | 53 | "Version of given Stata file is {version}. pandas supports importing " |
@@ -1976,9 +1959,6 @@ def _open_file_binary_write( |
1976 | 1959 | return fname, False, None # type: ignore[return-value] |
1977 | 1960 | elif isinstance(fname, (str, Path)): |
1978 | 1961 | # Extract compression mode as given, if dict |
1979 | | - compression_typ, compression_args = get_compression_method(compression) |
1980 | | - compression_typ = infer_compression(fname, compression_typ) |
1981 | | - compression = dict(compression_args, method=compression_typ) |
1982 | 1962 | ioargs = get_filepath_or_buffer( |
1983 | 1963 | fname, mode="wb", compression=compression, storage_options=storage_options |
1984 | 1964 | ) |
@@ -2235,7 +2215,7 @@ def __init__( |
2235 | 2215 | time_stamp: Optional[datetime.datetime] = None, |
2236 | 2216 | data_label: Optional[str] = None, |
2237 | 2217 | variable_labels: Optional[Dict[Label, str]] = None, |
2238 | | - compression: Union[str, Mapping[str, str], None] = "infer", |
| 2218 | + compression: CompressionOptions = "infer", |
2239 | 2219 | storage_options: StorageOptions = None, |
2240 | 2220 | ): |
2241 | 2221 | super().__init__() |
@@ -3118,7 +3098,7 @@ def __init__( |
3118 | 3098 | data_label: Optional[str] = None, |
3119 | 3099 | variable_labels: Optional[Dict[Label, str]] = None, |
3120 | 3100 | convert_strl: Optional[Sequence[Label]] = None, |
3121 | | - compression: Union[str, Mapping[str, str], None] = "infer", |
| 3101 | + compression: CompressionOptions = "infer", |
3122 | 3102 | storage_options: StorageOptions = None, |
3123 | 3103 | ): |
3124 | 3104 | # Copy to new list since convert_strl might be modified later |
@@ -3523,7 +3503,7 @@ def __init__( |
3523 | 3503 | variable_labels: Optional[Dict[Label, str]] = None, |
3524 | 3504 | convert_strl: Optional[Sequence[Label]] = None, |
3525 | 3505 | version: Optional[int] = None, |
3526 | | - compression: Union[str, Mapping[str, str], None] = "infer", |
| 3506 | + compression: CompressionOptions = "infer", |
3527 | 3507 | storage_options: StorageOptions = None, |
3528 | 3508 | ): |
3529 | 3509 | if version is None: |
|
0 commit comments