From f2d09a588735c548b90c7ad93635e7daeed00519 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 1 Nov 2023 00:18:34 -0400 Subject: [PATCH] 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> --- .pre-commit-config.yaml | 7 +++---- docs/make_format.py | 9 +++++---- dpdata/lammps/dump.py | 4 ++-- pyproject.toml | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23f19ed8..2e262070 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/docs/make_format.py b/docs/make_format.py index 62dd0879..4e78ce53 100644 --- a/docs/make_format.py +++ b/docs/make_format.py @@ -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: @@ -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: diff --git a/dpdata/lammps/dump.py b/dpdata/lammps/dump.py index 017f75a3..906fed9e 100644 --- a/dpdata/lammps/dump.py +++ b/dpdata/lammps/dump.py @@ -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): diff --git a/pyproject.toml b/pyproject.toml index bca3e2d3..32758449 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,6 @@ write_to = "dpdata/_version.py" profile = "black" [tool.ruff] -target-version = "py37" select = [ "E", # errors "F", # pyflakes @@ -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"