Repository navigation
refactor(models,io): Simplify helpers and make models/io mypy-clean - #375
Merged
Merged
Conversation
ericchansen
force-pushed
the
ericchansen-simplify-models-and-io-layer
branch
from
October 19, 2026 22:45
cf2104a to
3d7f4d6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The refactor introduces an angle-projection division failure and repeated parsing of Gaussian logs without frequency modes.
2 open issues
What changed in this PR
Consolidates shared model and I/O helpers and extends mypy enforcement across those modules.
Changes:
- Shares text-file handling, template resolution, and repeated model calculations.
- Simplifies parser staging and strengthens type annotations.
- Removes 13 mypy exemptions and adds shared-helper tests.
| File | Description |
|---|---|
| test/test_io_helpers.py | Tests shared helpers and parser inheritance. |
| q2mm/models/seminario.py | Shares Hessian projection logic and tightens types. |
| q2mm/models/observations.py | Centralizes enum coercion. |
| q2mm/models/molecule.py | Shares adjacency and geometry calculations. |
| q2mm/models/identifiers.py | Centralizes atom-type token cleaning. |
| q2mm/models/hessian.py | Shares conversion constants and mass weighting. |
| q2mm/models/forcefield.py | Simplifies parameter construction and keys. |
| q2mm/io/tinker.py | Strengthens types and shares template resolution. |
| q2mm/io/reference.py | Consolidates scalar observation parsing. |
| q2mm/io/openmm.py | Clarifies export variable types. |
| q2mm/io/mol2.py | Adopts shared text-file handling. |
| q2mm/io/mm3.py | Unifies torsion construction and template resolution. |
| q2mm/io/macromodel.py | Unifies staging records and file handling. |
| q2mm/io/jaguar.py | Shares file handling and simplifies parsing. |
| q2mm/io/gaussian.py | Refactors parser state and file handling. |
| q2mm/io/cmap.py | Centralizes grid finalization. |
| q2mm/io/amber.py | Tightens parameter types and shares template resolution. |
| q2mm/io/_helpers.py | Adds shared file and template helpers. |
| pyproject.toml | Removes model and I/O mypy exemptions. |
Review effort: Balanced
Consolidate duplicated text-file parser boilerplate, template-path resolution, Hessian frequency conversion constants, and Seminario 3x3 sub-block projection, and fix type annotations across q2mm.models and q2mm.io so all 13 grandfathered modules can be removed from [[tool.mypy.overrides]]. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ericchansen
force-pushed
the
ericchansen-simplify-models-and-io-layer
branch
from
October 20, 2026 17:38
3d7f4d6 to
f86e8e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Simplifies duplicated helpers across
q2mm.modelsandq2mm.io(-444 net lines) and resolves all remaining static type errors across everyq2mm.models.*andq2mm.io.*module so all 13 grandfathered model/I/O modules can be removed from[[tool.mypy.overrides]]inpyproject.toml.Changes
_TextFileBase) and template path resolution (_resolve_template_path) inq2mm/io/_helpers.py, removing duplicated boilerplate acrossGaussLog,JaguarIn,JaguarOut,MacroModel,MacroModelLog,Mol2,amber.py,mm3.py, andtinker.py.q2mm/models/molecule.pytoq2mm.geometry(bond_length,bond_angle)._project_subblock_along) inq2mm/models/seminario.py, frequency unit conversion constants andmass_weight_scale_3nusage inq2mm/models/hessian.py, enum coercion (_coerce_enum) inq2mm/models/observations.py, and token cleaning (_clean_env_tokens) inq2mm/models/identifiers.py.q2mm/io/cmap.py, MM3 proper/improper torsion construction inq2mm/io/mm3.py, MacroModel term staging (_MacroModelTerm) inq2mm/io/macromodel.py, and scalar observation parsing inq2mm/io/reference.py.q2mm.models.*andq2mm.io.*entries from[[tool.mypy.overrides]]inpyproject.toml.Testing
python -m ruff check q2mm/ test/ scripts/(all checks passed)python -m ruff format --check q2mm test scripts examples(288 files formatted)python -m mypy q2mm/(0 errors across 109 source files)python -m pytest test/ -x -q -m "not (openmm or tinker or jax or jax_md or psi4)"(7,582 passed, 185 skipped)