diff options
author | Christian Tismer <tismer@stackless.com> | 2021-05-26 19:23:32 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2021-06-10 19:16:07 +0200 |
commit | 6acc53a4e426fee336a8577581f579d6c173c7bc (patch) | |
tree | e5ceff840d592ae33c42f40b731447b7fe87ddea /sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py | |
parent | 5237a185d3a89bf03af7699a3b2f3d3745d2e46c (diff) |
PyClassProperty: Correct the decorator and publish the class
PyClassProperty is now correctly published as a QtCore class
and existing as an import.
As a side effect, a bug was fixed where a syntax error
occurred because of a missing signature count.
Task-number: PYSIDE-1019
Fixes: PYSIDE-1593
Change-Id: Iae733280d9f9c23244e83a356011104bf527c329
Pick-to: 6.1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py')
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py index f81e738b2..3c4efebda 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py @@ -146,7 +146,6 @@ class Formatter(Writer): from shiboken6 import Shiboken - import typing <<IMPORTS>> """ self.print(dedent(txt)) @@ -158,7 +157,6 @@ class Formatter(Writer): while "." in class_name: class_name = class_name.split(".", 1)[-1] class_str = class_str.split(".", 1)[-1] - here = self.outfile.tell() if self.have_body: self.print(f"{spaces}class {class_str}:") else: @@ -173,7 +171,7 @@ class Formatter(Writer): spaces = indent * self.level if isinstance(signature, list): for sig in signature: - self.print(f'{spaces}@typing.overload') + self.print(f'{spaces}@overload') self._function(func_name, sig, spaces) else: self._function(func_name, signature, spaces, decorator) @@ -183,8 +181,9 @@ class Formatter(Writer): def _function(self, func_name, signature, spaces, decorator=None): if decorator: + # In case of a PyClassProperty the classmethod decorator is not used. self.print(f'{spaces}@{decorator}') - if self.is_method() and "self" not in signature.parameters: + elif self.is_method() and "self" not in signature.parameters: kind = "class" if "cls" in signature.parameters else "static" self.print(f'{spaces}@{kind}method') signature = self.optional_replacer(signature) @@ -211,8 +210,8 @@ def find_imports(text): FROM_IMPORTS = [ - ("typing", "Any Callable Dict List Optional Tuple Union".split()), - ("PySide6", ["PyClassProperty"]), + ("typing", "Any Callable Dict List Optional overload Tuple Union".split()), + ("PySide6.QtCore", ["PyClassProperty"]), ] def filter_from_imports(from_struct, text): |