Skip to content

Commit f8045b0

Browse files
committed
self.__class__.__name__ -> type(self).__name__
1 parent 805396c commit f8045b0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

crystal_toolkit/components/transformations/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class TransformationComponent(MPComponent):
2525
def __init__(self, input_structure_component_id: str, *args, **kwargs):
2626

27-
if self.__class__.__name__ != f"{self.transformation.__name__}Component":
27+
if type(self).__name__ != f"{self.transformation.__name__}Component":
2828
# sanity check, enforcing conventions
2929
raise NameError(
3030
f"Class has to be named corresponding to the underlying "
@@ -230,7 +230,7 @@ def update_preview(transformation_data, input_structure):
230230
)
231231
@cache.memoize(
232232
timeout=60 * 60 * 24,
233-
make_name=lambda x: f"{self.__class__.__name__}_{x}_cached",
233+
make_name=lambda x: f"{type(self).__name__}_{x}_cached",
234234
)
235235
def update_transformation(enabled, states):
236236

crystal_toolkit/core/mpcomponent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __init__(
207207
if id is None:
208208
# TODO: this could lead to duplicate ids and an error, but if
209209
# setting random ids, this could also lead to undefined behavior
210-
id = f"{CT_NAMESPACE}{self.__class__.__name__}"
210+
id = f"{CT_NAMESPACE}{type(self).__name__}"
211211
elif not id.startswith(CT_NAMESPACE):
212212
id = f"{CT_NAMESPACE}{id}"
213213
MPComponent._all_id_basenames.add(id)
@@ -228,7 +228,7 @@ def __init__(
228228
# callbacks generated as final step by crystal_toolkit_layout()
229229
self._callbacks_to_generate.add(self)
230230

231-
self.logger = logging.getLogger(self.__class__.__name__)
231+
self.logger = logging.getLogger(type(self).__name__)
232232

233233
def id(
234234
self,
@@ -360,7 +360,7 @@ def all_ids(self) -> List[str]:
360360
)
361361

362362
def __repr__(self):
363-
return f"{self.id()}<{self.__class__.__name__}>"
363+
return f"{self.id()}<{type(self).__name__}>"
364364

365365
def __str__(self):
366366
ids = "\n".join(
@@ -371,7 +371,7 @@ def __str__(self):
371371
[f"* {layout} " for layout in sorted(self._sub_layouts.keys())]
372372
)
373373

374-
return f"""{self.id()}<{self.__class__.__name__}> \n
374+
return f"""{self.id()}<{type(self).__name__}> \n
375375
IDs: \n{ids} \n
376376
Stores: \n{stores} \n
377377
Sub-layouts: \n{layouts}"""
@@ -764,7 +764,7 @@ def reconstruct_kwargs_from_state(self, state=None, kwarg_labels=None) -> Dict:
764764
kwargs[k] = v.tolist()
765765

766766
if SETTINGS.DEBUG_MODE:
767-
print(self.__class__.__name__, "kwargs", kwargs)
767+
print(type(self).__name__, "kwargs", kwargs)
768768

769769
return kwargs
770770

0 commit comments

Comments
 (0)