Skip to content

STY: x.__class__ to type(x) #batch-6 #29905

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
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 4 additions & 5 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,8 @@ def apply_index(self, i):

if type(self) is not DateOffset:
raise NotImplementedError(
"DateOffset subclass {name} "
"does not have a vectorized "
"implementation".format(name=self.__class__.__name__)
f"DateOffset subclass {type(self).__name__} "
"does not have a vectorized implementation"
)
kwds = self.kwds
relativedelta_fast = {
Expand Down Expand Up @@ -402,7 +401,7 @@ def rollback(self, dt):
"""
dt = as_timestamp(dt)
if not self.onOffset(dt):
dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds)
dt = dt - type(self)(1, normalize=self.normalize, **self.kwds)
return dt

def rollforward(self, dt):
Expand All @@ -416,7 +415,7 @@ def rollforward(self, dt):
"""
dt = as_timestamp(dt)
if not self.onOffset(dt):
dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds)
dt = dt + type(self)(1, normalize=self.normalize, **self.kwds)
return dt

def onOffset(self, dt):
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_depr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, deprmod, deprmodto=None, removals=None, moved=None):
self.moved = moved

# For introspection purposes.
self.self_dir = frozenset(dir(self.__class__))
self.self_dir = frozenset(dir(type(self)))

def __dir__(self):
deprmodule = self._import_deprmod()
Expand Down
18 changes: 9 additions & 9 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def repr_class(x):
return x

try:
return x.__class__.__name__
return type(x).__name__
except AttributeError:
return repr(type(x))

Expand Down Expand Up @@ -780,17 +780,17 @@ def assert_is_valid_plot_return_object(objs):
if isinstance(objs, (pd.Series, np.ndarray)):
for el in objs.ravel():
msg = (
"one of 'objs' is not a matplotlib Axes instance, type "
"encountered {name!r}"
).format(name=el.__class__.__name__)
"one of 'objs' is not a matplotlib Axes instance, "
f"type encountered {repr(type(el).__name__)}"
)
assert isinstance(el, (plt.Axes, dict)), msg
else:
assert isinstance(objs, (plt.Artist, tuple, dict)), (
"objs is neither an ndarray of Artist instances nor a "
'single Artist instance, tuple, or dict, "objs" is a {name!r}'.format(
name=objs.__class__.__name__
)
msg = (
"objs is neither an ndarray of Artist instances nor a single "
'Artist instance, tuple, or dict, "objs" is a '
f"{repr(type(objs).__name__)}"
)
assert isinstance(objs, (plt.Artist, tuple, dict)), msg


def isiterable(obj):
Expand Down