Skip to content

Commit

Permalink
Merge pull request #7380 from Cadair/units/quantity-nan
Browse files Browse the repository at this point in the history
v2.0.x : Fix None return annotation in quantity_input
  • Loading branch information
bsipocz committed Apr 20, 2018
2 parents 69b7dba + 8110a7b commit 3cb966e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion astropy/units/decorators.py
Expand Up @@ -221,7 +221,7 @@ def wrapper(*func_args, **func_kwargs):
# Call the original function with any equivalencies in force.
with add_enabled_equivalencies(self.equivalencies):
return_ = wrapped_function(*func_args, **func_kwargs)
if wrapped_signature.return_annotation is not funcsigs.Signature.empty:
if wrapped_signature.return_annotation not in (funcsigs.Signature.empty, None):
return return_.to(wrapped_signature.return_annotation)
else:
return return_
Expand Down
11 changes: 11 additions & 0 deletions astropy/units/tests/py3_test_quantity_annotations.py
Expand Up @@ -289,3 +289,14 @@ def myfunc_args(solarx: u.arcsec) -> u.deg:
assert solarx.unit is u.deg
"""
return src

def test_return_annotation_none():
src = """
@u.quantity_input
def myfunc_args(solarx: u.arcsec) -> None:
pass
solarx = myfunc_args(1*u.arcsec)
assert solarx is None
"""
return src

0 comments on commit 3cb966e

Please sign in to comment.