[BUG] sip: Type stub generated with --pep484-pyi is wrong when using %HideNamespace

Greger Stolt Nilsen gregersn at gmail.com
Thu Dec 16 08:36:45 GMT 2021


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: ...



More information about the PyQt mailing list