Skip to content

Commit c69287a

Browse files
committed
use type() and repr() instead of __class__ and __repr__
1 parent ab86156 commit c69287a

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

.github/workflows/url-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
- name: Check for broken links
1717
uses: lycheeverse/lychee-action@v1
1818
with:
19-
# exclude loopback to skip localhost URLs from checking
19+
# --exclude-loopback ensures we don't check localhost URLs
2020
args: --exclude-loopback './**/*.md' './**/*.rst'

crystal_toolkit/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def _repr_mimebundle_(self, include=None, exclude=None):
6868
if hasattr(self, "get_scene"):
6969
return {
7070
"application/vnd.mp.ctk+json": self.get_scene().to_json(),
71-
"text/plain": help_text_ct + self.__repr__(),
71+
"text/plain": help_text_ct + repr(self),
7272
}
7373
elif hasattr(self, "get_plot"):
7474
return {
7575
"application/vnd.plotly.v1+json": self.get_plot().to_plotly_json(),
76-
"text/plain": help_text_plotly + self.__repr__(),
76+
"text/plain": help_text_plotly + repr(self),
7777
}
7878
else:
79-
return {"application/json": self.as_dict(), "text/plain": self.__repr__()}
79+
return {"application/json": self.as_dict(), "text/plain": repr(self)}
8080

8181

8282
MSONable._repr_mimebundle_ = _repr_mimebundle_

crystal_toolkit/components/bandstructure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ def update_select(elements, mpid):
846846
+ [{"label": "Orbital Projected - Total", "value": "op"}]
847847
+ [
848848
{
849-
"label": "Orbital Projected - " + str(ele_label),
850-
"value": "orb" + str(ele_label),
849+
"label": f"Orbital Projected - {ele_label}",
850+
"value": f"orb{ele_label}",
851851
}
852852
for ele_label in elements
853853
]
@@ -863,8 +863,8 @@ def update_select(elements, mpid):
863863
+ [{"label": "Orbital Projected - Total", "value": "op"}]
864864
+ [
865865
{
866-
"label": "Orbital Projected - " + str(ele_label),
867-
"value": "orb" + str(ele_label),
866+
"label": f"Orbital Projected - {ele_label}",
867+
"value": f"orb{ele_label}",
868868
}
869869
for ele_label in elements
870870
]

crystal_toolkit/components/diffraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,4 @@ def pattern_from_struct(struct, rad_source):
529529
# output = scope.transform(data, format="png", width=600, height=400, scale=4)
530530
# image = b64encode(output).decode('ascii')
531531
#
532-
# return "data:image/png;base64," + image
532+
# return f"data:image/png;base64,{image}"

crystal_toolkit/components/transformations/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def apply_transformation(transformation_data, struct):
183183
struct = transformation.apply_transformation(struct)
184184
except Exception as exc:
185185
error_title = (
186-
f'Failed to apply "{transformation.__class__.__name__}" '
186+
f'Failed to apply "{type(transformation).__name__}" '
187187
f"transformation: {exc}"
188188
)
189189
traceback_info = Reveal(
@@ -281,7 +281,7 @@ def __init__(
281281
user-defined order.
282282
283283
:param transformations: if provided, only offer a subset of available
284-
transformaitons, provide as a string of the given transformation name
284+
transformations, provide as a string of the given transformation name
285285
:param input_structure_component: will supply the structure to transform
286286
"""
287287

@@ -311,7 +311,7 @@ def __init__(
311311
t(input_structure_component_id=self.id("input_structure"))
312312
for t in transformations
313313
]
314-
self.transformations = {t.__class__.__name__: t for t in transformations}
314+
self.transformations = {type(t).__name__: t for t in transformations}
315315

316316
@property
317317
def _sub_layouts(self):
@@ -372,7 +372,7 @@ def apply_transformation(transformation_data, struct):
372372
struct = transformation.apply_transformation(struct)
373373
except Exception as exc:
374374
error_title = html.Span(
375-
f'Failed to apply "{transformation.__class__.__name__}" '
375+
f'Failed to apply "{type(transformation).__name__}" '
376376
f"transformation: {exc}"
377377
)
378378
traceback_info = Reveal(

crystal_toolkit/core/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _repr_mimebundle_(self, include=None, exclude=None):
7777
"""
7878
return {
7979
"application/vnd.mp.ctk+json": self.to_json(),
80-
"text/plain": self.__repr__(),
80+
"text/plain": repr(self),
8181
}
8282

8383
def to_json(self):

0 commit comments

Comments
 (0)