Skip to content

Commit ab86156

Browse files
committed
convert str addition to f-str, skip mypy + flake8 in pre-commit.ci
1 parent 288b669 commit ab86156

File tree

12 files changed

+28
-41
lines changed

12 files changed

+28
-41
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ci:
22
autoupdate_schedule: quarterly
3+
skip: [mypy, flake8]
34

45
default_stages: [commit]
56

code-of-conduct.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ is deemed necessary and appropriate to the circumstances. Maintainers are
4141
obligated to maintain confidentiality with regard to the reporter of an
4242
incident to the extent possible by law and institutional policy.
4343

44+
This Code of Conduct is adapted from the [Contributor Covenant][covenant],
45+
version 1.3.0, available at <https://www.contributor-covenant.org/version/1/3/0/code-of-conduct.html>
4446

45-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
46-
version 1.3.0, available at https://www.contributor-covenant.org/version/1/3/0/code-of-conduct.html
47-
48-
[homepage]: https://www.contributor-covenant.org
47+
[covenant]: https://www.contributor-covenant.org

crystal_toolkit/apps/examples/bandstructure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
# app.config["suppress_callback_exceptions"] = True
2020

2121
path = os.path.dirname(os.path.realpath(__file__))
22-
bandstructure_symm_line = loadfn(path + "/GaN_bs.json")
23-
density_of_states = loadfn(path + "/GaN_dos.json")
22+
bandstructure_symm_line = loadfn(f"{path}/GaN_bs.json")
23+
density_of_states = loadfn(f"{path}/GaN_dos.json")
2424

2525
# # create the Crystal Toolkit component
2626
bsdos_component = ctc.BandstructureAndDosComponent(

crystal_toolkit/apps/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import warnings
66
from random import choice
77
from time import time
8+
from typing import Any
89
from urllib import parse
910
from uuid import uuid4
1011

@@ -20,6 +21,7 @@
2021
import crystal_toolkit.components as ctc
2122
from crystal_toolkit import __file__ as module_path
2223
from crystal_toolkit.core.mpcomponent import MPComponent
24+
from crystal_toolkit.core.panelcomponent import PanelComponent
2325
from crystal_toolkit.helpers.layouts import (
2426
Box,
2527
Column,
@@ -151,7 +153,7 @@
151153
links={"default": transformation_component.id()}
152154
)
153155
# pbx_component = ctc.PourbaixDiagramPanelComponent(origin_component=struct_component)
154-
#
156+
155157
symmetry_panel = ctc.SymmetryPanel(links={"default": struct_component.id()})
156158
localenv_panel = ctc.LocalEnvironmentPanel(
157159
links={
@@ -179,7 +181,7 @@
179181

180182

181183
if SETTINGS.MP_EMBED_MODE:
182-
mp_section = (html.Div(),)
184+
mp_section: tuple[Any, ...] = (html.Div(),)
183185
else:
184186

185187
# bsdos_component = ctc.BandstructureAndDosPanelComponent(
@@ -200,7 +202,7 @@
200202
# literature_component,
201203
# ]
202204

203-
mp_panels = []
205+
mp_panels: list[PanelComponent] = []
204206

205207
mp_section = (
206208
html.H3("Materials Project"),

crystal_toolkit/components/bandstructure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,14 @@ def get_dos_traces(dos, dos_select, energy_window=(-6.0, 10.0)):
587587
"x": -1.0 * proj_data[label].densities[Spin.down][dos_min:dos_max],
588588
"y": dos.energies[dos_min:dos_max] - dos.efermi,
589589
"mode": "lines",
590-
"name": str(label) + " (spin ↓)",
590+
"name": f"{label} (spin ↓)",
591591
"line": dict(width=3, color=colors[count], dash="dot"),
592592
"xaxis": "x2",
593593
"yaxis": "y2",
594594
}
595595

596596
dostraces.append(trace)
597-
spin_up_label = str(label) + " (spin ↑)"
597+
spin_up_label = f"{label} (spin ↑)"
598598

599599
else:
600600
spin_up_label = str(label)

crystal_toolkit/components/diffraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def get_figure(
364364

365365
hkl_list = [hkl[0]["hkl"] for hkl in hkls]
366366
hkls = [
367-
"hkl: (" + " ".join([str(i) for i in hkl]) + ")" for hkl in hkl_list
367+
f"hkl: ({' '.join([str(i) for i in hkl])})" for hkl in hkl_list
368368
] # convert to (h k l) format
369369

370370
annotations = [

crystal_toolkit/components/phase_diagram.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ def create_table(chemsys, pd_time, n_clicks, pd, rows):
692692
trigger = ctx.triggered[0]
693693

694694
# PD update trigger
695-
if trigger["prop_id"] == self.id() + ".modified_timestamp":
695+
if trigger["prop_id"] == f"{self.id()}.modified_timestamp":
696696
table_content = self.create_table_content(self.from_data(pd))
697697
return table_content
698-
elif trigger["prop_id"] == self.id("editing-rows-button") + ".n_clicks":
698+
elif trigger["prop_id"] == f"{self.id('editing-rows-button')}.n_clicks":
699699
if n_clicks > 0 and rows:
700700
rows.append(self.empty_row)
701701
return rows
@@ -734,14 +734,14 @@ def get_chemsys_from_mpid_or_chemsys(mpid, chemsys_external: str):
734734
chemsys = None
735735

736736
# get entries by mpid
737-
if trigger["prop_id"] == self.id("mpid") + ".data":
737+
if trigger["prop_id"] == f"{self.id('mpid')}.data":
738738
with MPRester() as mpr:
739739
entry = mpr.get_entry_by_material_id(mpid)
740740

741741
chemsys = entry.composition.chemical_system
742742

743743
# get entries by chemsys
744-
if trigger["prop_id"] == self.id("chemsys-external") + ".data":
744+
if trigger["prop_id"] == f"{self.id('chemsys-external')}.data":
745745
chemsys = chemsys_external
746746

747747
return chemsys

crystal_toolkit/components/xas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def pattern_from_mpid(element, mpid, elements):
143143
if not element or not elements:
144144
raise PreventUpdate
145145

146-
url_path = "/materials/" + mpid["mpid"] + "/xas/" + element
146+
url_path = f"/materials/{mpid['mpid']}/xas/{element}"
147147

148148
from mp_api.client import MPRester
149149

crystal_toolkit/core/scene.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
class Primitive:
2020
"""
21-
A Mixin class for standard plottable primitive behavior
22-
For now, this just enforces some basic mergeability
21+
A Mixin class for standard plottable primitive behavior.
22+
For now, this just enforces some basic mergeability.
2323
"""
2424

25+
positions: tuple
26+
2527
@property
2628
@abstractmethod
2729
def key(self):
@@ -61,7 +63,7 @@ def __add__(self, other):
6163
:return:
6264
"""
6365
return Scene(
64-
name=self.name + "_" + other.name,
66+
name=f"{self.name}_{other.name}",
6567
contents=self.contents + other.contents,
6668
origin=self.origin,
6769
visible=self.visible,

crystal_toolkit/helpers/asymptote_renderer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ def _get_surface(ctk_scene, d_args=None):
282282
color = color.replace("#", "")
283283
opacity = ctk_scene.opacity or updated_defaults["opacity"]
284284

285-
positions = tuple(
286-
map(lambda x: "{" + f"{x[0]}, {x[1]}, {x[2]}" + "}", ctk_scene.positions)
287-
)
285+
positions = tuple(map(lambda x: f"{{{x[0]}, {x[1]}, {x[2]}}}", ctk_scene.positions))
288286
num_triangle = len(ctk_scene.positions) / 3.0
289287
# sanity check the mesh must be triangles
290288
assert num_triangle.is_integer()

0 commit comments

Comments
 (0)