Skip to content

Commit a46e8c1

Browse files
committed
CLN: for Python 3+, we can define classes without inheriting from object
1 parent 04dd8be commit a46e8c1

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

larray/core/array.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def concat(arrays, axis=0, dtype=None):
305305
return result
306306

307307

308-
class ArrayIterator(object):
308+
class ArrayIterator:
309309
__slots__ = ('__next__',)
310310

311311
def __init__(self, array):
@@ -326,7 +326,7 @@ def __iter__(self):
326326

327327
# TODO: rename to ArrayIndexIndexer or something like that
328328
# TODO: the first slice in the example below should be documented
329-
class ArrayPositionalIndexer(object):
329+
class ArrayPositionalIndexer:
330330
r"""
331331
Allows selection of a subset using indices of labels.
332332
@@ -409,7 +409,7 @@ def __iter__(self):
409409
return ArrayIterator(array)
410410

411411

412-
class ArrayPointsIndexer(object):
412+
class ArrayPointsIndexer:
413413
r"""
414414
Allows selection of arbitrary items in the array based on their N-dimensional label index.
415415
@@ -460,7 +460,7 @@ def __setitem__(self, key, value):
460460
# >>> arr.iflat[:4]
461461
# a_b a0_b0 a0_b1 a0_b2 a1_b0
462462
# 0 10 20 30
463-
class ArrayFlatIndicesIndexer(object):
463+
class ArrayFlatIndicesIndexer:
464464
r"""
465465
Access the array by index as if it was flat (one dimensional) and all its axes were combined.
466466
@@ -531,7 +531,7 @@ def __len__(self):
531531
# TODO: show that we need to use a "full slice" for leaving the dimension alone
532532
# TODO: document explicitly that axes should be in the correct order and missing axes should be slice None
533533
# (except at the end)
534-
class ArrayPositionalPointsIndexer(object):
534+
class ArrayPositionalPointsIndexer:
535535
r"""
536536
Allows selection of arbitrary items in the array based on their N-dimensional index.
537537

larray/core/axis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ def _make_axis(obj):
14741474
# not using OrderedDict because it does not support indices-based getitem
14751475
# not using namedtuple because we have to know the fields in advance (it is a one-off class) and we need more
14761476
# functionality than just a named tuple
1477-
class AxisCollection(object):
1477+
class AxisCollection:
14781478
__slots__ = ('_list', '_map')
14791479
r"""
14801480
Represents a collection of axes.
@@ -3665,7 +3665,7 @@ def evaluate(self, context):
36653665
__hash__ = object.__hash__
36663666

36673667

3668-
class AxisReferenceFactory(object):
3668+
class AxisReferenceFactory:
36693669
# needed to make pickle work (because we have a __getattr__ which does not return AttributeError on __getstate__)
36703670
def __getstate__(self):
36713671
return self.__dict__
@@ -3683,7 +3683,7 @@ def __getitem__(self, key):
36833683
X = AxisReferenceFactory()
36843684

36853685

3686-
class DeprecatedAxisReferenceFactory(object):
3686+
class DeprecatedAxisReferenceFactory:
36873687
# needed to make pickle work (because we have a __getattr__ which does not return AttributeError on __getstate__)
36883688
def __getstate__(self):
36893689
return self.__dict__

larray/core/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22

33

4-
class ExprNode(object):
4+
class ExprNode:
55
# method factory
66
def _binop(opname):
77
def opmethod(self, other):

larray/core/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def union(*args):
700700
return []
701701

702702

703-
class IGroupMaker(object):
703+
class IGroupMaker:
704704
r"""
705705
Generates a new instance of IGroup for a given axis and key.
706706
@@ -730,7 +730,7 @@ def __len__(self):
730730

731731
# We need a separate class for LGroup and cannot simply create a new Axis with a subset of values/ticks/labels:
732732
# the subset of ticks/labels of the LGroup need to correspond to its *Axis* indices
733-
class Group(object):
733+
class Group:
734734
"""Abstract Group.
735735
"""
736736
__slots__ = ('key', 'name', 'axis')

larray/core/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
# XXX: inherit from OrderedDict or Array?
21-
class Session(object):
21+
class Session:
2222
r"""
2323
Groups several objects together.
2424

larray/inout/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _get_index_col(nb_axes=None, index_col=None, wide=True):
3232
return index_col
3333

3434

35-
class FileHandler(object):
35+
class FileHandler:
3636
r"""
3737
Abstract class defining the methods for "file handler" subclasses.
3838

larray/inout/xw_excel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _disable_screen_updates(app):
6868
# unsure we can safely do this
6969
# xl_app.EnableEvents = False
7070

71-
class Workbook(object):
71+
class Workbook:
7272
# TODO: replace overwrite_file by mode='r'|'w'|'a' the day xlwings will support a read-only mode
7373
def __init__(self, filepath=None, overwrite_file=False, visible=None, silent=None, app=None, load_addins=None):
7474
global global_app
@@ -366,7 +366,7 @@ def _concrete_key(key, obj, ndim=2):
366366
return [_fill_slice(k, length) if isinstance(k, slice) else k
367367
for k, length in zip(key, shape)]
368368

369-
class Sheet(object):
369+
class Sheet:
370370
def __init__(self, workbook, key, xw_sheet=None):
371371
if xw_sheet is None:
372372
xw_sheet = workbook.xw_wkb.sheets[key]
@@ -508,7 +508,7 @@ def __repr__(self):
508508
xw_sheet = self.xw_sheet
509509
return f'<{cls.__module__}.{cls.__name__} [{xw_sheet.book.name}]{xw_sheet.name}>'
510510

511-
class Range(object):
511+
class Range:
512512
def __init__(self, sheet, *args):
513513
xw_range = sheet.xw_sheet.range(*args)
514514

@@ -615,7 +615,7 @@ def open_excel(filepath=None, overwrite_file=False, visible=None, silent=None, a
615615
return Workbook(filepath, overwrite_file=overwrite_file, visible=visible, silent=silent, app=app,
616616
load_addins=load_addins)
617617
else:
618-
class Workbook(object):
618+
class Workbook:
619619
def __init__(self, filepath=None, overwrite_file=False, visible=None, silent=None, app=None, load_addins=None):
620620
raise Exception("Workbook class cannot be instantiated because xlwings is not installed")
621621

larray/inout/xw_reporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _validate_template_filename(filename):
2525
return filename + ext
2626

2727

28-
class AbstractReportItem(object):
28+
class AbstractReportItem:
2929
def __init__(self, template_dir=None, template=None, graphs_per_row=1):
3030
self.template_dir = template_dir
3131
self.template = template
@@ -547,7 +547,7 @@ def to_excel(self, filepath, data_sheet_name='__data__', overwrite=True):
547547
from xlwings.constants import LegendPosition, HAlign, VAlign, ChartType, RowCol, AxisType, Constants
548548
from larray.inout.xw_excel import open_excel
549549

550-
class ItemSize(object):
550+
class ItemSize:
551551
def __init__(self, width, height):
552552
self.width = width
553553
self.height = height

larray/tests/test_excel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
@needs_xlwings
15-
class TestWorkbook(object):
15+
class TestWorkbook:
1616
def test_open_excel(self):
1717
import pywintypes
1818

@@ -118,7 +118,7 @@ def test_rename(self):
118118

119119

120120
@needs_xlwings
121-
class TestSheet(object):
121+
class TestSheet:
122122
def test_get_and_set_item(self):
123123
arr = ndtest((2, 3))
124124

@@ -197,7 +197,7 @@ def test_repr(self):
197197

198198

199199
@needs_xlwings
200-
class TestRange(object):
200+
class TestRange:
201201
def test_scalar_convert(self):
202202
with open_excel(visible=False) as wb:
203203
sheet = wb[0]

larray/util/misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def wrapper(*args, **kwargs):
658658
return _deprecate_kwarg
659659

660660

661-
class lazy_attribute(object):
661+
class lazy_attribute:
662662
"""
663663
Decorate a method of a class and turn it into an attribute on the instance
664664
when first called. Should obviously only be used when the result of the method is constant.
@@ -727,7 +727,7 @@ def common_type(arrays):
727727
return object
728728

729729

730-
class LHDFStore(object):
730+
class LHDFStore:
731731
"""Context manager for pandas HDFStore"""
732732
def __init__(self, filepath_or_buffer, **kwargs):
733733
if isinstance(filepath_or_buffer, pd.HDFStore):
@@ -747,7 +747,7 @@ def __exit__(self, type_, value, traceback):
747747
self.store.close()
748748

749749

750-
class SequenceZip(object):
750+
class SequenceZip:
751751
"""
752752
Represents the "combination" of several sequences.
753753
@@ -802,7 +802,7 @@ def __repr__(self):
802802
return f'SequenceZip({self.sequences})'
803803

804804

805-
class Repeater(object):
805+
class Repeater:
806806
"""
807807
Returns a virtual sequence with value repeated n times.
808808
The sequence is never actually created in memory.
@@ -875,7 +875,7 @@ def __repr__(self):
875875

876876

877877
# TODO: remove Product from larray_editor.utils (it is almost identical)
878-
class Product(object):
878+
class Product:
879879
"""
880880
Represents the `cartesian product` of several sequences.
881881

0 commit comments

Comments
 (0)