Description
The decorator quantity_input() tries to convert the annotated return value to a Quantity here. When a return annotation other than Quantity is used, this conversion fails of course resulting in the error below.
Expected behavior
The decorator quantity_input() should ignore annotated return values which are not of type Quantity. This has also been disicussed and fixed here but the fix has been discarded.
Actual behavior
The following error message is shown:
Traceback (most recent call last):
File "<input>", line 6, in <module>
File "<<redacted>>/venv/lib/python3.7/site-packages/astropy/units/decorators.py", line 236, in wrapper
return return_.to(wrapped_signature.return_annotation)
AttributeError: 'str' object has no attribute 'to'
Steps to Reproduce
- [Run the code below in a python console]
import astropy.units as u
@u.quantity_input(temp=[u.Kelvin, u.Celsius])
def foo(temp: u.Quantity) -> str:
return "bar"
print(foo(300 * u.K)())
System Details
Darwin-19.4.0-x86_64-i386-64bit
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)]
Numpy 1.18.2
astropy 4.0.1.post1
Scipy 1.4.1
Description
The decorator
quantity_input()tries to convert the annotated return value to a Quantity here. When a return annotation other than Quantity is used, this conversion fails of course resulting in the error below.Expected behavior
The decorator
quantity_input()should ignore annotated return values which are not of type Quantity. This has also been disicussed and fixed here but the fix has been discarded.Actual behavior
The following error message is shown:
Steps to Reproduce
System Details