Open dwhswenson opened 1 year ago
0.2.1 breaks lots of stuff for reasons that have caused me physiological aging (blood pressure, hair loss, etc.). For now the recommendation is to stick to 0.2.0, since I think that works, and we'll have fixes out as soon as we can (one attempt at https://github.com/openforcefield/openff-units/pull/68).
I'm also not sure if this affects both Pint 0.21 and 0.22, but I'm pretty sure one of them works with 0.2.0
With #84 I have it passing on Pint 0.21, 0.22, 0.23
With https://github.com/openforcefield/openff-models/pull/42 it's also passing with Pydantic models. The SomeQuantity['preferred_unit']
paradigm is likely going away, I unfortunately don't think that pattern is future-compatible with how tooling interprets string literals brackets inside of things that look like types.
This still sticks around on the v1 API, it should be gone with v2
$ cat example.py && python example.py && mypy example.py 14:00:02 ☁ 0.2.2 ☂
# file named example.py
import openff.units
import openff.models
from openff.models.types import FloatQuantity
from pydantic.v1 import BaseModel
from openff.units import Quantity
print(f"{openff.units.__version__=}")
print(f"{openff.models.__version__=}")
class Model(BaseModel):
temperature: FloatQuantity["kelvin"]
print(f"{Model(temperature=Quantity("419.0 kelvin")).temperature=}")
openff.units.__version__='0.2.2'
openff.models.__version__='0.1.2'
Model(temperature=Quantity("419.0 kelvin")).temperature=<Quantity(419.0, 'kelvin')>
example.py:15: error: Variable "openff.models.types.FloatQuantity" is not valid as a type [valid-type]
example.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
example.py:15: error: Name "kelvin" is not defined [name-defined]
Found 2 errors in 1 file (checked 1 source file)
Not sure if this belongs here or on openff-models, but here's a MCVE:
Then, with openff-units 0.2.0 (and openff-models at current release, 0.0.5):
With openff-units 0.2.1:
see also https://github.com/OpenFreeEnergy/openfe/issues/461