Closed mattwthompson closed 2 weeks ago
Just to be clear, there are two potential issues here:
unit
argument is not sanitized in a way that's consistent with the type annotationfoo = ParameterAttribute(default=None, unit=unit.nanometer)
is magically stringified in some of the machinery, causing problems later on that look similar to what happens in some cases with (1)(2) I can't actually reproduce with a full head of steam; it looks like something was funky on my local machine with a combination of editable builds on top of editable builds and virtual site non-bonded interactions shadowing atomistic non-bonded interactions of the same name, one having accidentally done a ..., unit="nanometer"
type deal.
Describe the bug
I'm working on a isolating something from a more involved example, but for now I can demonstrate that this argument is not checked for proper types
https://github.com/openforcefield/openff-toolkit/blob/fdf383261717a1ca9fe72586e2463a425c04e0f9/openff/toolkit/typing/engines/smirnoff/parameters.py#L342-L350
which later causes this clause to bubble up in confusing ways - below because
self._unit
is allowed to be a string, it bubbles up a confusing error that nanometers aren't compatible with nanometers.https://github.com/openforcefield/openff-toolkit/blob/fdf383261717a1ca9fe72586e2463a425c04e0f9/openff/toolkit/typing/engines/smirnoff/parameters.py#L416-L420
It's possible I'm missing something with how stuff is passed through these classes, but it's hard for me to figure out from the code itself.
To Reproduce
Passing a string to the
unit
argument is bad, but for now just consider the possibly that something could get botched and let it through like that or that a user would give it a try.