Skip to content

Commit 8787b45

Browse files
[pre-commit.ci] pre-commit autoupdate (#5178)
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.13 → v0.14.14](astral-sh/ruff-pre-commit@v0.14.13...v0.14.14) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
1 parent d5d5155 commit 8787b45

File tree

9 files changed

+32
-12
lines changed

9 files changed

+32
-12
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
exclude: ^source/3rdparty
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
3131
# Ruff version.
32-
rev: v0.14.13
32+
rev: v0.14.14
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]

deepmd/dpmodel/modifier/base_modifier.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
Any,
99
)
1010

11+
from typing_extensions import (
12+
Self,
13+
)
14+
1115
from deepmd.utils.plugin import (
1216
PluginVariant,
1317
make_plugin_registry,
@@ -18,7 +22,7 @@ def make_base_modifier() -> type[object]:
1822
class BaseModifier(ABC, PluginVariant, make_plugin_registry("modifier")):
1923
"""Base class for data modifier."""
2024

21-
def __new__(cls, *args: Any, **kwargs: Any) -> "BaseModifier":
25+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
2226
if cls is BaseModifier:
2327
cls = cls.get_class_by_type(kwargs["type"])
2428
return super().__new__(cls)

deepmd/infer/deep_eval.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
)
1212

1313
import numpy as np
14+
from typing_extensions import (
15+
Self,
16+
)
1417

1518
from deepmd.backend.backend import (
1619
Backend,
@@ -89,9 +92,7 @@ def __init__(
8992
) -> None:
9093
pass
9194

92-
def __new__(
93-
cls, model_file: str, *args: object, **kwargs: object
94-
) -> "DeepEvalBackend":
95+
def __new__(cls, model_file: str, *args: object, **kwargs: object) -> Self:
9596
if cls is DeepEvalBackend:
9697
backend = Backend.detect_backend_by_model(model_file)
9798
return super().__new__(backend().deep_eval)
@@ -384,7 +385,7 @@ class DeepEval(ABC):
384385
Keyword arguments.
385386
"""
386387

387-
def __new__(cls, model_file: str, *args: object, **kwargs: object) -> "DeepEval":
388+
def __new__(cls, model_file: str, *args: object, **kwargs: object) -> Self:
388389
if cls is DeepEval:
389390
deep_eval = DeepEvalBackend(
390391
model_file,

deepmd/pd/model/descriptor/descriptor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
)
1414

1515
import paddle
16+
from typing_extensions import (
17+
Self,
18+
)
1619

1720
from deepmd.pd.model.network.network import (
1821
TypeEmbedNet,
@@ -44,7 +47,7 @@ class DescriptorBlock(paddle.nn.Layer, ABC, make_plugin_registry("DescriptorBloc
4447

4548
local_cluster = False
4649

47-
def __new__(cls, *args: Any, **kwargs: Any) -> "DescriptorBlock":
50+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
4851
if cls is DescriptorBlock:
4952
try:
5053
descrpt_type = kwargs["type"]

deepmd/pd/model/task/fitting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
import numpy as np
1414
import paddle
15+
from typing_extensions import (
16+
Self,
17+
)
1518

1619
from deepmd.dpmodel.utils.seed import (
1720
child_seed,
@@ -54,7 +57,7 @@
5457
class Fitting(paddle.nn.Layer, BaseFitting):
5558
# plugin moved to BaseFitting
5659

57-
def __new__(cls, *args: Any, **kwargs: Any) -> "Fitting":
60+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
5861
if cls is Fitting:
5962
return BaseFitting.__new__(BaseFitting, *args, **kwargs)
6063
return super().__new__(cls)

deepmd/pt/model/descriptor/descriptor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
)
1414

1515
import torch
16+
from typing_extensions import (
17+
Self,
18+
)
1619

1720
from deepmd.pt.model.network.network import (
1821
TypeEmbedNet,
@@ -44,7 +47,7 @@ class DescriptorBlock(torch.nn.Module, ABC, make_plugin_registry("DescriptorBloc
4447

4548
local_cluster = False
4649

47-
def __new__(cls, *args: Any, **kwargs: Any) -> "DescriptorBlock":
50+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
4851
if cls is DescriptorBlock:
4952
try:
5053
descrpt_type = kwargs["type"]

deepmd/pt/model/task/fitting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
import numpy as np
1515
import torch
16+
from typing_extensions import (
17+
Self,
18+
)
1619

1720
from deepmd.dpmodel.utils.seed import (
1821
child_seed,
@@ -58,7 +61,7 @@
5861
class Fitting(torch.nn.Module, BaseFitting):
5962
# plugin moved to BaseFitting
6063

61-
def __new__(cls, *args: Any, **kwargs: Any) -> "Fitting":
64+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
6265
if cls is Fitting:
6366
return BaseFitting.__new__(BaseFitting, *args, **kwargs)
6467
return super().__new__(cls)

deepmd/utils/path.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import h5py
2020
import numpy as np
21+
from typing_extensions import (
22+
Self,
23+
)
2124
from wcmatch.glob import (
2225
globfilter,
2326
)
@@ -34,7 +37,7 @@ class DPPath(ABC):
3437
mode, by default "r"
3538
"""
3639

37-
def __new__(cls, path: str, mode: str = "r") -> "DPPath":
40+
def __new__(cls, path: str, mode: str = "r") -> Self:
3841
if cls is DPPath:
3942
if os.path.isdir(path):
4043
return super().__new__(DPOSPath)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies = [
4545
'scipy',
4646
'pyyaml',
4747
'dargs >= 0.4.7',
48-
'typing_extensions; python_version < "3.8"',
48+
'typing_extensions>=4.0.0',
4949
'importlib_metadata>=1.4; python_version < "3.8"',
5050
'h5py',
5151
"h5py>=3.6.0,!=3.11.0; platform_system=='Linux' and platform_machine=='aarch64'",

0 commit comments

Comments
 (0)