-
Notifications
You must be signed in to change notification settings - Fork 468
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
AttributeError when using method "to" if a custom preprocessor is in place and a string is passed as target unit #1004
Comments
This is (unfortunately) the expected behavior of the preprocessors feature. Given that the preprocessors exist on the registry level, they only function when using the registry-level parsers ( However, this can definitely be better documented! (xref #972) |
Thanks @jthielen for the explanation, I supposed that it was related to the design of the feature (I tried to read the entire discussion but I got lost somewhere ;) ). Documenting this is fine, but IMHO this is something that should be better handled, i.e. by issuing a warning if a string is passed and the preprocessor attribute is not empty. |
But you can do the following: >>> UREG("count").to(UREG("%"))
<Quantity(100.0, 'percent')> |
Any PR to document this? |
I'm experiencing a problem with the new custom preprocessors feature;
trying to convert a quantity to "%" using a string instead of the quantity raises an AttributeError in the
ParserHelper.from_string
method, since it's not aware of the preprocessors.The last line throws this exception:
The text was updated successfully, but these errors were encountered: