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
|
|
@ -316,7 +316,6 @@ public:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
/* end added */
|
||||
} else if (strcmp(argv[i], "-globals") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
global_name = NewString(argv[i + 1]);
|
||||
|
|
@ -2275,7 +2274,7 @@ public:
|
|||
return parms;
|
||||
}
|
||||
|
||||
bool funcanno = py3 ? true : false;
|
||||
bool funcanno = Equal(Getattr(n, "feature:python:annotations"), "c") ? true : false;
|
||||
String *params = NewString("");
|
||||
String *_params = make_autodocParmList(n, false, ((in_class || has_self_for_count)? 2 : 1), is_calling, funcanno);
|
||||
|
||||
|
|
@ -2391,8 +2390,8 @@ public:
|
|||
if (ret)
|
||||
ret = SwigType_str(ret, 0);
|
||||
}
|
||||
return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
|
||||
: NewString("");
|
||||
bool funcanno = Equal(Getattr(n, "feature:python:annotations"), "c") ? true : false;
|
||||
return (ret && funcanno) ? NewStringf(" -> \"%s\"", ret) : NewString("");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue