From 71135de929da0f0def2a6f4c4fa588c63d589a96 Mon Sep 17 00:00:00 2001 From: btyrcha Date: Wed, 2 Dec 2026 17:33:08 +0100 Subject: [PATCH 1/3] pre-commit: hygiene hooks, black and flake8 as in CI, notebooks and metadata An optional .pre-commit-config.yaml for local commits; CI is unchanged. black and flake8 run the checks CI runs: black at the 26 release CI installs, flake8 stopping only on CI's critical errors. The general hooks catch large files, merge-conflict markers, broken YAML and TOML, missing final newlines, trailing whitespace, leftover breakpoints and private keys. no-commit-to-branch keeps commits off main, which changes only through pull requests. nbstripout keeps the example notebooks free of outputs and widget state. check-jsonschema validates the GitHub workflows, as release.yml runs only on a tag push, and CITATION.cff, which GitHub's citation and Zenodo read. Co-Authored-By: Claude Opus 5.5 --- .pre-commit-config.yaml | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c30d505 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,70 @@ +# pre-commit hooks for propSAPT. They check only the files being committed. +# +# One-time setup, in the prop-sapt environment (the hooks then run on its Python): +# pip install pre-commit +# pre-commit install # installs the commit hook +# pre-commit run --all-files # first run over the existing code +# +# Day to day: +# pre-commit autoupdate # bump hook versions (every month or two) +# SKIP= git commit ... # skip one hook once, after checking by hand +# +# black and flake8 run the checks CI runs (.github/workflows/python-package-conda.yml). +# black's style is fixed within a major version: bump its rev together with the pins +# in CI and prop-sapt.yaml. + +repos: + # --- General hygiene ------------------------------------------------------ + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-added-large-files # stray data dumps and outputs + args: [--maxkb=1000] + - id: check-merge-conflict + - id: check-yaml + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: debug-statements # leftover breakpoint() / pdb + - id: detect-private-key + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: no-commit-to-branch # main changes only through pull requests + + # --- Secrets (API keys, tokens, passwords) --------------------------------- + # detect-private-key above catches private keys only. For a thorough scan, + # uncomment gitleaks. pre-commit builds it with Go, which it downloads on + # first run if Go isn't installed (a few minutes, once). + # - repo: https://github.com/gitleaks/gitleaks + # rev: v8.30.0 + # hooks: + # - id: gitleaks + + # --- Python --------------------------------------------------------------- + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.10.1 + hooks: + - id: black + + # The errors CI stops on: syntax errors and undefined names. + - repo: https://github.com/PyCQA/flake8 + rev: 7.5.0 + hooks: + - id: flake8 + args: ["--select=E9,F63,F7,F82", --show-source] + + # --- Notebooks ------------------------------------------------------------ + # The example notebooks are kept without outputs and widget state. + - repo: https://github.com/kynan/nbstripout + rev: 0.9.2 + hooks: + - id: nbstripout + + # --- Metadata ------------------------------------------------------------- + # CITATION.cff feeds GitHub's "Cite this repository" and Zenodo. The workflows + # are checked against their schema, as release.yml runs only on a tag push. + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.40.0 + hooks: + - id: check-github-workflows + - id: check-citation-file-format From 1cdc9ed2c27a39ad53740d76736c0ac0b2d4ecd8 Mon Sep 17 00:00:00 2001 From: btyrcha Date: Wed, 2 Dec 2026 17:33:08 +0100 Subject: [PATCH 2/3] AI usage log: the pre-commit configuration Co-Authored-By: Claude Opus 5.5 --- AI-USAGE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AI-USAGE.md b/AI-USAGE.md index 8c57201..7138a08 100644 --- a/AI-USAGE.md +++ b/AI-USAGE.md @@ -179,3 +179,7 @@ The short version, for disclosures; the log below has the detail. ### 2026-11-25 - Worked through a code review of the Psi4 backend pull request: J/K inputs cleared after a failed build, monomers with different numbers of orbitals rejected, `nao_aux` renamed `naux` (it now counts spherical fitting functions), Psi4's timer around the whole dimer construction again, clear errors from the Psi4 getters with another backend, the tensor folding of `compute_jk` tested on both sides, with docs and changelog notes for the API changes. + +### 2026-12-02 + +- Added a pre-commit configuration (`.pre-commit-config.yaml`), adapted from a suggested setup after reviewing it against the repository. From 295c8de7afc85bea3f9f89161b65b327a39d5476 Mon Sep 17 00:00:00 2001 From: btyrcha Date: Wed, 2 Dec 2026 17:45:50 +0100 Subject: [PATCH 3/3] The first pre-commit run: a final newline in LICENSE, blank lines in docs/usage.rst The fixes of end-of-file-fixer and trailing-whitespace, the only hooks that failed on the existing files. Three blank lines in the usage guide held only spaces; the rendered docs are unchanged. pre-commit run --all-files now passes. Co-Authored-By: Claude Opus 5.5 --- LICENSE | 2 +- docs/usage.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index a710913..a861d92 100644 --- a/LICENSE +++ b/LICENSE @@ -25,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/usage.rst b/docs/usage.rst index 9e94dfb..85f4135 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -97,7 +97,7 @@ To perform the SAPT energy decomposition, SAPT0 for an ``RHF`` dimer and SAPT(DF # Calculate all SAPT components energy_result = calc_sapt_energy(dimer) - + print(energy_result) The result is a pandas Series of all SAPT energy components. It is also saved to @@ -130,7 +130,7 @@ To calculate interaction-induced properties for a general one-electron operator: # Calculate property contributions property_result = calc_property(dimer, property_matrix) - + print(property_result) For predefined properties, you can use the convenience functions, e.g., to calculate the dipole moment: @@ -271,7 +271,7 @@ A bundle that does not match raises :class:`~prop_sapt.artifacts.ArtifactError`. The older layout of bare :file:`delta_dm_.npy` and :file:`wfn_mon_.npy` files is still written with :python:`matrix_format="npy"`, but it is deprecated, and so is the ``compress_matrices`` argument. - + .. _viamd: