aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-10-19 10:10:21 +0200
committerChristian Tismer <tismer@stackless.com>2021-10-19 17:16:47 +0200
commiteec7ff0c4096379a92975e9a7ca0aa35672aff1e (patch)
tree04d6effd212a9770738ab88c9bc1b70392c841cf
parent0bb9ff7925eca9616937b170c71a8581990a38dd (diff)
Improve the MyPy support, first systematic changes
* hand-crafted class signatures don't have a return type (__init__) * make optional typing imports complete * skip imports which are defined in the same module Task-number: PYSIDE-1675 Change-Id: I30950e16347158804430e04f93254f0177d2a506 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/pyside6/libpyside/class_property.cpp3
-rw-r--r--sources/pyside6/libpyside/pysideproperty.cpp3
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py4
3 files changed, 4 insertions, 6 deletions
diff --git a/sources/pyside6/libpyside/class_property.cpp b/sources/pyside6/libpyside/class_property.cpp
index 74ee79e4d..5dbb4e4f7 100644
--- a/sources/pyside6/libpyside/class_property.cpp
+++ b/sources/pyside6/libpyside/class_property.cpp
@@ -152,8 +152,7 @@ static const char *PyClassProperty_SignatureStrings[] = {
"fget:typing.Optional[typing.Callable[[typing.Any],typing.Any]]=None,"
"fset:typing.Optional[typing.Callable[[typing.Any,typing.Any],None]]=None,"
"fdel:typing.Optional[typing.Callable[[typing.Any],None]]=None,"
- "doc:typing.Optional[str]=None)"
- "->PySide6.QtCore.PyClassProperty",
+ "doc:typing.Optional[str]=None)",
"PySide6.QtCore.PyClassProperty.getter(cls,fget:typing.Callable[[typing.Any],typing.Any])->PySide6.QtCore.PyClassProperty",
"PySide6.QtCore.PyClassProperty.setter(cls,fset:typing.Callable[[typing.Any,typing.Any],None])->PySide6.QtCore.PyClassProperty",
"PySide6.QtCore.PyClassProperty.deleter(cls,fdel:typing.Callable[[typing.Any],None])->PySide6.QtCore.PyClassProperty",
diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp
index 9f9340e19..25475cb61 100644
--- a/sources/pyside6/libpyside/pysideproperty.cpp
+++ b/sources/pyside6/libpyside/pysideproperty.cpp
@@ -450,8 +450,7 @@ static const char *Property_SignatureStrings[] = {
"PySide6.QtCore.Property(self,type:type,fget:typing.Callable=None,fset:typing.Callable=None,"
"freset:typing.Callable=None,fdel:typing.Callable=None,doc:str=None,"
"notify:typing.Callable=None,designable:bool=True,scriptable:bool=True,"
- "stored:bool=True,user:bool=False,constant:bool=False,final:bool=False)"
- "->PySide6.QtCore.Property",
+ "stored:bool=True,user:bool=False,constant:bool=False,final:bool=False)",
"PySide6.QtCore.Property.deleter(self,fdel:typing.Callable)->PySide6.QtCore.Property",
"PySide6.QtCore.Property.getter(self,fget:typing.Callable)->PySide6.QtCore.Property",
"PySide6.QtCore.Property.read(self,fget:typing.Callable)->PySide6.QtCore.Property",
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 f24487c8f..8a786b574 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
@@ -196,7 +196,7 @@ def find_imports(text):
FROM_IMPORTS = [
- ("typing", "Any Callable Dict List Optional overload Tuple Union".split()),
+ ("typing", typing.__all__),
("PySide6.QtCore", ["PyClassProperty"]),
(None, ["builtins"]),
]
@@ -287,7 +287,7 @@ def generate_pyi(import_name, outpath, options):
if mod is None:
# special case, a normal import
wr.print(f"import {import_args}")
- else:
+ elif mod != import_name:
wr.print(f"from {mod} import {import_args}")
wr.print()
if need_imports: