Skip to content

Commit

Permalink
fix: prevent deepmd.tf be imported globally (#3382)
Browse files Browse the repository at this point in the history
Add a ruff rule `TID253` to ensure it.

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored Mar 2, 2024
1 parent 92ee632 commit 831610a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion deepmd/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import numpy as np

from deepmd.tf.common import (
from deepmd.common import (
j_must_have,
)

Expand Down
4 changes: 1 addition & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
date,
)

from deepmd.tf.common import (
from deepmd.utils.argcheck import (
ACTIVATION_FN_DICT,
PRECISION_DICT,
)
from deepmd.tf.utils.argcheck import (
list_to_doc,
)

Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ select = [
"C4", # flake8-comprehensions
"RUF", # ruff
"NPY", # numpy
"TID253", # banned-module-level-imports
]

ignore = [
Expand All @@ -256,9 +257,30 @@ ignore = [
]
ignore-init-module-imports = true

exclude = [
"source/3rdparty/**",
]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.flake8-tidy-imports]
banned-module-level-imports = [
"deepmd.tf",
"deepmd.pt",
"tensorflow",
"torch",
]

[tool.ruff.lint.extend-per-file-ignores]
# Also ignore `E402` in all `__init__.py` files.
"deepmd/tf/**" = ["TID253"]
"deepmd/pt/**" = ["TID253"]
"source/tests/tf/**" = ["TID253"]
"source/tests/pt/**" = ["TID253"]
"source/ipi/tests/**" = ["TID253"]
"source/lmp/tests/**" = ["TID253"]

[tool.pytest.ini_options]
markers = "run"

Expand Down
27 changes: 0 additions & 27 deletions source/tests/common/test_uni_infer.py

This file was deleted.

0 comments on commit 831610a

Please sign in to comment.