Skip to content

Commit

Permalink
more typing
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Jul 7, 2020
1 parent 5ea0038 commit ba17b28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,12 @@ def _mpl_repr(self):
# how to represent ourselves to matplotlib
return self.values

def format(self, name: bool = False, formatter=None, na_rep="NaN") -> List[str_t]:
def format(
self,
name: bool = False,
formatter: Optional[Callable] = None,
na_rep: str_t = "NaN",
) -> List[str_t]:
"""
Render a string representation of the Index.
"""
Expand Down
10 changes: 7 additions & 3 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandas._libs import NaT, Timedelta, iNaT, join as libjoin, lib
from pandas._libs.tslibs import BaseOffset, Resolution, Tick, timezones
from pandas._libs.tslibs.parsing import DateParseError
from pandas._typing import Label
from pandas._typing import Callable, Label
from pandas.compat.numpy import function as nv
from pandas.errors import AbstractMethodError
from pandas.util._decorators import Appender, cache_readonly, doc
Expand Down Expand Up @@ -339,7 +339,11 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs):
# Rendering Methods

def format(
self, name: bool = False, formatter=None, na_rep="NaT", date_format=None
self,
name: bool = False,
formatter: Optional[Callable] = None,
na_rep: str = "NaT",
date_format: Optional[str] = None,
) -> List[str]:
"""
Render a string representation of the Index.
Expand All @@ -352,7 +356,7 @@ def format(
if formatter is not None:
return header + list(self.map(formatter))

return self._format_with_header(header, date_format=date_format, na_rep=na_rep)
return self._format_with_header(header, na_rep=na_rep, date_format=date_format)

def _format_with_header(self, header, na_rep="NaT", date_format=None) -> List[str]:
return header + list(
Expand Down

0 comments on commit ba17b28

Please sign in to comment.