diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 407869ac2..e75e543cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.2.2 + rev: v0.3.2 hooks: - id: ruff args: ["--fix"] diff --git a/dpdata/amber/mask.py b/dpdata/amber/mask.py index 109cdf9c1..e3ae1e8da 100644 --- a/dpdata/amber/mask.py +++ b/dpdata/amber/mask.py @@ -1,4 +1,5 @@ """Amber mask.""" + try: import parmed except ImportError: diff --git a/dpdata/cli.py b/dpdata/cli.py index 04850b80b..07e7b4b5d 100644 --- a/dpdata/cli.py +++ b/dpdata/cli.py @@ -1,4 +1,5 @@ """Command line interface for dpdata.""" + import argparse from typing import Optional diff --git a/dpdata/cp2k/output.py b/dpdata/cp2k/output.py index 0c8df6d78..c84355c46 100644 --- a/dpdata/cp2k/output.py +++ b/dpdata/cp2k/output.py @@ -117,9 +117,7 @@ def get_xyz_block_generator(self): lines.append(self.xyz_file_object.readline()) if not lines[-1]: raise RuntimeError( - "this xyz file may lack of lines, should be {};lines:{}".format( - atom_num + 2, lines - ) + f"this xyz file may lack of lines, should be {atom_num + 2};lines:{lines}" ) yield lines diff --git a/dpdata/deepmd/hdf5.py b/dpdata/deepmd/hdf5.py index 0bae06943..ef54d862a 100644 --- a/dpdata/deepmd/hdf5.py +++ b/dpdata/deepmd/hdf5.py @@ -1,4 +1,5 @@ """Utils for deepmd/hdf5 format.""" + from __future__ import annotations import warnings diff --git a/dpdata/driver.py b/dpdata/driver.py index 71a1e0b35..81d9a9ede 100644 --- a/dpdata/driver.py +++ b/dpdata/driver.py @@ -1,4 +1,5 @@ """Driver plugin system.""" + from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Callable, List, Union diff --git a/dpdata/format.py b/dpdata/format.py index 461d1ad68..c231ef729 100644 --- a/dpdata/format.py +++ b/dpdata/format.py @@ -1,4 +1,5 @@ """Implement the format plugin system.""" + import os from abc import ABC diff --git a/dpdata/system.py b/dpdata/system.py index a75e0e880..3be86ef48 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1334,9 +1334,7 @@ def __repr__(self): return self.__str__() def __str__(self): - return "MultiSystems ({} systems containing {} frames)".format( - len(self.systems), self.get_nframes() - ) + return f"MultiSystems ({len(self.systems)} systems containing {self.get_nframes()} frames)" def __add__(self, others): """Magic method "+" operation.""" diff --git a/dpdata/vasp/xml.py b/dpdata/vasp/xml.py index cf94bc8e7..a534fd0cf 100755 --- a/dpdata/vasp/xml.py +++ b/dpdata/vasp/xml.py @@ -68,14 +68,7 @@ def formulate_config(eles, types, posi, cell, ener, forc, strs_): ret += f"#Z {cell[2][0]:13.8f} {cell[2][1]:13.8f} {cell[2][2]:13.8f}\n" ret += "#W 1.0\n" ret += "#E %.10f\n" % (ener / natoms) - ret += "#S {:.9e} {:.9e} {:.9e} {:.9e} {:.9e} {:.9e}\n".format( - strs[0][0], - strs[1][1], - strs[2][2], - strs[0][1], - strs[1][2], - strs[0][2], - ) + ret += f"#S {strs[0][0]:.9e} {strs[1][1]:.9e} {strs[2][2]:.9e} {strs[0][1]:.9e} {strs[1][2]:.9e} {strs[0][2]:.9e}\n" ret += "#F\n" for ii in range(natoms): sp = np.matmul(cell.T, posi[ii]) diff --git a/dpdata/xyz/quip_gap_xyz.py b/dpdata/xyz/quip_gap_xyz.py index 8b3f164be..068bec1fb 100644 --- a/dpdata/xyz/quip_gap_xyz.py +++ b/dpdata/xyz/quip_gap_xyz.py @@ -36,9 +36,7 @@ def get_block_generator(self): lines.append(self.file_object.readline()) if not lines[-1]: raise RuntimeError( - "this xyz file may lack of lines, should be {};lines:{}".format( - atom_num + 2, lines - ) + f"this xyz file may lack of lines, should be {atom_num + 2};lines:{lines}" ) yield lines