From 961b5913a2b39a5cd9280faa3586ded010a65d45 Mon Sep 17 00:00:00 2001 From: Han Wang <92130845+wanghan-iapcm@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:53:22 +0800 Subject: [PATCH] breaking: drop python 3.7 (#783) ## Summary by CodeRabbit ## Release Notes - **Python Version Support** - Dropped support for Python 3.7 - Now requires Python 3.8 or higher - **Documentation** - Updated installation instructions to reflect new Python version requirements - **Code Maintenance** - Simplified type imports and version-specific code handling - Removed legacy version compatibility checks - **Build Configuration** - Updated GitHub Actions workflow to test only Python 3.8 and 3.12 --------- Co-authored-by: Han Wang Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- docs/installation.md | 2 +- docs/make_format.py | 7 +------ dpdata/stat.py | 8 ++++---- dpdata/system.py | 7 +------ dpdata/utils.py | 7 +------ pyproject.toml | 3 +-- tests/plugin/pyproject.toml | 2 +- 8 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2410563b6..caf4a59c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: ["3.7", "3.8", "3.12"] + python-version: ["3.8", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/docs/installation.md b/docs/installation.md index 064f91331..1b24e0051 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation -DP-GEN only supports Python 3.7 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install DP-GEN: +dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata: - Install via pip: `pip install dpdata` - Install via conda: `conda install -c conda-forge dpdata` diff --git a/docs/make_format.py b/docs/make_format.py index 2b3c03c67..e9c1f60d3 100644 --- a/docs/make_format.py +++ b/docs/make_format.py @@ -2,14 +2,9 @@ import csv import os -import sys from collections import defaultdict from inspect import Parameter, Signature, cleandoc, signature - -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal +from typing import Literal from numpydoc.docscrape import Parameter as numpydoc_Parameter from numpydoc.docscrape_sphinx import SphinxDocString diff --git a/dpdata/stat.py b/dpdata/stat.py index 31e972306..0b04d5700 100644 --- a/dpdata/stat.py +++ b/dpdata/stat.py @@ -116,7 +116,7 @@ class Errors(ErrorsBase): SYSTEM_TYPE = LabeledSystem @property - @lru_cache() + @lru_cache def e_errors(self) -> np.ndarray: """Energy errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -124,7 +124,7 @@ def e_errors(self) -> np.ndarray: return self.system_1["energies"] - self.system_2["energies"] @property - @lru_cache() + @lru_cache def f_errors(self) -> np.ndarray: """Force errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -153,7 +153,7 @@ class MultiErrors(ErrorsBase): SYSTEM_TYPE = MultiSystems @property - @lru_cache() + @lru_cache def e_errors(self) -> np.ndarray: """Energy errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -166,7 +166,7 @@ def e_errors(self) -> np.ndarray: return np.concatenate(errors) @property - @lru_cache() + @lru_cache def f_errors(self) -> np.ndarray: """Force errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) diff --git a/dpdata/system.py b/dpdata/system.py index 645628ccd..cfc0f184e 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -5,21 +5,16 @@ import hashlib import numbers import os -import sys import warnings from copy import deepcopy from typing import ( TYPE_CHECKING, Any, Iterable, + Literal, overload, ) -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - import numpy as np import dpdata diff --git a/dpdata/utils.py b/dpdata/utils.py index 8942bd54d..58a908cc7 100644 --- a/dpdata/utils.py +++ b/dpdata/utils.py @@ -2,14 +2,9 @@ import io import os -import sys from contextlib import contextmanager -from typing import TYPE_CHECKING, Generator, overload +from typing import TYPE_CHECKING, Generator, Literal, overload -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal import numpy as np from dpdata.periodic_table import Element diff --git a/pyproject.toml b/pyproject.toml index 514025e71..52c47804e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ authors = [ ] license = {file = "LICENSE"} classifiers = [ - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -28,7 +27,7 @@ dependencies = [ 'importlib_metadata>=1.4; python_version < "3.8"', 'typing_extensions; python_version < "3.8"', ] -requires-python = ">=3.7" +requires-python = ">=3.8" readme = "README.md" keywords = ["lammps", "vasp", "deepmd-kit"] diff --git a/tests/plugin/pyproject.toml b/tests/plugin/pyproject.toml index 7ce1f854a..3e01f27cb 100644 --- a/tests/plugin/pyproject.toml +++ b/tests/plugin/pyproject.toml @@ -11,7 +11,7 @@ dependencies = [ 'dpdata', ] readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" [project.entry-points.'dpdata.plugins'] random = "dpdata_plugin_test:ep"