deepmodeling / deepmodeling/dftio
[Code scan] Reject parser root/prefix combinations that match no calculations
- Dominant language
- Jupyter Notebook
- Stars
- 16
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
This issue comes from a Codex global repository scan.
## Problem
Parser initialization intends to reject empty input discovery, but the assertion is written as a single tuple expression:
https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/io/parse.py#L64-L69
`assert(len(self.raw_datas) != 0, "...")` always asserts a non-empty tuple, so it never fails. Empty parser inputs then proceed and fail later with less useful errors.
`python -m compileall -q dftio` also reports:
```text
SyntaxWarning: assertion is always true, perhaps remove parentheses?
```
## Suggested fix
Use a real assertion or an explicit exception:
```python
if len(self.raw_datas) == 0:
raise FileNotFoundError("There are no folders that meet the requirements in the directory!")
```
Contributor guide
Research direction
Start with dftio/io/parse.py at lines 64-69 and inspect how parser initialization handles root/prefix combinations that produce no raw data. Run python -m compileall -q dftio before and after the change, then verify that an empty discovery raises the specified FileNotFoundError instead of continuing to later processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100