Skip to content

CLN: remove compat.add_metaclass #26165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

Key items to import for compatible code:
* lists: lrange(), lmap(), lzip()
* add_metaclass(metaclass) - class decorator that recreates class with with the
given metaclass instead (and avoids intermediary class creation)

Other items:
* platform checker
Expand Down Expand Up @@ -66,20 +64,6 @@ def set_function_name(f, name, cls):
return f


def add_metaclass(metaclass):
"""
Class decorator for creating a class with a metaclass.
"""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
for slots_var in orig_vars.get('__slots__', ()):
orig_vars.pop(slots_var)
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper


def raise_with_traceback(exc, traceback=Ellipsis):
"""
Raise exception with existing traceback.
Expand Down
7 changes: 2 additions & 5 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pandas._config import config

import pandas.compat as compat
from pandas.compat import add_metaclass
from pandas.errors import EmptyDataError
from pandas.util._decorators import Appender, deprecate_kwarg

Expand Down Expand Up @@ -328,8 +327,7 @@ def read_excel(io,
**kwds)


@add_metaclass(abc.ABCMeta)
class _BaseExcelReader:
class _BaseExcelReader(metaclass=abc.ABCMeta):

@property
@abc.abstractmethod
Expand Down Expand Up @@ -487,8 +485,7 @@ def parse(self,
return output[asheetname]


@add_metaclass(abc.ABCMeta)
class ExcelWriter:
class ExcelWriter(metaclass=abc.ABCMeta):
"""
Class for writing DataFrame objects into excel sheets, default is to use
xlwt for xls, openpyxl for xlsx. See DataFrame.to_excel for typical usage.
Expand Down
5 changes: 1 addition & 4 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dateutil.relativedelta import FR, MO, SA, SU, TH, TU, WE # noqa
import numpy as np

from pandas.compat import add_metaclass
from pandas.errors import PerformanceWarning

from pandas import DateOffset, Series, Timestamp, date_range
Expand Down Expand Up @@ -324,12 +323,10 @@ def __new__(cls, clsname, bases, attrs):
return calendar_class


@add_metaclass(HolidayCalendarMetaClass)
class AbstractHolidayCalendar:
class AbstractHolidayCalendar(metaclass=HolidayCalendarMetaClass):
"""
Abstract interface to create holidays following certain rules.
"""
__metaclass__ = HolidayCalendarMetaClass
rules = [] # type: List[Holiday]
start_date = Timestamp(datetime(1970, 1, 1))
end_date = Timestamp(datetime(2030, 12, 31))
Expand Down