theochem / iodata

Python library for reading, writing, and converting computational chemistry file formats and generating input files.
https://iodata.readthedocs.io/
GNU Lesser General Public License v3.0
131 stars 46 forks source link

Check required attributes before dumping to a file #337

Closed tovrstra closed 3 months ago

tovrstra commented 3 months ago

This is the first step in a series of pull requests for issue #191. This is an old and complex issue, but important for data management, and it involves API changes. I've sliced up the issue in smaller tasks to make pull requests as small as possible.

This PR introduces an extra sanity check before dumping to a file. This also revealed a minor documentation mistake in the WFN format, which had to be fixed to make the tests pass.

I will YOLO-merge this on Friday, June 21, unless reviewed earlier.

Summary by Sourcery

This pull request adds a sanity check to ensure required attributes are present before dumping data to a file, corrects documentation for the WFN format, and introduces new unit tests to verify the behavior of the dump functions when required attributes are missing.

sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request introduces a new sanity check to ensure required attributes are present before dumping data to a file. The changes include adding a _check_required function in iodata/api.py, updating the WFN format documentation in iodata/formats/wfn.py, and adding new unit tests in iodata/test/test_api.py to validate these checks. Additionally, FileFormatError and FileFormatWarning were added to iodata/utils.py.

File-Level Changes

Files Changes
iodata/api.py
iodata/formats/wfn.py
Introduced a new function _check_required to validate required attributes before dumping data to a file and updated the WFN format documentation to reflect the correct required attributes.
iodata/utils.py
iodata/test/test_api.py
Added FileFormatError and FileFormatWarning to utils and created new unit tests to ensure the new attribute checks work correctly.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - You can change your review settings at any time by accessing your [dashboard](https://sourcery.ai/dashboard): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
deepsource-io[bot] commented 3 months ago

Here's the code health analysis summary for commits a127856..6c70851. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.
tovrstra commented 3 months ago

I've merged main into this PR to run the tests properly.

tovrstra commented 3 months ago

Thanks for reviewing! Going in....