Skip to content

Commit 61cf55d

Browse files
author
MomIsBestFriend
committed
Changed x.__class__ to type(x)
1 parent 6332b1e commit 61cf55d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+96
-102
lines changed

pandas/_libs/internals.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cdef class BlockPlacement:
5454
else:
5555
v = self._as_array
5656

57-
return f'{self.__class__.__name__}({v})'
57+
return f'{type(self).__name__}({v})'
5858

5959
def __repr__(self) -> str:
6060
return str(self)

pandas/_libs/tslibs/offsets.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class _BaseOffset:
363363
attrs = [(k, v) for k, v in all_paras.items()
364364
if (k not in exclude) and (k[0] != '_')]
365365
attrs = sorted(set(attrs))
366-
params = tuple([str(self.__class__)] + attrs)
366+
params = tuple([str(type(self))] + attrs)
367367
return params
368368

369369
@property

pandas/core/arrays/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ def __repr__(self) -> str:
923923
data = format_object_summary(
924924
self, self._formatter(), indent_for_name=False
925925
).rstrip(", \n")
926-
class_name = "<{}>\n".format(self.__class__.__name__)
926+
class_name = "<{}>\n".format(type(self).__name__)
927927
return template.format(
928928
class_name=class_name, data=data, length=len(self), dtype=self.dtype
929929
)

pandas/core/arrays/interval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def __repr__(self) -> str:
870870
# repr does. So we include a newline in our template, and strip
871871
# any trailing newlines from format_object_summary
872872
data = self._format_data()
873-
class_name = "<{}>\n".format(self.__class__.__name__)
873+
class_name = "<{}>\n".format(type(self).__name__)
874874
return template.format(
875875
class_name=class_name,
876876
data=data,
@@ -880,7 +880,7 @@ def __repr__(self) -> str:
880880
)
881881

882882
def _format_space(self):
883-
space = " " * (len(self.__class__.__name__) + 1)
883+
space = " " * (len(type(self).__name__) + 1)
884884
return "\n{space}".format(space=space)
885885

886886
@property

pandas/core/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class PandasObject(DirNamesMixin):
5151
@property
5252
def _constructor(self):
5353
"""class constructor (for this class it's just `__class__`"""
54-
return self.__class__
54+
return type(self)
5555

5656
def __repr__(self) -> str:
5757
"""
@@ -1185,7 +1185,7 @@ def _reduce(
11851185
if func is None:
11861186
raise TypeError(
11871187
"{klass} cannot perform the operation {op}".format(
1188-
klass=self.__class__.__name__, op=name
1188+
klass=type(self).__name__, op=name
11891189
)
11901190
)
11911191
return func(skipna=skipna, **kwds)

pandas/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def get_callable_name(obj):
317317
return get_callable_name(obj.func)
318318
# fall back to class name
319319
if hasattr(obj, "__call__"):
320-
return obj.__class__.__name__
320+
return type(obj).__name__
321321
# everything failed (probably because the argument
322322
# wasn't actually callable); we return None
323323
# instead of the empty string in this case to allow

pandas/core/computation/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def visit(self, node, **kwargs):
435435
e.msg = "Python keyword not valid identifier in numexpr query"
436436
raise e
437437

438-
method = "visit_" + node.__class__.__name__
438+
method = "visit_" + type(node).__name__
439439
visitor = getattr(self, method)
440440
return visitor(node, **kwargs)
441441

pandas/core/computation/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def type(self):
145145
def raw(self) -> str:
146146
return pprint_thing(
147147
"{0}(name={1!r}, type={2})"
148-
"".format(self.__class__.__name__, self.name, self.type)
148+
"".format(type(self).__name__, self.name, self.type)
149149
)
150150

151151
@property

pandas/core/computation/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def visit_Attribute(self, node, **kwargs):
440440
attr = node.attr
441441
value = node.value
442442

443-
ctx = node.ctx.__class__
443+
ctx = type(node.ctx)
444444
if ctx == ast.Load:
445445
# resolve the value
446446
resolved = self.visit(value)

pandas/core/dtypes/dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def __repr__(self) -> str_type:
420420
if self.categories is None:
421421
data = "None, "
422422
else:
423-
data = self.categories._format_data(name=self.__class__.__name__)
423+
data = self.categories._format_data(name=type(self).__name__)
424424
return tpl.format(data=data, ordered=self._ordered)
425425

426426
@staticmethod

0 commit comments

Comments
 (0)