Skip to content

Commit

Permalink
Add ruff-precommit, remove pydocstyle (#138)
Browse files Browse the repository at this point in the history
* add ruff changes

* remove import *

* change max line length back to 80
  • Loading branch information
chrisjonesBSU authored May 16, 2024
1 parent 0245f75 commit fbb3ad1
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand All @@ -26,6 +25,7 @@ on:

jobs:
pytest:
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
Expand Down
30 changes: 7 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
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:
- id: check-yaml
- 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:
Expand All @@ -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 ]
1 change: 1 addition & 0 deletions flowermd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""flowerMD package."""

from .base import (
Expand Down
1 change: 1 addition & 0 deletions flowermd/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Paths to the assets used by flowerMD."""

from .forcefields import FF_DIR
Expand Down
1 change: 1 addition & 0 deletions flowermd/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Base classes for flowerMD."""

from .forcefield import BaseHOOMDForcefield, BaseXMLForcefield
Expand Down
8 changes: 4 additions & 4 deletions flowermd/base/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions flowermd/internal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# ruff: noqa: F401
from .ff_utils import xml_to_gmso_ff
from .utils import check_return_iterable, validate_ref_value
1 change: 1 addition & 0 deletions flowermd/library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Library of predefined molecules, recipes and forcefields."""

from .forcefields import (
Expand Down
1 change: 1 addition & 0 deletions flowermd/modules/surface_wetting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Surface wetting module for FlowerMD."""

from .surface_wetting import (
Expand Down
1 change: 1 addition & 0 deletions flowermd/modules/welding/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Welding module for FlowerMD."""

from .utils import add_void_particles
Expand Down
1 change: 1 addition & 0 deletions flowermd/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# ruff: noqa: F401
from .base_test import BaseTest
6 changes: 3 additions & 3 deletions flowermd/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion flowermd/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down

0 comments on commit fbb3ad1

Please sign in to comment.