Skip to content

Commit 7850c38

Browse files
Drop Python 3.9 (#105)
* Drop Python 3.9 * Drop Python 3.9 * Lint, add CodeCov token
1 parent 8775736 commit 7850c38

File tree

9 files changed

+85
-103
lines changed

9 files changed

+85
-103
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
python-version:
25-
- "3.9"
2625
- "3.10"
26+
- "3.11"
2727
os:
2828
- ubuntu-latest
2929
- macos-latest
@@ -36,13 +36,6 @@ jobs:
3636
steps:
3737
- uses: actions/checkout@v4
3838

39-
- name: Additional info about the build
40-
shell: bash
41-
run: |
42-
uname -a
43-
df -h
44-
ulimit -a
45-
4639
- name: Install dependencies
4740
if: ${{ matrix.toolkit == true }}
4841
uses: mamba-org/setup-micromamba@v1
@@ -61,10 +54,7 @@ jobs:
6154
6255
- name: Install package
6356
run: |
64-
micromamba remove --force openff-forcefields
6557
python -m pip install -e .
66-
conda list
67-
conda info --all
6858
6959
- name: Run water model tests
7060
if: ${{ matrix.toolkit == true }}
@@ -100,5 +90,6 @@ jobs:
10090
- name: Codecov
10191
uses: codecov/codecov-action@v4
10292
with:
93+
token: ${{ secrets.CODECOV_TOKEN }}
10394
file: ./coverage.xml
10495
fail_ci_if_error: false

.github/workflows/canary.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
python-version:
19-
- "3.9"
2019
- "3.10"
20+
- "3.11"
2121
cfg:
2222
- os: ubuntu-latest
2323
- os: macOS-latest

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ repos:
2323
rev: v3.15.2
2424
hooks:
2525
- id: pyupgrade
26-
exclude: openforcefields/_version.py|setup.py
26+
args: ["--py310-plus"]

openforcefields/_version.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
import re
1717
import subprocess
1818
import sys
19-
from typing import Any, Callable, Dict, List, Optional, Tuple
19+
from collections.abc import Callable
20+
from typing import Any
2021

2122

22-
def get_keywords() -> Dict[str, str]:
23+
def get_keywords() -> dict[str, str]:
2324
"""Get the keywords needed to look up the version information."""
2425
# these strings will be replaced by git during git-archive.
2526
# setup.py/versioneer.py will grep for the variable names, so they must
@@ -61,8 +62,8 @@ class NotThisMethod(Exception):
6162
"""Exception raised if a method is not valid for the current scenario."""
6263

6364

64-
LONG_VERSION_PY: Dict[str, str] = {}
65-
HANDLERS: Dict[str, Dict[str, Callable]] = {}
65+
LONG_VERSION_PY: dict[str, str] = {}
66+
HANDLERS: dict[str, dict[str, Callable]] = {}
6667

6768

6869
def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator
@@ -79,18 +80,18 @@ def decorate(f: Callable) -> Callable:
7980

8081

8182
def run_command(
82-
commands: List[str],
83-
args: List[str],
84-
cwd: Optional[str] = None,
83+
commands: list[str],
84+
args: list[str],
85+
cwd: str | None = None,
8586
verbose: bool = False,
8687
hide_stderr: bool = False,
87-
env: Optional[Dict[str, str]] = None,
88-
) -> Tuple[Optional[str], Optional[int]]:
88+
env: dict[str, str] | None = None,
89+
) -> tuple[str | None, int | None]:
8990
"""Call the given command(s)."""
9091
assert isinstance(commands, list)
9192
process = None
9293

93-
popen_kwargs: Dict[str, Any] = {}
94+
popen_kwargs: dict[str, Any] = {}
9495
if sys.platform == "win32":
9596
# This hides the console window if pythonw.exe is used
9697
startupinfo = subprocess.STARTUPINFO()
@@ -119,7 +120,7 @@ def run_command(
119120
return None, None
120121
else:
121122
if verbose:
122-
print("unable to find command, tried %s" % (commands,))
123+
print(f"unable to find command, tried {commands}")
123124
return None, None
124125
stdout = process.communicate()[0].strip().decode()
125126
if process.returncode != 0:
@@ -134,7 +135,7 @@ def versions_from_parentdir(
134135
parentdir_prefix: str,
135136
root: str,
136137
verbose: bool,
137-
) -> Dict[str, Any]:
138+
) -> dict[str, Any]:
138139
"""Try to determine the version from the parent directory name.
139140
140141
Source tarballs conventionally unpack into a directory that includes both
@@ -165,15 +166,15 @@ def versions_from_parentdir(
165166

166167

167168
@register_vcs_handler("git", "get_keywords")
168-
def git_get_keywords(versionfile_abs: str) -> Dict[str, str]:
169+
def git_get_keywords(versionfile_abs: str) -> dict[str, str]:
169170
"""Extract version information from the given file."""
170171
# the code embedded in _version.py can just fetch the value of these
171172
# keywords. When used from setup.py, we don't want to import _version.py,
172173
# so we do it with a regexp instead. This function is not used from
173174
# _version.py.
174-
keywords: Dict[str, str] = {}
175+
keywords: dict[str, str] = {}
175176
try:
176-
with open(versionfile_abs, "r") as fobj:
177+
with open(versionfile_abs) as fobj:
177178
for line in fobj:
178179
if line.strip().startswith("git_refnames ="):
179180
mo = re.search(r'=\s*"(.*)"', line)
@@ -194,10 +195,10 @@ def git_get_keywords(versionfile_abs: str) -> Dict[str, str]:
194195

195196
@register_vcs_handler("git", "keywords")
196197
def git_versions_from_keywords(
197-
keywords: Dict[str, str],
198+
keywords: dict[str, str],
198199
tag_prefix: str,
199200
verbose: bool,
200-
) -> Dict[str, Any]:
201+
) -> dict[str, Any]:
201202
"""Get version information from git keywords."""
202203
if "refnames" not in keywords:
203204
raise NotThisMethod("Short version file found")
@@ -270,7 +271,7 @@ def git_versions_from_keywords(
270271
@register_vcs_handler("git", "pieces_from_vcs")
271272
def git_pieces_from_vcs(
272273
tag_prefix: str, root: str, verbose: bool, runner: Callable = run_command
273-
) -> Dict[str, Any]:
274+
) -> dict[str, Any]:
274275
"""Get version from 'git describe' in the root of the source tree.
275276
276277
This only gets called if the git-archive 'subst' keywords were *not*
@@ -318,7 +319,7 @@ def git_pieces_from_vcs(
318319
raise NotThisMethod("'git rev-parse' failed")
319320
full_out = full_out.strip()
320321

321-
pieces: Dict[str, Any] = {}
322+
pieces: dict[str, Any] = {}
322323
pieces["long"] = full_out
323324
pieces["short"] = full_out[:7] # maybe improved later
324325
pieces["error"] = None
@@ -383,7 +384,7 @@ def git_pieces_from_vcs(
383384
if verbose:
384385
fmt = "tag '%s' doesn't start with prefix '%s'"
385386
print(fmt % (full_tag, tag_prefix))
386-
pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (
387+
pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format(
387388
full_tag,
388389
tag_prefix,
389390
)
@@ -417,14 +418,14 @@ def git_pieces_from_vcs(
417418
return pieces
418419

419420

420-
def plus_or_dot(pieces: Dict[str, Any]) -> str:
421+
def plus_or_dot(pieces: dict[str, Any]) -> str:
421422
"""Return a + if we don't already have one, else return a ."""
422423
if "+" in pieces.get("closest-tag", ""):
423424
return "."
424425
return "+"
425426

426427

427-
def render_pep440(pieces: Dict[str, Any]) -> str:
428+
def render_pep440(pieces: dict[str, Any]) -> str:
428429
"""Build up version string, with post-release "local version identifier".
429430
430431
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
@@ -448,7 +449,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str:
448449
return rendered
449450

450451

451-
def render_pep440_branch(pieces: Dict[str, Any]) -> str:
452+
def render_pep440_branch(pieces: dict[str, Any]) -> str:
452453
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
453454
454455
The ".dev0" means not master branch. Note that .dev0 sorts backwards
@@ -477,7 +478,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str:
477478
return rendered
478479

479480

480-
def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]:
481+
def pep440_split_post(ver: str) -> tuple[str, int | None]:
481482
"""Split pep440 version string at the post-release segment.
482483
483484
Returns the release segments before the post-release and the
@@ -487,7 +488,7 @@ def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]:
487488
return vc[0], int(vc[1] or 0) if len(vc) == 2 else None
488489

489490

490-
def render_pep440_pre(pieces: Dict[str, Any]) -> str:
491+
def render_pep440_pre(pieces: dict[str, Any]) -> str:
491492
"""TAG[.postN.devDISTANCE] -- No -dirty.
492493
493494
Exceptions:
@@ -511,7 +512,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str:
511512
return rendered
512513

513514

514-
def render_pep440_post(pieces: Dict[str, Any]) -> str:
515+
def render_pep440_post(pieces: dict[str, Any]) -> str:
515516
"""TAG[.postDISTANCE[.dev0]+gHEX] .
516517
517518
The ".dev0" means dirty. Note that .dev0 sorts backwards
@@ -538,7 +539,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str:
538539
return rendered
539540

540541

541-
def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
542+
def render_pep440_post_branch(pieces: dict[str, Any]) -> str:
542543
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
543544
544545
The ".dev0" means not master branch.
@@ -567,7 +568,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
567568
return rendered
568569

569570

570-
def render_pep440_old(pieces: Dict[str, Any]) -> str:
571+
def render_pep440_old(pieces: dict[str, Any]) -> str:
571572
"""TAG[.postDISTANCE[.dev0]] .
572573
573574
The ".dev0" means dirty.
@@ -589,7 +590,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str:
589590
return rendered
590591

591592

592-
def render_git_describe(pieces: Dict[str, Any]) -> str:
593+
def render_git_describe(pieces: dict[str, Any]) -> str:
593594
"""TAG[-DISTANCE-gHEX][-dirty].
594595
595596
Like 'git describe --tags --dirty --always'.
@@ -609,7 +610,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str:
609610
return rendered
610611

611612

612-
def render_git_describe_long(pieces: Dict[str, Any]) -> str:
613+
def render_git_describe_long(pieces: dict[str, Any]) -> str:
613614
"""TAG-DISTANCE-gHEX[-dirty].
614615
615616
Like 'git describe --tags --dirty --always -long'.
@@ -629,7 +630,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str:
629630
return rendered
630631

631632

632-
def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]:
633+
def render(pieces: dict[str, Any], style: str) -> dict[str, Any]:
633634
"""Render the given version pieces into the requested style."""
634635
if pieces["error"]:
635636
return {
@@ -671,7 +672,7 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]:
671672
}
672673

673674

674-
def get_versions() -> Dict[str, Any]:
675+
def get_versions() -> dict[str, Any]:
675676
"""Get version information or return default if unable to do so."""
676677
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
677678
# __file__, we can work backwards from there to the root. Some

openforcefields/tests/compare.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import Dict
2-
31
import openmm
42
import openmm.unit
53

64

75
def _compare(
86
system1: openmm.System,
97
system2: openmm.System,
10-
tolerances: Dict[str, openmm.unit.Quantity],
8+
tolerances: dict[str, openmm.unit.Quantity],
119
):
1210
"""Check that two OpenMM systems have the same parameters.
1311
@@ -39,7 +37,7 @@ def _compare(
3937
def _compare_nonbonded_forces(
4038
force1: openmm.NonbondedForce,
4139
force2: openmm.NonbondedForce,
42-
tolerances: Dict[str, openmm.unit.Quantity],
40+
tolerances: dict[str, openmm.unit.Quantity],
4341
):
4442
assert force1.getNumParticles() == force2.getNumParticles()
4543

openforcefields/tests/test_water_models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Dict
2-
31
import numpy
42
import openmm
53
import openmm.unit
@@ -62,7 +60,7 @@ def opc_positions() -> Molecule:
6260
def compare_water_systems(
6361
reference: openmm.System,
6462
system: openmm.System,
65-
tolerances: Dict[str, openmm.unit.Quantity],
63+
tolerances: dict[str, openmm.unit.Quantity],
6664
):
6765
# OpenMM creates bond and angle forces despite each containing 0 parameters
6866
for index, force in enumerate(reference.getForces()):

scripts/write_tip3p.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Dict
2-
31
import pandas
42
from openff.toolkit.typing.engines.smirnoff.forcefield import ForceField
53
from openff.toolkit.typing.engines.smirnoff.parameters import (
@@ -55,7 +53,7 @@
5553
}
5654
)
5755

58-
element_to_atomic_number: Dict[str, int] = {
56+
element_to_atomic_number: dict[str, int] = {
5957
"Li": 3,
6058
"Na": 11,
6159
"K": 19,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
short_description = __doc__.split("\n")
1010

11-
with open("README.md", "r") as handle:
11+
with open("README.md") as handle:
1212
long_description = handle.read()
1313

1414

0 commit comments

Comments
 (0)