From fbb3ad1442bd09cfc7d6d08c23c93046a94643e9 Mon Sep 17 00:00:00 2001 From: Chris Jones <50423140+chrisjonesBSU@users.noreply.github.com> Date: Wed, 15 May 2024 21:07:06 -0600 Subject: [PATCH] Add ruff-precommit, remove pydocstyle (#138) * add ruff changes * remove import * * change max line length back to 80 --- .github/workflows/pytest.yml | 2 +- .pre-commit-config.yaml | 30 +++++--------------- flowermd/__init__.py | 1 + flowermd/assets/__init__.py | 1 + flowermd/base/__init__.py | 1 + flowermd/base/molecule.py | 8 +++--- flowermd/internal/__init__.py | 1 + flowermd/library/__init__.py | 1 + flowermd/modules/surface_wetting/__init__.py | 1 + flowermd/modules/welding/__init__.py | 1 + flowermd/tests/__init__.py | 1 + flowermd/tests/base_test.py | 6 ++-- flowermd/utils/__init__.py | 11 ++++++- 13 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 3c08cfb4..284423a0 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,7 +2,6 @@ name: pytest on: push: - # Action will run when any changes to these paths are pushed or pr'ed to master branches: [ main ] paths: - flowermd/** @@ -26,6 +25,7 @@ on: jobs: pytest: + if: github.event.pull_request.draft == false strategy: fail-fast: false matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63a4ad32..6461d9c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,20 @@ ci: autofix_commit_msg: | [pre-commit.ci] auto fixes from pre-commit.com hooks - for more information, see https://pre-commit.ci autofix_prs: true autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: weekly skip: [ ] submodules: false - repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.2 # Ruff version + hooks: + - id: ruff + args: [--fix, --extend-ignore=E203] + - id: ruff-format + args: [ --line-length=80 ] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: @@ -17,11 +22,6 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace exclude: 'flowermd/tests/assets/.* | flowermd/assets/.*' - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - args: [ --line-length=80 ] - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: @@ -30,19 +30,3 @@ repos: args: [ --profile=black, --line-length=80 ] exclude: 'flowermd/tests/assets/.* ' - - - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - args: - - --max-line-length=80 - - --extend-ignore=E203 - exclude: '__init__.py' - - - repo: https://github.com/pycqa/pydocstyle - rev: '6.3.0' - hooks: - - id: pydocstyle - exclude: ^(flowermd/tests/|flowermd/internal/|flowermd/utils|setup.py|flowermd/__version__.py|docs/) - args: [ --convention=numpy ] diff --git a/flowermd/__init__.py b/flowermd/__init__.py index e0995a2c..f8c66533 100644 --- a/flowermd/__init__.py +++ b/flowermd/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """flowerMD package.""" from .base import ( diff --git a/flowermd/assets/__init__.py b/flowermd/assets/__init__.py index 7a63aa3f..dd30075b 100644 --- a/flowermd/assets/__init__.py +++ b/flowermd/assets/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """Paths to the assets used by flowerMD.""" from .forcefields import FF_DIR diff --git a/flowermd/base/__init__.py b/flowermd/base/__init__.py index 4376da88..14c369e0 100644 --- a/flowermd/base/__init__.py +++ b/flowermd/base/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """Base classes for flowerMD.""" from .forcefield import BaseHOOMDForcefield, BaseXMLForcefield diff --git a/flowermd/base/molecule.py b/flowermd/base/molecule.py index 840d32b9..298f5f1d 100644 --- a/flowermd/base/molecule.py +++ b/flowermd/base/molecule.py @@ -314,7 +314,7 @@ def _identify_bond_types(self, gmso_molecule): or bond.connection_members[1].name ) bond_connections = [p1_name, p2_name] - if not tuple(bond_connections[::-1]) in self.bond_types: + if tuple(bond_connections[::-1]) not in self.bond_types: self.bond_types.add(tuple(bond_connections)) def _identify_angle_types(self, gmso_molecule): @@ -341,7 +341,7 @@ def _identify_angle_types(self, gmso_molecule): or angle.connection_members[2].name ) angle_connections = [p1_name, p2_name, p3_name] - if not tuple(angle_connections[::-1]) in self.angle_types: + if tuple(angle_connections[::-1]) not in self.angle_types: self.angle_types.add(tuple(angle_connections)) def _identify_dihedral_types(self, gmso_molecule): @@ -372,7 +372,7 @@ def _identify_dihedral_types(self, gmso_molecule): or dihedral.connection_members[3].name ) dihedral_connections = [p1_name, p2_name, p3_name, p4_name] - if not tuple(dihedral_connections[::-1]) in self.dihedral_types: + if tuple(dihedral_connections[::-1]) not in self.dihedral_types: self.dihedral_types.add(tuple(dihedral_connections)) def _identify_improper_types(self, gmso_molecule): @@ -403,7 +403,7 @@ def _identify_improper_types(self, gmso_molecule): or improper.connection_members[3].name ) improper_connections = [p1_name, p2_name, p3_name, p4_name] - if not tuple(improper_connections[::-1]) in self.improper_types: + if tuple(improper_connections[::-1]) not in self.improper_types: self.improper_types.add(tuple(improper_connections)) def _identify_topology_information(self, gmso_molecule): diff --git a/flowermd/internal/__init__.py b/flowermd/internal/__init__.py index d449c3b3..a06e7713 100644 --- a/flowermd/internal/__init__.py +++ b/flowermd/internal/__init__.py @@ -1,2 +1,3 @@ +# ruff: noqa: F401 from .ff_utils import xml_to_gmso_ff from .utils import check_return_iterable, validate_ref_value diff --git a/flowermd/library/__init__.py b/flowermd/library/__init__.py index 64ea7c0d..d57a1bc2 100644 --- a/flowermd/library/__init__.py +++ b/flowermd/library/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """Library of predefined molecules, recipes and forcefields.""" from .forcefields import ( diff --git a/flowermd/modules/surface_wetting/__init__.py b/flowermd/modules/surface_wetting/__init__.py index b5a838ef..2c194ea0 100644 --- a/flowermd/modules/surface_wetting/__init__.py +++ b/flowermd/modules/surface_wetting/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """Surface wetting module for FlowerMD.""" from .surface_wetting import ( diff --git a/flowermd/modules/welding/__init__.py b/flowermd/modules/welding/__init__.py index d927c0a6..4768054a 100644 --- a/flowermd/modules/welding/__init__.py +++ b/flowermd/modules/welding/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F401 """Welding module for FlowerMD.""" from .utils import add_void_particles diff --git a/flowermd/tests/__init__.py b/flowermd/tests/__init__.py index 9eb4c5fb..2bb6e9cb 100644 --- a/flowermd/tests/__init__.py +++ b/flowermd/tests/__init__.py @@ -1 +1,2 @@ +# ruff: noqa: F401 from .base_test import BaseTest diff --git a/flowermd/tests/base_test.py b/flowermd/tests/base_test.py index b9637c3c..3a70949d 100644 --- a/flowermd/tests/base_test.py +++ b/flowermd/tests/base_test.py @@ -169,7 +169,7 @@ def __init__(self, lengths, num_mols, **kwargs): bond_indices=bond_indices, bond_length=bond_length, bond_orientation=bond_orientation, - **kwargs + **kwargs, ) return _PolyEthylene @@ -189,7 +189,7 @@ def __init__(self, lengths, num_mols, **kwargs): bond_indices=bond_indices, bond_length=bond_length, bond_orientation=bond_orientation, - **kwargs + **kwargs, ) return _PPS @@ -209,7 +209,7 @@ def __init__(self, lengths, num_mols, **kwargs): bond_indices=bond_indices, bond_length=bond_length, bond_orientation=bond_orientation, - **kwargs + **kwargs, ) return _PolyDME diff --git a/flowermd/utils/__init__.py b/flowermd/utils/__init__.py index f3e56cb6..5915613c 100644 --- a/flowermd/utils/__init__.py +++ b/flowermd/utils/__init__.py @@ -1,4 +1,13 @@ -from .actions import * +# ruff: noqa: F401 +"""Helpful utility functions for use with flowerMD.""" + +from .actions import ( + PullParticles, + ScaleEpsilon, + ScaleSigma, + StdOutLogger, + UpdateWalls, +) from .base_types import HOOMDThermostats from .rigid_body import create_rigid_body from .utils import (