From 3f148c16b25d09a5c4d084cef76a61f8e2629bdc Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 10:56:27 +0200 Subject: [PATCH 1/6] Black update --- .pre-commit-config.yaml | 6 +++--- Makefile | 2 +- pyproject.toml | 6 +++--- turtlemd/__init__.py | 1 + turtlemd/integrators.py | 1 + turtlemd/potentials/lennardjones.py | 1 + turtlemd/potentials/potential.py | 1 + turtlemd/potentials/well.py | 5 ++--- turtlemd/simulation/mdsimulation.py | 1 + turtlemd/simulation/stopping.py | 1 + turtlemd/system/__init__.py | 1 + turtlemd/system/box.py | 1 + turtlemd/system/particles.py | 1 + turtlemd/system/system.py | 1 + turtlemd/tools/tools.py | 1 + turtlemd/tools/xyz.py | 1 + turtlemd/version.py | 1 + 17 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c2e91f..71531e8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ repos: - - repo: https://github.com/psf/black - rev: 23.7.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 25.9.0 hooks: - id: black-jupyter # It is recommended to specify the latest version of Python # supported by your project here, or alternatively use # pre-commit's default_language_version, see # https://pre-commit.com/#top_level-default_language_version - language_version: python3.11 + language_version: python3.14 diff --git a/Makefile b/Makefile index ce3a2ca..4a2f64e 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ coverage-print: pytest --cov-report html --cov=turtlemd -rP tests/ ruff: - poetry run ruff turtlemd + poetry run ruff check turtlemd black: poetry run black --check turtlemd diff --git a/pyproject.toml b/pyproject.toml index bf51ae2..0268633 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "turtlemd" -version = "2023.3.1" +version = "2025.1" description = "A slow molecular dynamics library for testing" authors = [ "Daniel Zhang ", @@ -11,7 +11,7 @@ license = "MIT" readme = "README.md" [tool.poetry.dependencies] -python = ">=3.10,<3.13" +python = ">=3.10,<3.15" numpy = "^1.24.2" [tool.poetry.group.dev.dependencies] @@ -32,7 +32,7 @@ ignore-init-module-imports = true [tool.black] line-length = 79 -target-version = ["py310", "py311", "py312"] +target-version = ["py310", "py311", "py312", "py313", "py314"] [tool.mypy] warn_unused_ignores = true diff --git a/turtlemd/__init__.py b/turtlemd/__init__.py index dcc288f..6855294 100644 --- a/turtlemd/__init__.py +++ b/turtlemd/__init__.py @@ -1,4 +1,5 @@ """TurtleMD is a slow MD library for testing.""" + from .version import __version__ __all__ = ["__version__"] diff --git a/turtlemd/integrators.py b/turtlemd/integrators.py index b72f4ca..f25fb48 100644 --- a/turtlemd/integrators.py +++ b/turtlemd/integrators.py @@ -1,4 +1,5 @@ """Definition of time integrators.""" + import logging from abc import ABC, abstractmethod from dataclasses import dataclass, field diff --git a/turtlemd/potentials/lennardjones.py b/turtlemd/potentials/lennardjones.py index 987591f..bddcf44 100644 --- a/turtlemd/potentials/lennardjones.py +++ b/turtlemd/potentials/lennardjones.py @@ -1,4 +1,5 @@ """Module defining a Lennard-Jones pair potential.""" + import itertools import logging from typing import Any diff --git a/turtlemd/potentials/potential.py b/turtlemd/potentials/potential.py index bef810f..4c63422 100644 --- a/turtlemd/potentials/potential.py +++ b/turtlemd/potentials/potential.py @@ -3,6 +3,7 @@ This module defines the generic class for potential functions. This class is sub-classed in all potential functions. """ + from __future__ import annotations import logging diff --git a/turtlemd/potentials/well.py b/turtlemd/potentials/well.py index 17bc8f5..4ca4971 100644 --- a/turtlemd/potentials/well.py +++ b/turtlemd/potentials/well.py @@ -12,6 +12,7 @@ * DoubleWellPair (:py:class:`.DoubleWellPair`) This class defines a double well pair potential. """ + import logging import numpy as np @@ -276,9 +277,7 @@ def force(self, system: System) -> tuple[np.ndarray, np.ndarray]: delta = box.pbc_dist(particles.pos[i] - particles.pos[j]) delr = np.sqrt(np.dot(delta, delta)) diff = delr - rwidth - forceij = ( - height4 * (1.0 - diff**2 / width2) * (diff / width2) - ) + forceij = height4 * (1.0 - diff**2 / width2) * (diff / width2) forceij = forceij * delta / delr forces[i] += forceij forces[j] -= forceij diff --git a/turtlemd/simulation/mdsimulation.py b/turtlemd/simulation/mdsimulation.py index 392ba92..ae5bb29 100644 --- a/turtlemd/simulation/mdsimulation.py +++ b/turtlemd/simulation/mdsimulation.py @@ -1,4 +1,5 @@ """Definition of a simulation.""" + from __future__ import annotations import logging diff --git a/turtlemd/simulation/stopping.py b/turtlemd/simulation/stopping.py index e4f924e..03fafb7 100644 --- a/turtlemd/simulation/stopping.py +++ b/turtlemd/simulation/stopping.py @@ -1,4 +1,5 @@ """Definitions for stopping a simulation.""" + from __future__ import annotations import logging diff --git a/turtlemd/system/__init__.py b/turtlemd/system/__init__.py index a4a5439..66fba14 100644 --- a/turtlemd/system/__init__.py +++ b/turtlemd/system/__init__.py @@ -1,4 +1,5 @@ """For importing the most commonly used system methods.""" + from .box import Box from .particles import Particles from .system import System diff --git a/turtlemd/system/box.py b/turtlemd/system/box.py index 05b3db0..0ed548c 100644 --- a/turtlemd/system/box.py +++ b/turtlemd/system/box.py @@ -1,4 +1,5 @@ """Define a simulation box.""" + import itertools import logging from abc import ABC, abstractmethod diff --git a/turtlemd/system/particles.py b/turtlemd/system/particles.py index 46458b4..da208f1 100644 --- a/turtlemd/system/particles.py +++ b/turtlemd/system/particles.py @@ -3,6 +3,7 @@ Tha particle list collects the mass, positions, velocities, forces, types, etc. for a collection of particles. """ + from collections.abc import Iterator from typing import SupportsIndex diff --git a/turtlemd/system/system.py b/turtlemd/system/system.py index fc9ee7e..07e974b 100644 --- a/turtlemd/system/system.py +++ b/turtlemd/system/system.py @@ -1,4 +1,5 @@ """Definition of the simulation system.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any, TypedDict diff --git a/turtlemd/tools/tools.py b/turtlemd/tools/tools.py index fdb2173..8fa0456 100644 --- a/turtlemd/tools/tools.py +++ b/turtlemd/tools/tools.py @@ -1,4 +1,5 @@ """Some helper methods for setting up simulations.""" + import itertools import numpy as np diff --git a/turtlemd/tools/xyz.py b/turtlemd/tools/xyz.py index 2fd68df..3479e3f 100644 --- a/turtlemd/tools/xyz.py +++ b/turtlemd/tools/xyz.py @@ -1,4 +1,5 @@ """Methods to read particles from xyz-files.""" + import logging import pathlib from collections.abc import Iterator diff --git a/turtlemd/version.py b/turtlemd/version.py index 41e9640..6001bfa 100644 --- a/turtlemd/version.py +++ b/turtlemd/version.py @@ -1,4 +1,5 @@ """Version information.""" + from importlib import metadata __version__ = metadata.version("turtlemd") From 002be025f9bdf1d49fd4d3b15620adb7e002623a Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 11:09:15 +0200 Subject: [PATCH 2/6] Updated the lining section for ruff --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0268633..a6a1cfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,8 +27,9 @@ flake8 = "^6.0.0" [tool.ruff] line-length = 79 + +[tool.ruff.lint] select = ["F", "E", "W", "I001", "UP"] -ignore-init-module-imports = true [tool.black] line-length = 79 From b7c755d32c9bb48c546d8d1c257ee07053029a87 Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 11:16:35 +0200 Subject: [PATCH 3/6] Removed support for old Python versions. --- .github/workflows/coverage.yaml | 2 +- .github/workflows/lint-and-type.yaml | 2 +- .github/workflows/test.yaml | 2 +- pyproject.toml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 7cbd409..9675e57 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -23,7 +23,7 @@ jobs: id: setuppy uses: actions/setup-python@v4 with: - python-version: "3.12" + python-version: "3.14" - name: "Set up Poetry" uses: abatilo/actions-poetry@v2 diff --git a/.github/workflows/lint-and-type.yaml b/.github/workflows/lint-and-type.yaml index 6f55b2d..ac0fe82 100644 --- a/.github/workflows/lint-and-type.yaml +++ b/.github/workflows/lint-and-type.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ["3.14"] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8062abc..40e43a8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.12", "3.13", "3.14"] runs-on: ubuntu-latest steps: diff --git a/pyproject.toml b/pyproject.toml index a6a1cfb..5ce30b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ license = "MIT" readme = "README.md" [tool.poetry.dependencies] -python = ">=3.10,<3.15" +python = ">=3.12,<3.15" numpy = "^1.24.2" [tool.poetry.group.dev.dependencies] @@ -33,7 +33,7 @@ select = ["F", "E", "W", "I001", "UP"] [tool.black] line-length = 79 -target-version = ["py310", "py311", "py312", "py313", "py314"] +target-version = ["py312", "py313", "py314"] [tool.mypy] warn_unused_ignores = true From 2eb37aacb69e38d1d6858561d7372bdbf15e228b Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 11:33:18 +0200 Subject: [PATCH 4/6] Update ruff command. --- .github/workflows/lint-and-type.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-type.yaml b/.github/workflows/lint-and-type.yaml index ac0fe82..b39661d 100644 --- a/.github/workflows/lint-and-type.yaml +++ b/.github/workflows/lint-and-type.yaml @@ -48,7 +48,7 @@ jobs: run: poetry run black --check turtlemd - name: "Run ruff" - run: poetry run ruff turtlemd + run: poetry run ruff check turtlemd - name: "Run mypy" run: poetry run mypy turtlemd From b171efda42725a47185d7a3290a2328c3c319998 Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 11:35:33 +0200 Subject: [PATCH 5/6] Updated the black version. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5ce30b6..e71206d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ numpy = "^1.24.2" [tool.poetry.group.dev.dependencies] ruff = "^0.0.261" -black = "^23.3.0" +black = "^25.9.0" mypy = "^1.2.0" pytest = "^7.3.1" pytest-cov = "^4.0.0" From 36649b52071d3c106f8fad23dee8e8635ee98d34 Mon Sep 17 00:00:00 2001 From: Anders Lervik Date: Thu, 9 Oct 2025 11:40:27 +0200 Subject: [PATCH 6/6] Updated version of mypy and ruff --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e71206d..30d5773 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,9 +15,9 @@ python = ">=3.12,<3.15" numpy = "^1.24.2" [tool.poetry.group.dev.dependencies] -ruff = "^0.0.261" +ruff = "^0.14.0" black = "^25.9.0" -mypy = "^1.2.0" +mypy = "^1.18.0" pytest = "^7.3.1" pytest-cov = "^4.0.0" pytest-randomly = "^3.12.0"