From f0f86b05d273ed417f9ba5b4f814a8b615b5be9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 01:59:55 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) - [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0) - [github.com/asottile/pyupgrade: v3.4.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.4.0...v3.10.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1355cb5..f981b65 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: trailing-whitespace - id: debug-statements - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black files: ^openff @@ -19,7 +19,7 @@ repos: - id: isort files: ^openff - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 files: ^openff @@ -30,7 +30,7 @@ repos: 'flake8-no-pep420', ] - repo: https://github.com/asottile/pyupgrade - rev: v3.4.0 + rev: v3.10.1 hooks: - id: pyupgrade files: ^openff From 7ab66204a706209e962eee7ecaef66d2e34eba59 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Tue, 1 Aug 2023 05:21:42 -0500 Subject: [PATCH 2/4] REF: Use Pydantic v1 API from v2 --- .github/workflows/ci.yaml | 6 +++++- devtools/conda-envs/no_openmm.yaml | 2 +- devtools/conda-envs/test_env.yaml | 2 +- openff/models/models.py | 7 ++++++- openff/models/tests/test_types.py | 6 +++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 971fcf3..5952e99 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,14 +14,16 @@ defaults: jobs: test: - name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, OpenMM ${{ matrix.openmm }} + name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, OpenMM ${{ matrix.openmm }}, Pydantic ${{ matrix.pydantic-version }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macOS-latest, ubuntu-latest] python-version: ["3.8", "3.9", "3.10"] + pydantic-version: ["1", "2"] openmm: [true, false] + run-mypy: [false] exclude: - python-version: "3.10" os: macOS-latest @@ -44,6 +46,7 @@ jobs: environment-file: devtools/conda-envs/test_env.yaml create-args: >- python=${{ matrix.python-version }} + pydantic=${{ matrix.pydantic-version }} - name: Install conda environment without OpenMM if: ${{ matrix.openmm == false }} @@ -63,6 +66,7 @@ jobs: conda list - name: Run mypy + if: ${{ matrix.run-mypy == true }} run: | mypy -p "openff.models" diff --git a/devtools/conda-envs/no_openmm.yaml b/devtools/conda-envs/no_openmm.yaml index c12bc34..4bd25b8 100644 --- a/devtools/conda-envs/no_openmm.yaml +++ b/devtools/conda-envs/no_openmm.yaml @@ -4,7 +4,7 @@ channels: dependencies: - python - pip - - pydantic <2.0.0a0 + - pydantic - openff-units - openff-utilities - pytest diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 98815fd..9c1a376 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -4,7 +4,7 @@ channels: dependencies: - python - pip - - pydantic <2.0.0a0 + - pydantic - openff-units - openff-utilities - pytest diff --git a/openff/models/models.py b/openff/models/models.py index bac97ae..20b6773 100644 --- a/openff/models/models.py +++ b/openff/models/models.py @@ -1,7 +1,12 @@ from typing import Any, Callable, Dict from openff.units import unit -from pydantic import BaseModel + +try: + from pydantic.v1 import BaseModel +except ImportError: + from pydantic import BaseModel + from openff.models.types import custom_quantity_encoder, json_loader diff --git a/openff/models/tests/test_types.py b/openff/models/tests/test_types.py index 05ab54a..f8ae8f9 100644 --- a/openff/models/tests/test_types.py +++ b/openff/models/tests/test_types.py @@ -4,12 +4,16 @@ import pytest from openff.units import unit from openff.utilities.testing import skip_if_missing -from pydantic import ValidationError from openff.models.exceptions import UnitValidationError from openff.models.models import DefaultModel from openff.models.types import ArrayQuantity, FloatQuantity +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError + class TestQuantityTypes: @skip_if_missing("openmm.unit") From b982e1bf9eb8250ae03be9c5e0ed12d8aa85c801 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Tue, 1 Aug 2023 05:40:03 -0500 Subject: [PATCH 3/4] LINT: Update type check in test --- openff/models/tests/test_types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openff/models/tests/test_types.py b/openff/models/tests/test_types.py index f8ae8f9..3f8b65c 100644 --- a/openff/models/tests/test_types.py +++ b/openff/models/tests/test_types.py @@ -190,9 +190,9 @@ class Subject(DefaultModel): ) # Ensure unyt scalars (unyt.unyt_quantity) are stored as floats - assert type(subject.age.m) == float - assert type(subject.height.m) == float - assert type(subject.doses.m) == np.ndarray + assert subject.age.m is float + assert subject.height.m is float + assert subject.doses.m is np.ndarray @skip_if_missing("unyt") @skip_if_missing("openmm.unit") From 8d1b68d8bb73c90b94c077fc6496d008aeedd7f3 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Tue, 1 Aug 2023 05:40:20 -0500 Subject: [PATCH 4/4] MAINT: Update Python support w/r/t NEP 29 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5952e99..69de64f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: os: [macOS-latest, ubuntu-latest] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.9", "3.11"] pydantic-version: ["1", "2"] openmm: [true, false] run-mypy: [false]