[BUG] sip: Type stub generated with --pep484-pyi is wrong when using %HideNamespace
Phil Thompson
phil at riverbankcomputing.com
Sun Dec 19 17:10:26 GMT 2021
On 16/12/2021 08:36, Greger Stolt Nilsen wrote:
> Sip-version used: 6.5
>
> The %HideNamespace directive is ignored by the type stub generation.
>
> Functions that are at defined inside the hidden namespace still gets
> "self" as first parameter in Python type files, even though they
> should not, when that namespace is hidden.
>
> Modifying the .pyi file manually fixes the problem.
>
> Minimal example:
>
> ```foo.h
> namespace HideMe
> {
> int calc(int a, int b);
> }
> ```
>
>
> ```foo.sip
> %Module(name=foo, call_super_init=True, keyword_arguments="All")
>
> %DefaultEncoding "UTF-8"
>
> %HideNamespace(name=HideMe)
> %ModuleCode
> #include "foo.h"
> %End
>
> namespace HideMe {
> int calc(int a, int b);
> };
> ```
>
> ```pyproject.toml
> [build-system]
> requires = ["sip >=5, <6"]
> build-backend = "sipbuild.api"
>
> [tool.sip.metadata]
> name = "foo"
>
> [tool.sip.bindings.foo]
> headers = ["foo.h"]
> include-dirs = ["."]
> ```
>
> build with: sip-build --pep484-pyi
>
> observe in file ./build/foo/foo.pyi:
> def calc(self, a: int, b: int) -> int: ...
>
> should be:
>
> def calc(a: int, b: int) -> int: ...
Hopefully fixed in the next snapshot.
Thanks,
Phil
More information about the PyQt
mailing list