diff options
author | Christian Tismer <tismer@stackless.com> | 2023-03-07 14:55:51 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-07 16:33:59 +0000 |
commit | 0ff77d558f0c5126230c3cd9fcf07f994ea6debf (patch) | |
tree | 9d220a28a62035ee2661b08cd31e09966a45c478 | |
parent | 30614ffb138a2858325d1041fbfa8aec130506df (diff) |
pyi_generator: Generate imports only for external classes
If a modules uses a class that it also creates in the same
module, then it must omit the import statement.
Change-Id: I71acf1e2d7c4aba65cc3d0fb0668cf779e70d80c
Fixes: PYSIDE-1603
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 0142b21d429a7cf0ef78a5bf9a0d972c2a7223b2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py | 7 |
1 files changed, 5 insertions, 2 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 bbca35fbd..437dd1316 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 @@ -180,8 +180,11 @@ def filter_from_imports(from_struct, text): lis = [] nfs.append((mod, lis)) for each in imports: - if re.search(rf"(\b|@){each}\b([^\s\(:]|\n)", text): - lis.append(each) + # PYSIDE-1603: We search text that is a usage of the class `each`, + # but only if the class is not also defined here. + if (f"class {each}(") not in text: + if re.search(rf"(\b|@){each}\b([^\s\(:]|\n)", text): + lis.append(each) if not lis: nfs.pop() return nfs |