Skip to content

Commit

Permalink
Allow for lazy loading of other modules with lazy loading (#1961)
Browse files Browse the repository at this point in the history
* unpin openff-units to trigger failing tests

* fall back to getattr

* Apply suggestions from code review

* Update releasehistory

---------

Co-authored-by: Matt Thompson <[email protected]>
Co-authored-by: Jeff Wagner <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 9c122a2 commit 52dd8a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
* `minor` increments add features but do not break API compatibility
* `micro` increments represent bugfix releases or improvements in documentation

## Current development

### API-breaking changes
## 0.16.6

### Behavior changes

- [PR #1954](https://github.com/openforcefield/openff-toolkit/pull/1954): `Topology.from_openmm` no longer casts residue numbers to int.

### Bugfixes

- [PR #1961](https://github.com/openforcefield/openff-toolkit/pull/1961): Fix [Issue #1960](https://github.com/openforcefield/openff-toolkit/issues/1960), where lazy-loading machinery in openff-toolkit would clash with newly added lazy-loading code in openff-units 0.2.3.

### New features

- [PR #1958](https://github.com/openforcefield/openff-toolkit/pull/1958): Allows serialization of `_SimpleMolecule`s (relevant to serialization of `Topology` objects created by `Interchange.from_openmm`)
Expand Down
5 changes: 4 additions & 1 deletion openff/toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def __getattr__(name):
obj_mod = _lazy_imports_obj.get(name)
if obj_mod is not None:
mod = importlib.import_module(obj_mod)
return mod.__dict__[name]
try:
return mod.__dict__[name]
except KeyError: # account for lazy loaders
return getattr(mod, name)

lazy_mod = _lazy_imports_mod.get(name)
if lazy_mod is not None:
Expand Down

0 comments on commit 52dd8a6

Please sign in to comment.