[pypy-commit] pypy signatures: Support None in signatures (handy for return types!)

Greg Price noreply at buildbot.pypy.org
Tue Dec 4 07:49:45 CET 2012


Author: Greg Price <price at mit.edu>
Branch: signatures
Changeset: r59323:0bfc606c7fb6
Date: 2012-12-03 21:09 -0800
http://bitbucket.org/pypy/pypy/changeset/0bfc606c7fb6/

Log:	Support None in signatures (handy for return types!)

diff --git a/pypy/annotation/types.py b/pypy/annotation/types.py
--- a/pypy/annotation/types.py
+++ b/pypy/annotation/types.py
@@ -2,6 +2,10 @@
 from pypy.annotation.listdef import ListDef
 
 
+def none():
+    return model.s_None
+
+
 def float():
     return model.SomeFloat()
 
diff --git a/pypy/rlib/test/test_signature.py b/pypy/rlib/test/test_signature.py
--- a/pypy/rlib/test/test_signature.py
+++ b/pypy/rlib/test/test_signature.py
@@ -76,6 +76,12 @@
         return s
 
 
+def test_signature_none():
+    @signature(returns=types.none())
+    def f():
+        pass
+    assert getsig(f) == [model.s_None]
+
 def test_signature_float():
     @signature(types.longfloat(), types.singlefloat(), returns=types.float())
     def f(a, b):


More information about the pypy-commit mailing list