Python function annotations removed from -py3 option.
Python function annotations containing C/C++ types are no longer
generated when using the -py3 option. Function annotations support
has been moved to a feature to provide finer grained control.
It can be turned on globally by adding:
%feature("python:annotations", "c");
or by using the command line argument:
-features python:annotations=c
The implementation is designed to be expandable to support different
annotations implementations. Future implementations could implement
something like the following for generating pure Python types:
%feature("python:annotations", "python");
or typing module types to conform to PEP-484:
%feature("python:annotations", "typing");
Closes #1561
Issue #735
This commit is contained in:
parent
bf382f01b4
commit
2072ae19c9
7 changed files with 133 additions and 33 deletions
|
|
@ -48,6 +48,7 @@ CPP_TEST_CASES += \
|
|||
li_std_wstring_inherit \
|
||||
primitive_types \
|
||||
python_abstractbase \
|
||||
python_annotations_c \
|
||||
python_append \
|
||||
python_builtin \
|
||||
python_destructor_exception \
|
||||
|
|
|
|||
27
Examples/test-suite/python/python_annotations_c_runme.py
Normal file
27
Examples/test-suite/python/python_annotations_c_runme.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import sys
|
||||
|
||||
if sys.version_info[0:2] >= (3, 2):
|
||||
from python_annotations_c import *
|
||||
|
||||
anno = MakeShort.__annotations__
|
||||
if anno != {'x': 'int', 'return': 'Space::Template< short >'}:
|
||||
raise RuntimeError("annotations mismatch: {}".format(anno))
|
||||
|
||||
anno = global_ints.__annotations__
|
||||
if anno != {'ri': 'int &', 't': 'TemplateShort', 'return': 'int *'}:
|
||||
raise RuntimeError("annotations mismatch: {}".format(anno))
|
||||
|
||||
ts = MakeShort(10)
|
||||
|
||||
anno = MakeShort.__annotations__
|
||||
if anno != {'x': 'int', 'return': 'Space::Template< short >'}:
|
||||
raise RuntimeError("annotations mismatch: {}".format(anno))
|
||||
|
||||
anno = ts.mymethod.__annotations__
|
||||
if anno != {'arg2': 'int', 'tt': 'TemplateShort', 'return': 'void'}:
|
||||
raise RuntimeError("annotations mismatch: {}".format(anno))
|
||||
|
||||
# No annotations
|
||||
anno = no_annotations.__annotations__
|
||||
if anno != {}:
|
||||
raise RuntimeError("annotations mismatch: {}".format(anno))
|
||||
Loading…
Add table
Add a link
Reference in a new issue