Commit 687fb41
Clean up unused imports and improve type hints (#324)
This pull request primarily removes unused imports and cleans up type
annotations across several modules in the `dpgen2` codebase. These
changes help streamline the code, reduce unnecessary dependencies, and
improve readability. Additionally, some minor logic and formatting
updates are included to modernize the code and ensure consistency.
### Code cleanup and import removal
* Removed unused imports such as `os`, `json`, `logging`, `glob`,
`pickle`, and several type hints (`Set`, `Union`, etc.) from multiple
files including `main.py`, `showkey.py`, `status.py`, `submit.py`,
`watch.py`, `workflow.py`, `prep_fp.py`, `run_fp.py`, and `vasp.py`.
This reduces clutter and potential confusion for future maintenance.
[[1]](diffhunk://#diff-566f49ecd2afbc4c7a22cd2f576a706a0fea95bed20f560240e328541830494dL4-L19)
[[2]](diffhunk://#diff-dc5e3ffd275993a4866b65927e0972ad7c65aac2e195b3ca9fdb43254278f265L1-L8)
[[3]](diffhunk://#diff-70638d2beeba19acd9b8de0bdf0bf976ba14b6f5e5f8dd24b1f84aaf23840425L4-L6)
[[4]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L2-L7)
[[5]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L18-L23)
[[6]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL7)
[[7]](diffhunk://#diff-74c1d2a47b53b85b573096163113600a7dd410f2a410bc9699e90c26af23d226L2-L4)
[[8]](diffhunk://#diff-8d2a04f59606da4f76ec76bc363f743a27ee018f3be91607b428165a5b56cba8L1-L2)
[[9]](diffhunk://#diff-8d2a04f59606da4f76ec76bc363f743a27ee018f3be91607b428165a5b56cba8L12-L16)
[[10]](diffhunk://#diff-c7fc0e85df33ae92aa2222a509449350292360031e74b03b169a3c7ba84dec29L1)
[[11]](diffhunk://#diff-c7fc0e85df33ae92aa2222a509449350292360031e74b03b169a3c7ba84dec29L13-L18)
[[12]](diffhunk://#diff-2f01a3587ee0b6fde430a0c71d0542ec7bd74bf9e57da500338b11afbf0df1c1L9-L14)
[[13]](diffhunk://#diff-34aa3497602bd93c83e17bd39502560ca7c9b6d09bacba3af33be0244a784477L13)
### Type annotation improvements
* Updated function signatures to use modern type hinting, such as
changing `Optional[Dict] = {}` to `Optional[Dict] | None = None` and
ensuring default values are properly handled with `wf_config = wf_config
or {}`. This makes the code safer and more in line with current Python
standards.
[[1]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL46-R67)
[[2]](diffhunk://#diff-74c1d2a47b53b85b573096163113600a7dd410f2a410bc9699e90c26af23d226L41-R40)
### Minor logic and formatting updates
* Improved string formatting in logging statements and conditional
checks for better readability and consistency. For example, switched to
f-strings with consistent quotation marks and improved assertion error
messages.
[[1]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL46-R67)
[[2]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L591-R584)
These changes collectively enhance code maintainability and readability
without altering core functionality.This pull request primarily cleans
up unused imports and improves code readability across several
entrypoint modules in the `dpgen2` package. It also introduces minor
enhancements to type hints and default argument handling for better code
clarity and robustness.
**Codebase cleanup and readability:**
* Removed unused imports (such as `os`, `glob`, `pickle`, `dpdata`,
etc.) from multiple files including `main.py`, `showkey.py`,
`status.py`, `submit.py`, and `workflow.py` to streamline the codebase.
[[1]](diffhunk://#diff-566f49ecd2afbc4c7a22cd2f576a706a0fea95bed20f560240e328541830494dL4-L19)
[[2]](diffhunk://#diff-dc5e3ffd275993a4866b65927e0972ad7c65aac2e195b3ca9fdb43254278f265L1-L8)
[[3]](diffhunk://#diff-70638d2beeba19acd9b8de0bdf0bf976ba14b6f5e5f8dd24b1f84aaf23840425L4-L6)
[[4]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L2-L7)
[[5]](diffhunk://#diff-74c1d2a47b53b85b573096163113600a7dd410f2a410bc9699e90c26af23d226L2-R2)
* Simplified assertion error messages and improved string formatting for
logging statements in `submit.py` and `watch.py`.
[[1]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L591-R583)
[[2]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL46-R67)
**Type hint and argument improvements:**
* Updated type hints for optional dictionary arguments in `watch.py` and
`workflow.py` to use `Optional[Dict] | None`, and ensured proper default
initialization using `wf_config = wf_config or {}`.
[[1]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL46-R67)
[[2]](diffhunk://#diff-74c1d2a47b53b85b573096163113600a7dd410f2a410bc9699e90c26af23d226L41-R38)
* Minor formatting improvements for argument parsing and function calls
for better readability in `main.py`.
[[1]](diffhunk://#diff-566f49ecd2afbc4c7a22cd2f576a706a0fea95bed20f560240e328541830494dL87-R77)
[[2]](diffhunk://#diff-566f49ecd2afbc4c7a22cd2f576a706a0fea95bed20f560240e328541830494dL384-R372)
**General code style enhancements:**
* Removed unnecessary tuple and union type imports, and cleaned up type
hints in `submit.py` and `status.py`.
[[1]](diffhunk://#diff-518b16955e40ff2d3d6308e0dff9a6800306adecead3255ccf8c71a146723588L18-L23)
[[2]](diffhunk://#diff-70638d2beeba19acd9b8de0bdf0bf976ba14b6f5e5f8dd24b1f84aaf23840425L4-L6)
[[3]](diffhunk://#diff-b80b08ddd1a5fe0cc9352de549f54b44ca1fbd63fd6e1300c756818bf2ef2dfdL7)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Refactor**
* Removed numerous unused imports across entry points and FP modules to
reduce dependency surface and trim code.
* Standardized logging/string formatting for consistency.
* **Bug Fixes**
* Changed workflow-config default from a mutable empty dict to None with
internal initialization to avoid shared-state issues.
* Corrected membership check used when computing finished-step diffs to
fix status reporting.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 9b6f382 commit 687fb41
10 files changed
Lines changed: 8 additions & 50 deletions
File tree
- dpgen2
- entrypoint
- fp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 10 | | |
21 | 11 | | |
22 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | 1 | | |
10 | 2 | | |
11 | 3 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
| |||
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 15 | | |
22 | 16 | | |
23 | | - | |
24 | 17 | | |
25 | 18 | | |
26 | 19 | | |
| |||
588 | 581 | | |
589 | 582 | | |
590 | 583 | | |
591 | | - | |
| 584 | + | |
592 | 585 | | |
593 | 586 | | |
594 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
| 45 | + | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
| 50 | + | |
52 | 51 | | |
53 | 52 | | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
| 60 | + | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | 2 | | |
6 | 3 | | |
7 | 4 | | |
| |||
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
| 38 | + | |
42 | 39 | | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | 10 | | |
14 | | - | |
15 | 11 | | |
16 | | - | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
21 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | 10 | | |
14 | | - | |
15 | 11 | | |
16 | 12 | | |
17 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
0 commit comments