Skip to content

Commit 9d0f896

Browse files
authored
Merge pull request #395 from materialsproject/fix-pyproject
Fix `pyproject.toml` malformed `[build-system] requires`
2 parents c1f0aed + 647985c commit 9d0f896

File tree

13 files changed

+97
-187
lines changed

13 files changed

+97
-187
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
3535
python${{ matrix.python-version }} -m pip install --upgrade pip
3636
python${{ matrix.python-version }} -m pip install --no-deps .[server]
37-
37+
3838
- name: Build package
3939
run: python${{ matrix.python-version }} -m build
4040

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exclude: ^(docs/.+|.*lock.*|jupyterlab-extension/.+|.*\.(svg|js|css))|_version.p
1111

1212
repos:
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.1.5
14+
rev: v0.4.8
1515
hooks:
1616
- id: ruff
1717
args: [--fix, --ignore, D]
@@ -23,7 +23,7 @@ repos:
2323
# - id: mypy
2424

2525
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v4.5.0
26+
rev: v4.6.0
2727
hooks:
2828
- id: check-case-conflict
2929
- id: check-symlinks
@@ -33,14 +33,14 @@ repos:
3333
- id: trailing-whitespace
3434

3535
- repo: https://github.com/codespell-project/codespell
36-
rev: v2.2.6
36+
rev: v2.3.0
3737
hooks:
3838
- id: codespell
3939
stages: [commit, commit-msg]
4040
args: [--ignore-words-list, "nd,te,ois,dscribe", --check-filenames]
4141

4242
- repo: https://github.com/kynan/nbstripout
43-
rev: 0.6.1
43+
rev: 0.7.1
4444
hooks:
4545
- id: nbstripout
4646
args: [--drop-empty-cells, --keep-output]

crystal_toolkit/apps/examples/tests/typing.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,33 @@ class DashDuo(Protocol):
1616

1717
# driver = ... # selenium.webdriver.remote.WebDriver
1818

19-
def start_server(self, start_server) -> None:
20-
...
19+
def start_server(self, start_server) -> None: ...
2120

22-
def find_element(self, selector: str) -> dash.development.base_component.Component:
23-
...
21+
def find_element(
22+
self, selector: str
23+
) -> dash.development.base_component.Component: ...
2424

2525
def wait_for_text_to_equal(
2626
self, selector: str, text: str, timeout: int | None = None
27-
) -> None:
28-
...
27+
) -> None: ...
2928

30-
def get_logs(self) -> list[str]:
31-
...
29+
def get_logs(self) -> list[str]: ...
3230

33-
def clear_storage(self) -> None:
34-
...
31+
def clear_storage(self) -> None: ...
3532

36-
def percy_snapshot(self, name: str, wait_for_callbacks: bool = False) -> None:
37-
...
33+
def percy_snapshot(self, name: str, wait_for_callbacks: bool = False) -> None: ...
3834

39-
def multiple_click(self, selector: str, clicks: int) -> None:
40-
...
35+
def multiple_click(self, selector: str, clicks: int) -> None: ...
4136

42-
def wait_for_element(self, selector: str, timeout: int | None = None) -> None:
43-
...
37+
def wait_for_element(self, selector: str, timeout: int | None = None) -> None: ...
4438

45-
def take_snapshot(self, name: str) -> None:
46-
...
39+
def take_snapshot(self, name: str) -> None: ...
4740

48-
def wait_for_page(self, url: str | None = None, timeout: int = 10) -> None:
49-
...
41+
def wait_for_page(self, url: str | None = None, timeout: int = 10) -> None: ...
5042

5143
def find_elements(
5244
self, selector: str
53-
) -> list[dash.development.base_component.Component]:
54-
...
45+
) -> list[dash.development.base_component.Component]: ...
5546

5647
def select_dcc_dropdown(
5748
self,

crystal_toolkit/components/bandstructure.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def get_dos_traces(
523523
raise PreventUpdate
524524

525525
# Projected DOS
526-
count = 0
527526
colors = [
528527
"#d62728", # brick red
529528
"#2ca02c", # cooked asparagus green
@@ -534,7 +533,7 @@ def get_dos_traces(
534533
"#e377c2", # raspberry yogurt pink
535534
]
536535

537-
for label in proj_data:
536+
for count, label in enumerate(proj_data):
538537
if spin_polarized:
539538
trace = {
540539
dos_axis: -1.0
@@ -565,8 +564,6 @@ def get_dos_traces(
565564

566565
dos_traces.append(trace)
567566

568-
count += 1
569-
570567
return dos_traces
571568

572569
@staticmethod

crystal_toolkit/components/phonon.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def layout(self) -> html.Div:
174174

175175
@staticmethod
176176
def _get_ph_bs_dos(
177-
data: dict[str, Any] | None
177+
data: dict[str, Any] | None,
178178
) -> tuple[PhononBandStructureSymmLine, CompletePhononDos]:
179179
data = data or {}
180180

@@ -399,7 +399,6 @@ def get_ph_dos_traces(dos: CompletePhononDos, freq_range: tuple[float, float]):
399399
dos_traces.append(trace_tdos)
400400

401401
# Projected DOS
402-
count = 0
403402
colors = [
404403
"#d62728", # brick red
405404
"#2ca02c", # cooked asparagus green
@@ -411,7 +410,7 @@ def get_ph_dos_traces(dos: CompletePhononDos, freq_range: tuple[float, float]):
411410
]
412411

413412
ele_dos = dos.get_element_dos() # project DOS onto elements
414-
for label in ele_dos:
413+
for count, label in enumerate(ele_dos):
415414
spin_up_label = str(label)
416415

417416
trace = {
@@ -426,8 +425,6 @@ def get_ph_dos_traces(dos: CompletePhononDos, freq_range: tuple[float, float]):
426425

427426
dos_traces.append(trace)
428427

429-
count += 1
430-
431428
return dos_traces
432429

433430
@staticmethod

crystal_toolkit/core/jupyter.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ class _JupyterRenderer:
3131

3232
@staticmethod
3333
def _find_available_port():
34-
"""
35-
Find an available port.
34+
"""Find an available port.
3635
3736
Thank you Mihai Capotă, https://stackoverflow.com/a/61685162
3837
"""
39-
4038
import socketserver
4139

4240
with socketserver.TCPServer(("localhost", 0), None) as s:
@@ -46,10 +44,7 @@ def _find_available_port():
4644
# check docs about proxy settings
4745

4846
def run(self, layout):
49-
"""
50-
Run Dash app.
51-
"""
52-
47+
"""Run Dash app."""
5348
app = Dash(plugins=[CrystalToolkitPlugin(layout=layout)])
5449

5550
port = SETTINGS.JUPYTER_EMBED_PORT or self._find_available_port()
@@ -63,10 +58,7 @@ def run(self, layout):
6358
app.run(port=free_port, jupyter_mode=SETTINGS.JUPYTER_EMBED_MODE)
6459

6560
def display(self, obj):
66-
"""
67-
Display a provided object.
68-
"""
69-
61+
"""Display a provided object."""
7062
for kls, component in self.registry.items():
7163
if isinstance(obj, kls):
7264
layout = ctl.Block(
@@ -79,35 +71,27 @@ def display(self, obj):
7971

8072

8173
def _to_plotly_json(self):
82-
"""
83-
Patch to ensure MSONable objects can be serialized into JSON by plotly tools.
84-
"""
74+
"""Patch to ensure MSONable objects can be serialized into JSON by plotly tools."""
8575
return self.as_dict()
8676

8777

8878
def _display_json(self, **kwargs):
89-
"""
90-
Display JSON representation of an MSONable object inside Jupyter.
91-
"""
79+
"""Display JSON representation of an MSONable object inside Jupyter."""
9280
from IPython.display import JSON
9381

9482
JSON(self.as_dict(), **kwargs)
9583

9684

9785
def _repr_mimebundle_(self, include=None, exclude=None):
98-
"""
99-
Method used by Jupyter. A default for MSONable objects to return JSON representation.
100-
"""
86+
"""Method used by Jupyter. A default for MSONable objects to return JSON representation."""
10187
return {
10288
"application/json": self.as_dict(),
10389
"text/plain": repr(self),
10490
}
10591

10692

10793
def _ipython_display_(self):
108-
"""
109-
Display MSONable objects using a Crystal Toolkit component, if available.
110-
"""
94+
"""Display MSONable objects using a Crystal Toolkit component, if available."""
11195
from IPython.display import publish_display_data
11296

11397
if any(isinstance(self, x) for x in _JupyterRenderer.registry):
@@ -140,11 +124,9 @@ def _ipython_display_(self):
140124

141125

142126
def patch_msonable():
143-
"""
144-
Patch MSONable to allow MSONable objects to render in Jupyter
127+
"""Patch MSONable to allow MSONable objects to render in Jupyter
145128
environments using Crystal Toolkit components.
146129
"""
147-
148130
from monty.json import MSONable
149131

150132
MSONable.to_plotly_json = _to_plotly_json

crystal_toolkit/core/mpcomponent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
CT_NAMESPACE = "CT"
3333

3434

35-
class MPComponent(ABC):
35+
class MPComponent(ABC): # noqa: B024
3636
"""The abstract base class for an MPComponent.
3737
3838
MPComponent is designed to help render an MSONable object.

crystal_toolkit/core/plugin.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212

1313
class CrystalToolkitPlugin:
14-
"""
15-
Enables Crystal Toolkit components to work with your Dash app.
14+
"""Enables Crystal Toolkit components to work with your Dash app.
1615
1716
This is a replacement for the previous `register_crystal_toolkit`
1817
function, to instead use Dash's native plugin system.
@@ -27,8 +26,7 @@ class CrystalToolkitPlugin:
2726
def __init__(
2827
self, layout, cache: Cache | None = None, use_default_css=True
2928
) -> None:
30-
"""
31-
Provide your initial app layout.
29+
"""Provide your initial app layout.
3230
3331
Provide a cache to improve performance. If running
3432
in debug mode, the cache will be automatically disabled. If
@@ -51,9 +49,7 @@ def __init__(
5149
self.use_default_css = use_default_css
5250

5351
def plug(self, app: Dash):
54-
"""
55-
Initialize Crystal Toolkit plugin for the specified Dash app.
56-
"""
52+
"""Initialize Crystal Toolkit plugin for the specified Dash app."""
5753
self.app = app
5854
self.cache.init_app(app.server)
5955

@@ -83,15 +79,13 @@ def plug(self, app: Dash):
8379
app.config.external_stylesheets.append(font_awesome_css)
8480

8581
def crystal_toolkit_layout(self, layout) -> html.Div:
86-
"""
87-
Crystal Toolkit currently requires a set of dcc.Store components
82+
"""Crystal Toolkit currently requires a set of dcc.Store components
8883
to be added to the layout in order to function.
8984
9085
Eventually, it is hoped to remove the need for this method through
9186
use of All-in-One components. All-in-One components were not yet
9287
available when Crystal Toolkit was first developed.
9388
"""
94-
9589
from crystal_toolkit.core.mpcomponent import MPComponent
9690

9791
# Crystal Toolkit has not been tested with dynamic layouts

crystal_toolkit/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Populate the default values from the JSON file."""
2+
23
from __future__ import annotations
34

45
import json

crystal_toolkit/helpers/asymptote_renderer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
TODO The code should also append a set of special points at the end in case the user wants to add
66
more "hand drawn" features to the plot.
77
"""
8+
89
from __future__ import annotations
910

1011
import logging

0 commit comments

Comments
 (0)