Skip to content

refactor: centralize MissingAttributeError in cclib.exception#1748

Closed
sputnik-mac wants to merge 1 commit intocclib:masterfrom
sputnik-mac:fix/issue-1746-centralize-missing-attribute-error
Closed

refactor: centralize MissingAttributeError in cclib.exception#1748
sputnik-mac wants to merge 1 commit intocclib:masterfrom
sputnik-mac:fix/issue-1746-centralize-missing-attribute-error

Conversation

@sputnik-mac
Copy link

Summary

Closes #1746

This PR removes the four duplicate MissingAttributeError class definitions and consolidates them into a single canonical exception under cclib.exception.

Changes

New file:

  • cclib/exception.py — defines MissingAttributeError(Exception) once

Removed duplicate definitions from:

  • cclib/bridge/cclib2pyscf.py
  • cclib/bridge/cclib2pyquante.py
  • cclib/io/filewriter.py
  • cclib/method/calculationmethod.py

Updated imports in source files:

  • cclib/io/wfxwriter.py — was using filewriter.MissingAttributeError, now imports directly
  • cclib/method/population.py

Updated imports in test files:

  • test/io/testwfxwriter.py
  • test/io/testmoldenwriter.py
  • test/method/testddec.py
  • test/method/testhirshfeld.py
  • test/method/testbader.py
  • test/method/testpopulation.py

Public API:

  • MissingAttributeError is now exported from cclib.__init__, making it accessible as cclib.MissingAttributeError

Backward compatibility

Existing code that imports from cclib.io.filewriter import MissingAttributeError or from cclib.method.calculationmethod import MissingAttributeError will break. If backward compatibility is required, re-export aliases can be added to those modules. Happy to add that if the maintainers prefer.

…clib#1746)

Define a single canonical MissingAttributeError under the top-level
cclib namespace in cclib/exception.py. Remove the duplicate class
definitions from:
- cclib/bridge/cclib2pyscf.py
- cclib/bridge/cclib2pyquante.py
- cclib/io/filewriter.py
- cclib/method/calculationmethod.py

Update all imports across source files and tests to use the new
canonical cclib.exception.MissingAttributeError. Also expose the
exception in cclib.__init__ as part of the public API.
@berquist
Copy link
Member

berquist commented Mar 7, 2026

While we develop a policy on AI-based contributions (#1749), I'm closing this as it is not in the intent of "good first issues" for them to be solved entirely by AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize on MissingAttributeError

2 participants