Adopt PEP 484 type hints for C++ types exported to Python
diff --git a/example/eigen.py b/example/eigen.py
index 5f7ec51..18c8a45 100644
--- a/example/eigen.py
+++ b/example/eigen.py
@@ -106,3 +106,9 @@
print("symmetric_lower %s" % ("OK" if (symmetric_lower(asymm) == symm_lower).all() else "FAILED"))
print("symmetric_upper %s" % ("OK" if (symmetric_upper(asymm) == symm_upper).all() else "FAILED"))
+
+print(double_col.__doc__)
+print(double_row.__doc__)
+print(double_mat_rm.__doc__)
+print(sparse_passthrough_r.__doc__)
+print(sparse_passthrough_c.__doc__)
diff --git a/example/eigen.ref b/example/eigen.ref
index 755012f..626c604 100644
--- a/example/eigen.ref
+++ b/example/eigen.ref
@@ -53,3 +53,8 @@
incr_diag OK
symmetric_lower OK
symmetric_upper OK
+double_col(arg0: numpy.ndarray[float32[m, 1]]) -> numpy.ndarray[float32[m, 1]]
+double_row(arg0: numpy.ndarray[float32[1, n]]) -> numpy.ndarray[float32[1, n]]
+double_mat_rm(arg0: numpy.ndarray[float32[m, n]]) -> numpy.ndarray[float32[m, n]]
+sparse_passthrough_r(arg0: scipy.sparse.csr_matrix[float32]) -> scipy.sparse.csr_matrix[float32]
+sparse_passthrough_c(arg0: scipy.sparse.csc_matrix[float32]) -> scipy.sparse.csc_matrix[float32]
diff --git a/example/example-arg-keywords-and-defaults.ref b/example/example-arg-keywords-and-defaults.ref
index 6889574..d3ca997 100644
--- a/example/example-arg-keywords-and-defaults.ref
+++ b/example/example-arg-keywords-and-defaults.ref
@@ -1,51 +1,51 @@
Help on built-in function kw_func0 in module example
kkww__ffuunncc00(...)
- kw_func0(arg0: int, arg1: int) -> NoneType
+ kw_func0(arg0: int, arg1: int) -> None
Help on built-in function kw_func1 in module example
kkww__ffuunncc11(...)
- kw_func1(x: int, y: int) -> NoneType
+ kw_func1(x: int, y: int) -> None
Help on built-in function kw_func2 in module example
kkww__ffuunncc22(...)
- kw_func2(x: int=100L, y: int=200L) -> NoneType
+ kw_func2(x: int=100L, y: int=200L) -> None
Help on built-in function kw_func3 in module example
kkww__ffuunncc33(...)
- kw_func3(data: unicode=u'Hello world!') -> NoneType
+ kw_func3(data: unicode=u'Hello world!') -> None
Help on built-in function kw_func4 in module example
kkww__ffuunncc44(...)
- kw_func4(myList: list<int>=[13L, 17L]) -> NoneType
+ kw_func4(myList: List[int]=[13L, 17L]) -> None
Help on built-in function kw_func_udl in module example
kkww__ffuunncc__uuddll(...)
- kw_func_udl(x: int, y: int=300L) -> NoneType
+ kw_func_udl(x: int, y: int=300L) -> None
Help on built-in function kw_func_udl_z in module example
kkww__ffuunncc__uuddll__zz(...)
- kw_func_udl_z(x: int, y: int=0L) -> NoneType
+ kw_func_udl_z(x: int, y: int=0L) -> None
Help on built-in function args_function in module example
aarrggss__ffuunnccttiioonn(...)
- args_function(*args) -> NoneType
+ args_function(*args) -> None
Help on built-in function args_kwargs_function in module example
aarrggss__kkwwaarrggss__ffuunnccttiioonn(...)
- args_kwargs_function(*args, **kwargs) -> NoneType
+ args_kwargs_function(*args, **kwargs) -> None
-foo0(self: KWClass, arg0: int, arg1: float) -> NoneType
-foo1(self: KWClass, x: int, y: float) -> NoneType
+foo0(self: KWClass, arg0: int, arg1: float) -> None
+foo1(self: KWClass, x: int, y: float) -> None
kw_func(x=5, y=10)
@@ -58,10 +58,10 @@
kw_func(x=5, y=10)
kw_func(x=5, y=10)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
- 1. (x: int=100L, y: int=200L) -> NoneType
+ 1. (x: int=100L, y: int=200L) -> None
Invoked with:
-kw_func4: 13 17
-kw_func4: 1 2 3
+kw_func4: 13 17
+kw_func4: 1 2 3
kw_func(x=1234, y=5678)
got argument: arg1_value
got argument: arg2_value
diff --git a/example/example-callbacks.py b/example/example-callbacks.py
index 674174a..1d18c89 100755
--- a/example/example-callbacks.py
+++ b/example/example-callbacks.py
@@ -82,3 +82,6 @@
print("All OK!")
else:
print("Problem!")
+
+print(test_callback3.__doc__)
+print(test_callback4.__doc__)
diff --git a/example/example-callbacks.ref b/example/example-callbacks.ref
index d6ab75e..7180b58 100644
--- a/example/example-callbacks.ref
+++ b/example/example-callbacks.ref
@@ -6,7 +6,7 @@
Molly is a dog
Woof!
The following error is expected: Incompatible function arguments. The following argument types are supported:
- 1. (arg0: example.Dog) -> NoneType
+ 1. (arg0: example.Dog) -> None
Invoked with: <example.Pet object at 0>
Callback function 1 called!
False
@@ -36,3 +36,6 @@
All OK!
could not convert to a function pointer.
All OK!
+
+test_callback3(arg0: Callable[[int], int]) -> None
+test_callback4() -> Callable[[int], int]
diff --git a/example/example-numpy-vectorize.py b/example/example-numpy-vectorize.py
index e21c1a5..322ce2a 100755
--- a/example/example-numpy-vectorize.py
+++ b/example/example-numpy-vectorize.py
@@ -32,3 +32,5 @@
selective_func(np.array([1], dtype=np.int32))
selective_func(np.array([1.0], dtype=np.float32))
selective_func(np.array([1.0j], dtype=np.complex64))
+
+print(vectorized_func.__doc__)
diff --git a/example/example-numpy-vectorize.ref b/example/example-numpy-vectorize.ref
index 4885fc1..d2d5d9b 100644
--- a/example/example-numpy-vectorize.ref
+++ b/example/example-numpy-vectorize.ref
@@ -76,3 +76,4 @@
Int branch taken.
Float branch taken.
Complex float branch taken.
+vectorized_func(arg0: numpy.ndarray[int], arg1: numpy.ndarray[float], arg2: numpy.ndarray[float]) -> object
diff --git a/example/example-opaque-types.ref b/example/example-opaque-types.ref
index a6672fd..f8f1692 100644
--- a/example/example-opaque-types.ref
+++ b/example/example-opaque-types.ref
@@ -10,7 +10,7 @@
Got void ptr : 0x7f9ba0f3c430
Called ExampleMandA destructor (0)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
- 1. (capsule) -> NoneType
+ 1. (arg0: capsule) -> None
Invoked with: [1, 2, 3]
None
Got null str : 0x0
diff --git a/example/example-python-types.ref b/example/example-python-types.ref
index 2a0237c..a8c39e0 100644
--- a/example/example-python-types.ref
+++ b/example/example-python-types.ref
@@ -34,8 +34,8 @@
| x.__init__(...) initializes x; see help(type(x)) for signature
|
| ggeett__aarrrraayy(...)
- | Signature : (example.ExamplePythonTypes) -> list<unicode>[2]
|
+ | Signature : (example.ExamplePythonTypes) -> List[unicode[2]]
| Return a C++ array
|
| ggeett__ddiicctt(...)
@@ -44,8 +44,8 @@
| Return a Python dictionary
|
| ggeett__ddiicctt__22(...)
- | Signature : (example.ExamplePythonTypes) -> dict<unicode, unicode>
|
+ | Signature : (example.ExamplePythonTypes) -> Dict[unicode, unicode]
| Return a C++ dictionary
|
| ggeett__lliisstt(...)
@@ -54,8 +54,8 @@
| Return a Python list
|
| ggeett__lliisstt__22(...)
- | Signature : (example.ExamplePythonTypes) -> list<unicode>
|
+ | Signature : (example.ExamplePythonTypes) -> List[unicode]
| Return a C++ list
|
| ggeett__sseett(...)
@@ -69,53 +69,53 @@
| Return a C++ set
|
| ppaaiirr__ppaasssstthhrroouugghh(...)
- | Signature : (example.ExamplePythonTypes, (bool, unicode)) -> (unicode, bool)
|
+ | Signature : (example.ExamplePythonTypes, Tuple[bool, unicode]) -> Tuple[unicode, bool]
| Return a pair in reversed order
|
| pprriinntt__aarrrraayy(...)
- | Signature : (example.ExamplePythonTypes, list<unicode>[2]) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, List[unicode[2]]) -> None
| Print entries of a C++ array
|
| pprriinntt__ddiicctt(...)
- | Signature : (example.ExamplePythonTypes, dict) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, dict) -> None
| Print entries of a Python dictionary
|
| pprriinntt__ddiicctt__22(...)
- | Signature : (example.ExamplePythonTypes, dict<unicode, unicode>) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, Dict[unicode, unicode]) -> None
| Print entries of a C++ dictionary
|
| pprriinntt__lliisstt(...)
- | Signature : (example.ExamplePythonTypes, list) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, list) -> None
| Print entries of a Python list
|
| pprriinntt__lliisstt__22(...)
- | Signature : (example.ExamplePythonTypes, list<unicode>) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, List[unicode]) -> None
| Print entries of a C++ list
|
| pprriinntt__sseett(...)
- | Signature : (example.ExamplePythonTypes, set) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, set) -> None
| Print entries of a Python set
|
| pprriinntt__sseett__22(...)
- | Signature : (example.ExamplePythonTypes, set<unicode>) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes, Set[unicode]) -> None
| Print entries of a C++ set
|
| tthhrrooww__eexxcceeppttiioonn(...)
- | Signature : (example.ExamplePythonTypes) -> NoneType
|
+ | Signature : (example.ExamplePythonTypes) -> None
| Throw an exception
|
| ttuuppllee__ppaasssstthhrroouugghh(...)
- | Signature : (example.ExamplePythonTypes, (bool, unicode, int)) -> (int, unicode, bool)
|
+ | Signature : (example.ExamplePythonTypes, Tuple[bool, unicode, int]) -> Tuple[int, unicode, bool]
| Return a triple in reversed order
|
| ----------------------------------------------------------------------
diff --git a/example/issues.ref b/example/issues.ref
index 90d8ce1..acb1ed0 100644
--- a/example/issues.ref
+++ b/example/issues.ref
@@ -6,7 +6,7 @@
[3, 5, 7, 9, 11, 13, 15]
0==0, 1==1, 2==2, 3==3, 4==4, 5==5, 6==6, 7==7, 8==8, 9==9,
Failed as expected: Incompatible function arguments. The following argument types are supported:
- 1. (arg0: example.issues.ElementA) -> NoneType
+ 1. (arg0: example.issues.ElementA) -> None
Invoked with: None
Failed as expected: Incompatible function arguments. The following argument types are supported:
1. (arg0: int) -> int