Skip to content

Commit

Permalink
Merge pull request #1116 from openforcefield/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
mattwthompson authored Nov 26, 2024
2 parents dec585e + 695fafe commit 41bfb6c
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 40 deletions.
16 changes: 3 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ repos:
hooks:
- id: add-trailing-comma
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.0
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/econchick/interrogate
rev: 1.7.0
Expand All @@ -28,22 +29,11 @@ repos:
- id: blacken-docs
files: ^docs/
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.43.0
hooks:
- id: markdownlint
exclude: .github
args: ["--disable", "MD013", "MD033", "MD024", "MD046", "--ignore", "docs/using/experimental.md", "--ignore", "docs/using/status.md", "--"]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-pyupgrade
files: ^examples
args:
- --py310-plus
- id: nbqa-ruff
files: ^examples
args:
- --fix
- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
hooks:
Expand Down
4 changes: 2 additions & 2 deletions openff/interchange/_tests/_openmm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import defaultdict
from typing import TYPE_CHECKING, DefaultDict
from typing import TYPE_CHECKING

from openff.utilities.utilities import has_package, requires_package

Expand Down Expand Up @@ -37,7 +37,7 @@ def get_14_scaling_factors(omm_sys: "openmm.System") -> tuple[list, list]:


def _create_torsion_dict(torsion_force) -> dict[tuple[int], list[tuple]]:
torsions: DefaultDict = defaultdict(list)
torsions = defaultdict(list)

for i in range(torsion_force.getNumTorsions()):
p1, p2, p3, p4, periodicity, phase, k = torsion_force.getTorsionParameters(i)
Expand Down
6 changes: 3 additions & 3 deletions openff/interchange/components/interchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def from_smirnoff(
----------
force_field : `openff.toolkit.ForceField`
The force field to parameterize the topology with.
topology : `openff.toolkit.Topology` or `List[openff.toolkit.Molecule]`
topology : `openff.toolkit.Topology` or `list[openff.toolkit.Molecule]`
The topology to parameterize, or a list of molecules to construct a
topology from and parameterize.
box : `openff.units.Quantity`, optional
Expand All @@ -109,14 +109,14 @@ def from_smirnoff(
positions : `openff.units.Quantity`, optional
The positions associated with atoms in the input topology. If ``None``,
positions are taken from the molecules in topology, if present on all molecules.
charge_from_molecules : `List[openff.toolkit.molecule.Molecule]`, optional
charge_from_molecules : `list[openff.toolkit.molecule.Molecule]`, optional
If specified, partial charges for any molecules isomorphic to those
given will be taken from the given molecules' `partial_charges`
attribute instead of being determined by the force field. All
molecules in this list must have partial charges assigned and must
not be isomorphic with any other molecules in the list. For all values
of this argument, charges on the input topology are ignored.
partial_bond_orders_from_molecules : List[openff.toolkit.molecule.Molecule], optional
partial_bond_orders_from_molecules : list[openff.toolkit.molecule.Molecule], optional
If specified, partial bond orders will be taken from the given molecules
instead of being determined by the force field.
allow_nonintegral_charges : bool, optional, default=False
Expand Down
6 changes: 3 additions & 3 deletions openff/interchange/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from openff.interchange.drivers.openmm import get_openmm_energies

__all__ = [
"get_openmm_energies",
"get_all_energies",
"get_amber_energies",
"get_gromacs_energies",
"get_lammps_energies",
"get_amber_energies",
"get_all_energies",
"get_openmm_energies",
"get_summary_data",
]
2 changes: 1 addition & 1 deletion openff/interchange/drivers/amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _run_sander(
Returns
-------
energies: Dict[str, Quantity]
energies: dict[str, Quantity]
A dictionary of energies, keyed by the GROMACS energy term name.
"""
Expand Down
2 changes: 1 addition & 1 deletion openff/interchange/drivers/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _run_gmx_energy(
Returns
-------
energies: Dict[str, Quantity]
energies: dict[str, Quantity]
A dictionary of energies, keyed by the GROMACS energy term name.
"""
Expand Down
3 changes: 1 addition & 2 deletions openff/interchange/interop/_virtual_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from collections import defaultdict
from typing import DefaultDict

import numpy
from openff.toolkit import Quantity, unit
Expand Down Expand Up @@ -75,7 +74,7 @@ def get_positions_with_virtual_sites(
raise MissingVirtualSitesError()

# map of molecule index to *list* of virtual site keys contained therein
molecule_virtual_site_map: DefaultDict[int, list[VirtualSiteKey]] = defaultdict(
molecule_virtual_site_map: defaultdict[int, list[VirtualSiteKey]] = defaultdict(
list,
)

Expand Down
4 changes: 2 additions & 2 deletions openff/interchange/interop/openmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from openff.interchange import Interchange

__all__ = [
"from_openmm",
"to_openmm",
"to_openmm_topology",
"to_openmm_positions",
"from_openmm",
"to_openmm_topology",
]


Expand Down
10 changes: 5 additions & 5 deletions openff/interchange/interop/openmm/_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import itertools
import warnings
from collections import defaultdict
from typing import DefaultDict, NamedTuple
from typing import NamedTuple

from openff.toolkit import Molecule, Quantity, unit
from openff.units.openmm import to_openmm as to_openmm_quantity
Expand Down Expand Up @@ -105,7 +105,7 @@ def _process_nonbonded_forces(

# Mapping between OpenFF "particles" and OpenMM particles (via index). OpenFF objects
# (keys) are either atom indices (if atoms) or `VirtualSiteKey`s if virtual sites
# openff_openmm_particle_map: Dict[Union[int, VirtualSiteKey], int] = dict()
# openff_openmm_particle_map: dict[Union[int, VirtualSiteKey], int] = dict()
openff_openmm_particle_map = _add_particles_to_system(
interchange,
system,
Expand Down Expand Up @@ -372,7 +372,7 @@ def _create_single_nonbonded_force(
# mapping between (openmm) index of each atom and the (openmm) index of each virtual particle
# of that parent atom (if any)
# if no virtual sites at all, this remains an empty dict
parent_virtual_particle_mapping: DefaultDict[int, list[int]] = defaultdict(list)
parent_virtual_particle_mapping: defaultdict[int, list[int]] = defaultdict(list)

vdw = data.vdw_collection

Expand Down Expand Up @@ -484,7 +484,7 @@ def _create_exceptions(
non_bonded_force: openmm.NonbondedForce,
interchange: "Interchange",
openff_openmm_particle_map: dict,
parent_virtual_particle_mapping: DefaultDict[int, list[int]],
parent_virtual_particle_mapping: defaultdict[int, list[int]],
):
# The topology indices reported by toolkit methods must be converted to openmm indices
bonds = [
Expand Down Expand Up @@ -849,7 +849,7 @@ def _create_electrostatics_force(
# mapping between (openmm) index of each atom and the (openmm) index of each virtual particle
# of that parent atom (if any)
# if no virtual sites at all, this remains an empty dict
parent_virtual_particle_mapping: DefaultDict[int, list[int]] = defaultdict(list)
parent_virtual_particle_mapping: defaultdict[int, list[int]] = defaultdict(list)

for molecule in interchange.topology.molecules:
for _ in molecule.atoms:
Expand Down
14 changes: 9 additions & 5 deletions openff/interchange/smirnoff/_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import logging
import warnings
from collections.abc import Iterable
from typing import Any, Literal, Optional, Union
from typing import Literal, Union

import numpy
from openff.toolkit import Molecule, Quantity, Topology, unit
from openff.toolkit.typing.engines.smirnoff.parameters import (
ChargeIncrementModelHandler,
ElectrostaticsHandler,
LibraryChargeHandler,
ParameterHandler,
ToolkitAM1BCCHandler,
vdWHandler,
)
Expand Down Expand Up @@ -276,7 +277,10 @@ class SMIRNOFFElectrostaticsCollection(ElectrostaticsCollection, SMIRNOFFCollect
) # type: ignore[assignment]
exception_potential: Literal["Coulomb"] = Field("Coulomb")

_charges: dict[Any, _ElementaryChargeQuantity] = PrivateAttr(dict())
_charges: dict[
TopologyKey | LibraryChargeTopologyKey | VirtualSiteKey,
_ElementaryChargeQuantity,
] = PrivateAttr(dict())
_charges_cached: bool = PrivateAttr(default=False)

@classmethod
Expand Down Expand Up @@ -402,7 +406,7 @@ def _get_charges(
)

logger.info(
"Charge section ChargeIncrementModel, applying charge increment from atom "
"Charge section ChargeIncrementModel, applying charge increment from atom " # type: ignore[union-attr]
f"{topology_key.this_atom_index} to atoms {topology_key.other_atom_indices}",
)

Expand Down Expand Up @@ -436,7 +440,7 @@ def parameter_handler_precedence(cls) -> list[str]:
@classmethod
def create(
cls,
parameter_handler: Any,
parameter_handler: ParameterHandler | list[ParameterHandler],
topology: Topology,
molecules_with_preset_charges=None,
allow_nonintegral_charges: bool = False,
Expand Down Expand Up @@ -807,7 +811,7 @@ def _assign_charges_from_molecules(
cls,
topology: Topology,
unique_molecule: Molecule,
molecules_with_preset_charges=Optional[list[Molecule]],
molecules_with_preset_charges=list[Molecule] | None,
) -> tuple[bool, dict, dict]:
if molecules_with_preset_charges is None:
return False, dict(), dict()
Expand Down
3 changes: 2 additions & 1 deletion stubs/mbuild/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

class Particle:
def __init__(self, name: str | None) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/mdtraj/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Generator
from collections.abc import Generator
from typing import Any

import numpy
import pandas
Expand Down
2 changes: 1 addition & 1 deletion stubs/nglview/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable

class NGLWidget:
def __init__(
Expand Down

0 comments on commit 41bfb6c

Please sign in to comment.