[Code scan] Reject parser root/prefix combinations that match no calculations

Open Beginner friendly
#32 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
backend

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.

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:

SyntaxWarning: assertion is always true, perhaps remove parentheses?

Suggested fix

Use a real assertion or an explicit exception:

if len(self.raw_datas) == 0:
    raise FileNotFoundError("There are no folders that meet the requirements in the directory!")
Dominant language
Jupyter Notebook
Stars
16
Forks
14
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from deepmodeling/dftio

All issues in deepmodeling/dftio

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.