Invalid python code generation for c-methods with empty parameter names
While trying to improve the python type-stubs i noticed the following:
In aui.pyi:
class AuiTabArt(object):
def GetBestTabCtrlSize(self, , , ): ...
Notice the empty parameter names. I think this is because the original wxWidgets source does indeed not define parameter names for this function here:
virtual int GetBestTabCtrlSize(wxWindow*, const wxAuiNotebookPageArray&, const wxSize&) = 0;
Maybe this is unintended in the first place but afaiu valid c code. The issue is that this is ofc not valid in python.
I tried to manually generate at least some dummy parameter names in etgtools/extractors.py FunctionDef.makePyArgsString(...). This leads to valid pyhon code, but throws the following warnings, suggesting that this might not be ideal:
$ python build.py etg ❮❮
Will build using: ".../Phoenix/.venv/bin/python"
3.11.9 (main, Sep 19 2024, 00:28:50) [GCC 14.2.1 20240805]
Python's architecture is 64bit
cfg.VERSION: 4.2.4a1
...
SEVERE: Incompatibility between function/method signature and list of parameters in `wx.aui.AuiTabArt.GetBestTabCtrlSize`:
The parameter `_param_0: wx.Window` appears in the method signature but could not be found in the parameter list.
==> Function/Method signature from `extractors`: def GetBestTabCtrlSize(self, _param_0: wx.Window, _param_1: AuiNotebookPageArray, _param_2: wx.Size) -> int:
==> Parameter list from wxWidgets XML items: ['']
This may be a documentation bug in wxWidgets or a side-effect of removing the `wx` prefix from signatures.
...
Have you got any ideas for a better solution? Maybe the function definition can be changed manually in etg/auibook.py or the warning can simply be silenced?
And do you think its worth filing an issue upstream? (I think this is a bug in wxPython specifically anyways!)
Do you know how many cases of this there are? If there are just a few, we could probably just submit the changes upstream. Specifically in the case of GetBestTabCtrlSize, the real code in include/wx/aui/tabart.h has parameter names.
I think these should be it:
$ rg --no-ignore-vcs '_param_\d:' wx/ ❮❮
wx/grid.pyi
2148: def SetCornerLabelValue(self, _param_0: str) -> None:
2524: def SetCornerLabelValue(self, _param_0: str) -> None:
2864: def SetCornerLabelValue(self, _param_0: str) -> None:
4800: def SetCellHighlightColour(self, _param_0: Union[wx.Colour, wx.Colour, wx._ThreeInts, wx._FourInts, str, None]) -> None:
4815: def SetGridFrozenBorderColour(self, _param_0: Union[wx.Colour, wx.Colour, wx._ThreeInts, wx._FourInts, str, None]) -> None:
wx/aui.pyi
3333: def GetBestTabCtrlSize(self, _param_0: wx.Window, _param_1: AuiNotebookPageArray, _param_2: Union[wx.Size, wx._TwoInts]) -> int:
3517: def GetBestTabCtrlSize(self, _param_0: wx.Window, _param_1: AuiNotebookPageArray, _param_2: Union[wx.Size, wx._TwoInts]) -> int:
3636: def GetBestTabCtrlSize(self, _param_0: wx.Window, _param_1: AuiNotebookPageArray, _param_2: Union[wx.Size, wx._TwoInts]) -> int:
(_param_ is from my first attempted fix)
So there are a few methods, but not very many. I think we should at least emit a warning when encountering such a situation even when fixing them upstream?