Skip to content

Commit 7098073

Browse files
authored
Merge pull request #272 from materialsproject/pre-commit
`pre-commit` hooks
2 parents 3626ccb + 0d3e20b commit 7098073

File tree

93 files changed

+733
-737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+733
-737
lines changed

.github/workflows/pytest_docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ jobs:
5050
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
5151
run: |
5252
poetry run pytest --color=yes --webdriver Firefox --headless crystal_toolkit/apps/examples/tests/
53-

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: release
22

3-
on:
3+
on:
44
workflow_dispatch
55

66
jobs:

.pre-commit-config.yaml

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,83 @@
1+
ci:
2+
autoupdate_schedule: quarterly
3+
4+
default_stages: [commit]
5+
6+
default_install_hook_types: [pre-commit, commit-msg]
7+
8+
# ignore generated doc and dependency lock files
9+
exclude: ^(docs/.+|.*lock.*)$
10+
111
repos:
2-
- repo: https://github.com/ambv/black
12+
- repo: https://github.com/PyCQA/isort
13+
rev: 5.10.1
14+
hooks:
15+
- id: isort
16+
17+
- repo: https://github.com/psf/black
318
rev: 22.6.0
419
hooks:
5-
- id: black
20+
- id: black-jupyter
21+
22+
- repo: https://github.com/PyCQA/flake8
23+
rev: 4.0.1
24+
hooks:
25+
- id: flake8
26+
27+
- repo: https://github.com/asottile/pyupgrade
28+
rev: v2.34.0
29+
hooks:
30+
- id: pyupgrade
31+
args: [--py38-plus]
32+
33+
- repo: https://github.com/pre-commit/mirrors-mypy
34+
rev: v0.961
35+
hooks:
36+
- id: mypy
37+
38+
- repo: https://github.com/pre-commit/pre-commit-hooks
39+
rev: v4.3.0
40+
hooks:
41+
- id: check-case-conflict
42+
- id: check-symlinks
43+
- id: check-yaml
44+
- id: destroyed-symlinks
45+
- id: end-of-file-fixer
46+
exclude: ^assets/.+\.(svg|html)$
47+
- id: mixed-line-ending
48+
- id: trailing-whitespace
49+
50+
- repo: https://github.com/codespell-project/codespell
51+
rev: v2.1.0
52+
hooks:
53+
- id: codespell
54+
stages: [commit, commit-msg]
55+
exclude_types: [csv, svg, html, yaml, jupyter]
56+
57+
- repo: local
58+
hooks:
59+
- id: svg-assets
60+
name: SVG assets
61+
entry: Files under assets/* must end in .(svg|html)
62+
language: fail
63+
files: ^assets/.*(?<!\.svg)(?<!\.html)$
64+
65+
- repo: https://github.com/myint/autoflake
66+
rev: v1.4
67+
hooks:
68+
- id: autoflake
69+
args:
70+
- --in-place
71+
- --remove-unused-variables
72+
- --remove-all-unused-imports
73+
- --expand-star-imports
74+
- --ignore-init-module-imports
75+
76+
- repo: https://github.com/nbQA-dev/nbQA
77+
rev: 1.3.1
78+
hooks:
79+
- id: nbqa-pyupgrade
80+
args: [--py38-plus]
81+
- id: nbqa-isort
82+
- id: nbqa-flake8
83+
args: [--ignore=E402]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ New contributors are welcome, please see our [Code of Conduct.](code-of-conduct.
4141

4242
The Crystal Toolkit repo currently contains three major parts:
4343

44-
* An object-orientated Python framework for rendering materials science data based on the schema employed by the Materials Proejct
44+
* An object-orientated Python framework for rendering materials science data based on the schema employed by the Materials Project
4545
* A few custom Plotly Dash components (Simple3DSceneComponent, JSONComponent, GraphComponent)
4646
* Some example apps using these components
4747

4848
It is likely the custom Plotly Dash components might be spun off into a separate repo at some point to reduce the complexity of the Crystal Toolkit repo itself.
4949

5050
## Acknowledgements
5151

52-
Thank you to all the authors and maintainers of the libraries Crystal Toolkit
53-
depends upon, and in particular [pymatgen](http://pymatgen.org) for crystallographic
52+
Thank you to all the authors and maintainers of the libraries Crystal Toolkit
53+
depends upon, and in particular [pymatgen](http://pymatgen.org) for crystallographic
5454
analysis and [Dash from Plotly](https://plot.ly/products/dash/) for their web app framework.
5555

5656
Thank you to the [NERSC Spin](http://www.nersc.gov/users/data-analytics/spin/) service for

code-of-conduct.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
4646
version 1.3.0, available at https://www.contributor-covenant.org/version/1/3/0/code-of-conduct.html
4747

4848
[homepage]: https://www.contributor-covenant.org
49-

crystal_toolkit/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
from __future__ import annotations
2+
13
import json
24
import os as _os
35
from collections import defaultdict
46
from pathlib import Path
7+
from typing import Any
58

69
# pleasant hack to support MSONable objects in Dash callbacks natively
710
from monty.json import MSONable
811

9-
from crystal_toolkit.renderables import *
12+
from crystal_toolkit.renderables import (
13+
Lattice,
14+
Molecule,
15+
MoleculeGraph,
16+
PhaseDiagram,
17+
Site,
18+
Structure,
19+
StructureGraph,
20+
VolumetricData,
21+
)
1022

1123
__version__ = "2022.07.25"
1224

@@ -21,7 +33,7 @@ def to_plotly_json(self):
2133

2234

2335
# Populate the default values from the JSON file
24-
_DEFAULTS = defaultdict(lambda: None)
36+
_DEFAULTS: dict[str, Any] = defaultdict()
2537
default_js = _os.path.join(
2638
_os.path.join(_os.path.dirname(_os.path.abspath(__file__))), "./", "defaults.json"
2739
)
@@ -43,8 +55,8 @@ def _repr_mimebundle_(self, include=None, exclude=None):
4355
This only works in Jupyter Lab 3.x or above.\n\n
4456
"""
4557

46-
help_text_plotly = """If you see this text, the Plotly Jupyter Lab extension
47-
is not installed, please consult Plotly documentation for information on how to
58+
help_text_plotly = """If you see this text, the Plotly Jupyter Lab extension
59+
is not installed, please consult Plotly documentation for information on how to
4860
install.
4961
"""
5062

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
41
body, html, .body {
52
background: #f3f3f3 !important;
63
}
7-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"10.26434/chemrxiv.11294480.v1": "D. Waroquiers, J. George, M. Horton, S. Schenk, K. Persson, G.-M. Rignanese, X. Gonze, and G. Hautier, \u201cChemEnv\u202f: A Fast and Robust Coordination Environment Identification Tool,\u201d Dec. 2019.\n", "10.3389/fmats.2017.00034": "N. E. R. Zimmermann, M. K. Horton, A. Jain, and M. Haranczyk, \u201cAssessing Local Structure Motifs Using Order Parameters for Motif Recognition, Interstitial Identification, and Diffusion Path Characterization,\u201d Frontiers in Materials, vol. 4, Nov. 2017.\n"}
1+
{"10.26434/chemrxiv.11294480.v1": "D. Waroquiers, J. George, M. Horton, S. Schenk, K. Persson, G.-M. Rignanese, X. Gonze, and G. Hautier, \u201cChemEnv\u202f: A Fast and Robust Coordination Environment Identification Tool,\u201d Dec. 2019.\n", "10.3389/fmats.2017.00034": "N. E. R. Zimmermann, M. K. Horton, A. Jain, and M. Haranczyk, \u201cAssessing Local Structure Motifs Using Order Parameters for Motif Recognition, Interstitial Identification, and Diffusion Path Characterization,\u201d Frontiers in Materials, vol. 4, Nov. 2017.\n"}

crystal_toolkit/apps/assets/task_ids_on_load.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

crystal_toolkit/apps/examples/GaN_bs.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)