diff --git a/asv_bench/benchmarks/index_object.py b/asv_bench/benchmarks/index_object.py index 11ff5444223d0..908eaa3a9d214 100644 --- a/asv_bench/benchmarks/index_object.py +++ b/asv_bench/benchmarks/index_object.py @@ -181,7 +181,7 @@ def time_get_loc(self): self.ind.get_loc(0) -class IntervalIndexMethod(object): +class IntervalIndexMethod: # GH 24813 params = [10**3, 10**5] diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 9a95b7887cfab..e7444fe56ab4d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -141,7 +141,7 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Check for python2 new-style classes' ; echo $MSG - invgrep -R --include="*.py" -E "class\s\S*\(object\):" pandas scripts + invgrep -R --include="*.py" --include="*.pyx" -E "class\s\S*\(object\):" pandas scripts RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Check for backticks incorrectly rendering because of missing spaces' ; echo $MSG diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index 663411ad984c2..b0533383ac3b1 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -50,7 +50,7 @@ cdef inline bint are_diff(object left, object right): return left != right -class Infinity(object): +class Infinity: """ provide a positive Infinity comparison method for ranking """ __lt__ = lambda self, other: False @@ -62,7 +62,7 @@ class Infinity(object): __ge__ = lambda self, other: not missing.checknull(other) -class NegInfinity(object): +class NegInfinity: """ provide a negative Infinity comparison method for ranking """ __lt__ = lambda self, other: (not isinstance(other, NegInfinity) and diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx index 173be9398b634..da1bbb8dc130f 100644 --- a/pandas/_libs/interval.pyx +++ b/pandas/_libs/interval.pyx @@ -30,7 +30,7 @@ from pandas._libs.tslibs.timezones cimport tz_compare _VALID_CLOSED = frozenset(['left', 'right', 'both', 'neither']) -cdef class IntervalMixin(object): +cdef class IntervalMixin: @property def closed_left(self): diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index d80cc482be5b3..0ffbfa0b1f462 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -935,7 +935,7 @@ except AttributeError: pass -cdef class Seen(object): +cdef class Seen: """ Class for keeping track of the types of elements encountered when trying to perform type conversions. diff --git a/pandas/_libs/properties.pyx b/pandas/_libs/properties.pyx index d2fbf5aa66fbf..98b2e2888fb21 100644 --- a/pandas/_libs/properties.pyx +++ b/pandas/_libs/properties.pyx @@ -6,7 +6,7 @@ from cpython cimport ( PyDict_Contains, PyDict_GetItem, PyDict_SetItem) -cdef class CachedProperty(object): +cdef class CachedProperty: cdef readonly: object func, name, __doc__ @@ -44,7 +44,7 @@ cdef class CachedProperty(object): cache_readonly = CachedProperty -cdef class AxisProperty(object): +cdef class AxisProperty: cdef readonly: Py_ssize_t axis diff --git a/pandas/_libs/sparse.pyx b/pandas/_libs/sparse.pyx index 5471c8184e458..fb8e0026556ee 100644 --- a/pandas/_libs/sparse.pyx +++ b/pandas/_libs/sparse.pyx @@ -614,7 +614,7 @@ cdef class BlockIndex(SparseIndex): pass -cdef class BlockMerge(object): +cdef class BlockMerge: """ Object-oriented approach makes sharing state between recursive functions a lot easier and reduces code duplication diff --git a/pandas/_libs/tslibs/frequencies.pyx b/pandas/_libs/tslibs/frequencies.pyx index fb74fb08286a3..eac1d31261602 100644 --- a/pandas/_libs/tslibs/frequencies.pyx +++ b/pandas/_libs/tslibs/frequencies.pyx @@ -22,7 +22,7 @@ INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}" # Period codes -class FreqGroup(object): +class FreqGroup: FR_ANN = 1000 FR_QTR = 2000 FR_MTH = 3000 diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 9d5151f05b45b..ed1d7cd4c76e7 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -312,7 +312,7 @@ class ApplyTypeError(TypeError): # --------------------------------------------------------------------- # Base Classes -class _BaseOffset(object): +class _BaseOffset: """ Base class for DateOffset methods that are not overridden by subclasses and will (after pickle errors are resolved) go into a cdef class. @@ -533,7 +533,7 @@ class BaseOffset(_BaseOffset): return -self + other -class _Tick(object): +class _Tick: """ dummy class to mix into tseries.offsets.Tick so that in tslibs.period we can do isinstance checks on _Tick and avoid importing tseries.offsets diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index f6f52efa951fe..7cf079af2ac29 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -660,7 +660,7 @@ def try_parse_datetime_components(object[:] years, # Thus, we port the class over so that both issues are resolved. # # Copyright (c) 2017 - dateutil contributors -class _timelex(object): +class _timelex: def __init__(self, instream): if getattr(instream, 'decode', None) is not None: instream = instream.decode() diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 624cad2bfa95a..8f190751951f1 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1557,7 +1557,7 @@ class IncompatibleFrequency(ValueError): pass -cdef class _Period(object): +cdef class _Period: cdef readonly: int64_t ordinal diff --git a/pandas/_libs/tslibs/resolution.pyx b/pandas/_libs/tslibs/resolution.pyx index e02e2b3fe8f3d..a9a63f8120851 100644 --- a/pandas/_libs/tslibs/resolution.pyx +++ b/pandas/_libs/tslibs/resolution.pyx @@ -133,7 +133,7 @@ def get_freq_group(freq): return (freq // 1000) * 1000 -class Resolution(object): +class Resolution: # Note: cython won't allow us to reference the cdef versions at the # module level diff --git a/pandas/_libs/tslibs/strptime.pyx b/pandas/_libs/tslibs/strptime.pyx index 527d2da8e3182..642f306f80bda 100644 --- a/pandas/_libs/tslibs/strptime.pyx +++ b/pandas/_libs/tslibs/strptime.pyx @@ -363,7 +363,7 @@ def _getlang(): return locale.getlocale(locale.LC_TIME) -class LocaleTime(object): +class LocaleTime: """Stores and handles locale-specific information related to time. ATTRIBUTES: diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 7340e716ec651..c76346e25cdb9 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -57,7 +57,7 @@ cdef inline object create_timestamp_from_ts(int64_t value, return ts_base -class RoundTo(object): +class RoundTo: """ enumeration defining the available rounding modes diff --git a/pandas/io/msgpack/_packer.pyx b/pandas/io/msgpack/_packer.pyx index 8e2d943d8ddb1..a0d2b013c8e9d 100644 --- a/pandas/io/msgpack/_packer.pyx +++ b/pandas/io/msgpack/_packer.pyx @@ -44,7 +44,7 @@ cdef extern from "../../src/msgpack/pack.h": cdef int DEFAULT_RECURSE_LIMIT=511 -cdef class Packer(object): +cdef class Packer: """ MessagePack Packer diff --git a/pandas/io/msgpack/_unpacker.pyx b/pandas/io/msgpack/_unpacker.pyx index 9bbfe749ef9ba..8734990c44da0 100644 --- a/pandas/io/msgpack/_unpacker.pyx +++ b/pandas/io/msgpack/_unpacker.pyx @@ -173,7 +173,7 @@ def unpack(object stream, object object_hook=None, object list_hook=None, encoding=encoding, unicode_errors=unicode_errors) -cdef class Unpacker(object): +cdef class Unpacker: """Streaming unpacker. arguments: diff --git a/pandas/io/sas/sas.pyx b/pandas/io/sas/sas.pyx index ed6a3efae137c..0aec958d1f9bd 100644 --- a/pandas/io/sas/sas.pyx +++ b/pandas/io/sas/sas.pyx @@ -211,7 +211,7 @@ cdef: int subheader_pointers_offset = const.subheader_pointers_offset -cdef class Parser(object): +cdef class Parser: cdef: int column_count