-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try and fix type annotations #68
base: main
Are you sure you want to change the base?
Conversation
@mattwthompson What's the reason we do this: @requires_package("openmm")
def _to_openmm(self) -> "OpenMMQuantity":
"""Convert the quantity to an ``openmm.unit.Quantity``.
Returns
-------
openmm_quantity : openmm.unit.quantity.Quantity
The OpenMM compatible quantity.
"""
from openff.units.openmm import to_openmm
return to_openmm(self)
Quantity.to_openmm = _to_openmm # type: ignore[attr-defined] Instead of just writing |
We choose to I did that not because I think it makes any sense to do but because it "works" and I'm mortified at learning why. Here's the paper trail: #67 (comment) |
I have just spent an hour on this and I just want to say that I'm sorry I ever deigned to believe that I could sort this out. I found Pint documentation on how to subclass registry, unit, and quantity, but PyRight and MyPy both don't seem to be able to figure out that the object produced by I'll push my changes to this branch and then it can sit here doing nothing for a bit while I finish sorting out the examples stuff. |
for more information, see https://pre-commit.ci
I've spent more time trying to wrestle this together and I have less to show for it. I'm not sure that's a bug in PyRight, I'm sure I'm deeply confused as to how Pint's internals work and I'm not sure it'd be simple to handle all of the different things that can be returned from I've considered trying to just make stubs to handle the cases our codebase uses, but that's not been as simple as I hoped. |
I have |
I think I have type annotations in a reasonable state on the |
Description
Not 100% sure but I think these
# type: ignore
messages are fixable. I'll see how many I can get through in this PRTodos
Notable points that this PR has either accomplished or will accomplish.
Questions
Status