diff options
| author | Christian Tismer <tismer@stackless.com> | 2020-08-20 17:48:25 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2020-08-24 12:24:35 +0200 |
| commit | acb54ac2235199cbb710799d7934e56737bacfbb (patch) | |
| tree | da9dcc722e7d52331e64983f1543571bfaea3e73 /sources/pyside2 | |
| parent | b8663129f275e2a1648090cf42c3bc673fad956c (diff) | |
signature: pass `self` directly from parser
The signature module took the info from the PyCFunction flags
for a long time to check if something is a function, method or
staticmethod.
It turned out that there are functions with multiple signatures
where the method/staticmethod info varies in the signatures.
This invalidated the PyCFunction flag usage.
Instead, we now compute that info directly from abstractmetalang.cpp
which has access to the correct info.
Fixes: PYSIDE-1328
Change-Id: I6ba7237efcc486de014184b1787d05d87bee5a5e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2')
| -rw-r--r-- | sources/pyside2/PySide2/support/generate_pyi.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py index af9f4d4f5..d71ee338e 100644 --- a/sources/pyside2/PySide2/support/generate_pyi.py +++ b/sources/pyside2/PySide2/support/generate_pyi.py @@ -171,7 +171,7 @@ class Formatter(Writer): yield @contextmanager - def function(self, func_name, signature, modifier=None): + def function(self, func_name, signature): if self.after_enum() or func_name == "__init__": self.print() key = func_name @@ -179,16 +179,16 @@ class Formatter(Writer): if type(signature) == type([]): for sig in signature: self.print('{spaces}@typing.overload'.format(**locals())) - self._function(func_name, sig, modifier, spaces) + self._function(func_name, sig, spaces) else: - self._function(func_name, signature, modifier, spaces) + self._function(func_name, signature, spaces) if func_name == "__init__": self.print() yield key - def _function(self, func_name, signature, modifier, spaces): - if modifier: - self.print('{spaces}@{modifier}'.format(**locals())) + def _function(self, func_name, signature, spaces): + if "self" not in tuple(signature.parameters.keys()): + self.print('{spaces}@staticmethod'.format(**locals())) signature = self.optional_replacer(signature) self.print('{spaces}def {func_name}{signature}: ...'.format(**locals())) |
