diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 2a7fd079679a4..19cb71cdc5528 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -790,7 +790,7 @@ def _get_axes(group): return group.axes -def _is_indexed_like(obj, axes): +def _is_indexed_like(obj, axes) -> bool: if isinstance(obj, Series): if len(axes) > 1: return False diff --git a/pandas/core/indexes/frozen.py b/pandas/core/indexes/frozen.py index a6c39d049c50c..4791ea2b70691 100644 --- a/pandas/core/indexes/frozen.py +++ b/pandas/core/indexes/frozen.py @@ -7,7 +7,6 @@ - .levels & .codes (FrozenNDArray) """ - import warnings import numpy as np @@ -31,7 +30,7 @@ class FrozenList(PandasObject, list): # Side note: This has to be of type list. Otherwise, # it messes up PyTables type checks. - def union(self, other): + def union(self, other) -> "FrozenList": """ Returns a FrozenList with other concatenated to the end of self. @@ -49,7 +48,7 @@ def union(self, other): other = list(other) return type(self)(super().__add__(other)) - def difference(self, other): + def difference(self, other) -> "FrozenList": """ Returns a FrozenList with elements from other removed from self. @@ -101,7 +100,9 @@ def __hash__(self): def _disabled(self, *args, **kwargs): """This method will not function because object is immutable.""" raise TypeError( - "'%s' does not support mutable operations." % self.__class__.__name__ + "'{cls}' does not support mutable operations.".format( + cls=self.__class__.__name__ + ) ) def __str__(self): @@ -132,7 +133,9 @@ def __new__(cls, data, dtype=None, copy=False): def _disabled(self, *args, **kwargs): """This method will not function because object is immutable.""" - raise TypeError("'%s' does not support mutable operations." % self.__class__) + raise TypeError( + "'{cls}' does not support mutable operations.".format(cls=self.__class__) + ) __setitem__ = __setslice__ = __delitem__ = __delslice__ = _disabled put = itemset = fill = _disabled diff --git a/pandas/io/formats/css.py b/pandas/io/formats/css.py index 92fe87cddb35b..cd58ef51d1b65 100644 --- a/pandas/io/formats/css.py +++ b/pandas/io/formats/css.py @@ -11,6 +11,23 @@ class CSSWarning(UserWarning): pass +def _side_expander(prop_fmt: str): + def expand(self, prop, value): + tokens = value.split() + try: + mapping = self.SIDE_SHORTHANDS[len(tokens)] + except KeyError: + warnings.warn( + 'Could not expand "{prop}: {val}"'.format(prop=prop, val=value), + CSSWarning, + ) + return + for key, idx in zip(self.SIDES, mapping): + yield prop_fmt.format(key), tokens[idx] + + return expand + + class CSSResolver: """A callable for parsing and resolving CSS to atomic properties @@ -213,22 +230,6 @@ def atomize(self, declarations): } SIDES = ("top", "right", "bottom", "left") - def _side_expander(prop_fmt): - def expand(self, prop, value): - tokens = value.split() - try: - mapping = self.SIDE_SHORTHANDS[len(tokens)] - except KeyError: - warnings.warn( - 'Could not expand "{prop}: {val}"'.format(prop=prop, val=value), - CSSWarning, - ) - return - for key, idx in zip(self.SIDES, mapping): - yield prop_fmt.format(key), tokens[idx] - - return expand - expand_border_color = _side_expander("border-{:s}-color") expand_border_style = _side_expander("border-{:s}-style") expand_border_width = _side_expander("border-{:s}-width") diff --git a/pandas/tests/io/msgpack/test_extension.py b/pandas/tests/io/msgpack/test_extension.py index 85ed43fa01079..6d1f8cb694601 100644 --- a/pandas/tests/io/msgpack/test_extension.py +++ b/pandas/tests/io/msgpack/test_extension.py @@ -48,7 +48,7 @@ def default(obj): typecode = 123 # application specific typecode data = tobytes(obj) return ExtType(typecode, data) - raise TypeError("Unknown type object {obj!r}".format(obj)) + raise TypeError("Unknown type object {obj!r}".format(obj=obj)) def ext_hook(code, data): print("ext_hook called", code, data)