From 56fd651063fca02b6a4236fda17ad3510f5fab44 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Tue, 24 Dec 2019 14:34:13 +0200 Subject: [PATCH] Added @WillAyd typing suggestions --- pandas/io/formats/css.py | 14 +------------- pandas/io/formats/csvs.py | 13 ++++++------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/pandas/io/formats/css.py b/pandas/io/formats/css.py index 334daab3083c0..f74be62fe818e 100644 --- a/pandas/io/formats/css.py +++ b/pandas/io/formats/css.py @@ -15,25 +15,13 @@ class CSSWarning(UserWarning): def _side_expander(prop_fmt: str): - """ - Parameters - ---------- - prop_fmt : str - """ - def expand(self, prop, value: str): - """ - Parameters - ---------- - prop - value : str - """ tokens = value.split() try: mapping = self.SIDE_SHORTHANDS[len(tokens)] except KeyError: warnings.warn( - f"Could not expand {prop}: {value}", CSSWarning, + f'Could not expand "{prop}: {value}"', CSSWarning, ) return for key, idx in zip(self.SIDES, mapping): diff --git a/pandas/io/formats/csvs.py b/pandas/io/formats/csvs.py index 9c6fb46d04db0..153de2b60d093 100644 --- a/pandas/io/formats/csvs.py +++ b/pandas/io/formats/csvs.py @@ -5,13 +5,14 @@ import csv as csvlib from io import StringIO import os -from typing import List, Optional, Sequence, Union +from typing import Hashable, List, Optional, Sequence, Union import warnings from zipfile import ZipFile import numpy as np from pandas._libs import writers as libwriters +from pandas._typing import FilePathOrBuffer from pandas.core.dtypes.generic import ( ABCDatetimeIndex, @@ -21,8 +22,6 @@ ) from pandas.core.dtypes.missing import notna -from pandas._typing import FilePathOrBuffer - from pandas.io.common import ( get_compression_method, get_filepath_or_buffer, @@ -38,11 +37,11 @@ def __init__( path_or_buf: Optional[FilePathOrBuffer[str]] = None, sep: str = ",", na_rep: str = "", - float_format=None, + float_format: Optional[str] = None, cols=None, - header: Union[bool, Sequence[str]] = True, + header: Union[bool, Sequence[Hashable]] = True, index: bool = True, - index_label=None, + index_label: Optional[Union[bool, Hashable, Sequence[Hashable]]] = None, mode: str = "w", encoding: Optional[str] = None, compression="infer", @@ -52,7 +51,7 @@ def __init__( quotechar: Optional[str] = '"', date_format: Optional[str] = None, doublequote: bool = True, - escapechar=None, + escapechar: Optional[str] = None, decimal: Optional[str] = ".", ): self.obj = obj