Skip to content

Commit

Permalink
move to ruff formatter (#565)
Browse files Browse the repository at this point in the history
See https://astral.sh/blog/the-ruff-formatter.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Nov 1, 2023
1 parent 94741be commit f2d09a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ repos:
- id: check-symlinks
- id: check-toml
# Python
- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
hooks:
- id: ruff
args: ["--fix"]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]
# numpydoc
- repo: https://github.com/Carreau/velin
rev: 0.0.12
Expand Down
9 changes: 5 additions & 4 deletions docs/make_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ def generate_sub_format_pages(formats: dict):
buff.append(""" :noindex:""")
buff.append("")
if docstring is None or method not in format.__dict__:
docstring = """ Convert this format to :class:`%s`.""" % (
method_classes[method]
docstring = (
""" Convert this format to :class:`%s`."""
% (method_classes[method])
)
doc_obj = SphinxDocString(docstring)
if len(doc_obj["Parameters"]) > 0:
Expand Down Expand Up @@ -293,8 +294,8 @@ def generate_sub_format_pages(formats: dict):
and "to_system" in format.__dict__
)
):
docstring = "Convert :class:`%s` to this format." % (
method_classes[method]
docstring = (
"Convert :class:`%s` to this format." % (method_classes[method])
)
doc_obj = SphinxDocString(docstring)
if len(doc_obj["Parameters"]) > 0:
Expand Down
4 changes: 2 additions & 2 deletions dpdata/lammps/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def safe_get_posi(lines, cell, orig=np.zeros(3), unwrap=False):
category=UnwrapWarning,
)
return (
posis % 1
) @ cell # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions
(posis % 1) @ cell
) # Convert scaled coordinates back to Cartesien coordinates with wraping at periodic boundary conditions


def get_dumpbox(lines):
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ write_to = "dpdata/_version.py"
profile = "black"

[tool.ruff]
target-version = "py37"
select = [
"E", # errors
"F", # pyflakes
Expand Down Expand Up @@ -101,3 +100,6 @@ ignore = [
"D404", # TODO: first word of the docstring should not be This
]
ignore-init-module-imports = true

[tool.ruff.pydocstyle]
convention = "numpy"

0 comments on commit f2d09a5

Please sign in to comment.