Skip to content

Commit f2d09a5

Browse files
move to ruff formatter (#565)
See https://astral.sh/blog/the-ruff-formatter. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 94741be commit f2d09a5

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ repos:
1717
- id: check-symlinks
1818
- id: check-toml
1919
# Python
20-
- repo: https://github.com/psf/black
21-
rev: 23.10.1
22-
hooks:
23-
- id: black-jupyter
2420
- repo: https://github.com/astral-sh/ruff-pre-commit
2521
# Ruff version.
2622
rev: v0.1.3
2723
hooks:
2824
- id: ruff
2925
args: ["--fix"]
26+
types_or: [python, pyi, jupyter]
27+
- id: ruff-format
28+
types_or: [python, pyi, jupyter]
3029
# numpydoc
3130
- repo: https://github.com/Carreau/velin
3231
rev: 0.0.12

docs/make_format.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ def generate_sub_format_pages(formats: dict):
224224
buff.append(""" :noindex:""")
225225
buff.append("")
226226
if docstring is None or method not in format.__dict__:
227-
docstring = """ Convert this format to :class:`%s`.""" % (
228-
method_classes[method]
227+
docstring = (
228+
""" Convert this format to :class:`%s`."""
229+
% (method_classes[method])
229230
)
230231
doc_obj = SphinxDocString(docstring)
231232
if len(doc_obj["Parameters"]) > 0:
@@ -293,8 +294,8 @@ def generate_sub_format_pages(formats: dict):
293294
and "to_system" in format.__dict__
294295
)
295296
):
296-
docstring = "Convert :class:`%s` to this format." % (
297-
method_classes[method]
297+
docstring = (
298+
"Convert :class:`%s` to this format." % (method_classes[method])
298299
)
299300
doc_obj = SphinxDocString(docstring)
300301
if len(doc_obj["Parameters"]) > 0:

dpdata/lammps/dump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def safe_get_posi(lines, cell, orig=np.zeros(3), unwrap=False):
121121
category=UnwrapWarning,
122122
)
123123
return (
124-
posis % 1
125-
) @ cell # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions
124+
(posis % 1) @ cell
125+
) # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions
126126

127127

128128
def get_dumpbox(lines):

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ write_to = "dpdata/_version.py"
7272
profile = "black"
7373

7474
[tool.ruff]
75-
target-version = "py37"
7675
select = [
7776
"E", # errors
7877
"F", # pyflakes
@@ -101,3 +100,6 @@ ignore = [
101100
"D404", # TODO: first word of the docstring should not be This
102101
]
103102
ignore-init-module-imports = true
103+
104+
[tool.ruff.pydocstyle]
105+
convention = "numpy"

0 commit comments

Comments
 (0)