8000 fix import order, None type annotations · pandas-dev/pandas@0a3a9fd · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a3a9fd

Browse files
committed
fix import order, None type annotations
1 parent 8ba9082 commit 0a3a9fd

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

pandas/core/generic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import operator
88
import pickle
99
from textwrap import dedent
10+
from typing import Dict, Union
1011
import warnings
1112
import weakref
1213

@@ -2918,7 +2919,8 @@ def to_latex(self, buf=None, columns=None, col_space=None, header=True,
29182919

29192920
def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
29202921
columns=None, header=True, index=True, index_label=None,
2921-
mode='w', encoding=None, compression='infer', quoting=None,
2922+
mode='w', encoding=None,
2923+
compression: Union[str, Dict, None] = 'infer', quoting=None,
29222924
quotechar='"', line_terminator=None, chunksize=None,
29232925
tupleize_cols=None, date_format=None, doublequote=True,
29242926
escapechar=None, decimal='.'):

pandas/io/common.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import lzma
1010
import mmap
1111
import os
12+
from typing import Dict, Union
1213
from urllib.error import URLError # noqa
1314
from urllib.parse import ( # noqa
1415
urlencode, urljoin, urlparse as parse_url, uses_netloc, uses_params,
1516
uses_relative)
1617
from urllib.request import pathname2url, urlopen
1718
import zipfile
18-
from typing import Dict
1919

2020
import pandas.compat as compat
2121
from pandas.errors import ( # noqa
@@ -234,7 +234,7 @@ def file_path_to_url(path):
234234
}
235235

236236

237-
def _get_compression_method(compression: (str, Dict)):
237+
def _get_compression_method(compression: Union[str, Dict, None]):
238238
"""
239239
Simplifies a compression argument to a compression method string and
240240
a dict containing additional arguments.
@@ -247,14 +247,14 @@ def _get_compression_method(compression: (str, Dict)):
247247
248248
Returns
249249
-------
250-
tuple of ({compression method}, str
250+
tuple of ({compression method}, any
251251
{compression arguments}, dict)
252252
253253
Raises
254254
------
255255
ValueError on dict missing 'method' key
256256
"""
257-
compression_args = {}
257+
compression_args = {} # type: Dict
258258
# Handle dict
259259
if isinstance(compression, dict):
260260
compression_args = compression.copy()
@@ -331,8 +331,9 @@ def _infer_compression(filepath_or_buffer, compression):
331331
raise ValueError(msg)
332332

333333

334-
def _get_handle(path_or_buf, mode, encoding=None, compression=None,
335-
memory_map=False, is_text=True):
334+
def _get_handle(path_or_buf, mode, encoding=None,
335+
compression: Union[str, Dict, None] = None, memory_map=False,
336+
is_text=True):
336337
"""
337338
Get file handle for given path/buffer and mode.
338339
@@ -480,7 +481,7 @@ class BytesZipFile(zipfile.ZipFile, BytesIO): # type: ignore
480481
"""
481482
# GH 17778
482483
def __init__(self, file, mode, compression=zipfile.ZIP_DEFLATED,
483-
arcname: (str, zipfile.ZipInfo) = None, **kwargs):
484+
arcname: Union[str, zipfile.ZipInfo, None] = None, **kwargs):
484485
if mode in ['wb', 'rb']:
485486
mode = mode.replace('b', '')
486487
self.arcname = arcname

pandas/io/formats/csvs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import csv as csvlib
77
from io import StringIO
88
import os
9+
from typing import Dict, Union
910
import warnings
1011
from zipfile import ZipFile
11-
from typing import Dict
1212

1313
import numpy as np
1414

@@ -19,16 +19,16 @@
1919
from pandas.core.dtypes.missing import notna
2020

2121
from pandas.io.common import (
22-
UnicodeWriter, _get_handle, _infer_compression, get_filepath_or_buffer,
23-
_get_compression_method)
22+
UnicodeWriter, _get_compression_method, _get_handle, _infer_compression,
23+
get_filepath_or_buffer)
2424

2525

2626
class CSVFormatter(object):
2727

2828
def __init__(self, obj, path_or_buf=None, sep=",", na_rep='',
2929
float_format=None, cols=None, header=True, index=True,
3030
index_label=None, mode='w', nanRep=None, encoding=None,
31-
compression: (str, Dict) = 'infer', quoting=None,
31+
compression: Union[str, Dict, None] = 'infer', quoting=None,
3232
line_terminator='\n', chunksize=None, tupleize_cols=False,
3333
quotechar='"', date_format=None, doublequote=True,
3434
escapechar=None, decimal='.'):

0 commit comments

Comments
 (0)
0