diff options
| author | Christian Tismer <tismer@stackless.com> | 2024-10-12 17:03:18 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2024-10-17 15:09:21 +0200 |
| commit | 7ee3fb7958d6384baf3d1bd4cfe4931cacfa77df (patch) | |
| tree | c54580d70c03db917873db2fa717607e31bd541a | |
| parent | 9af99c2fd8ed6b8b8959b1b33717989d51555e3d (diff) | |
type hints: Fix typing.Callable to include parameters
All callables have now arguments.
Task-number: PYSIDE-2846
Fixes: PYSIDE-2884
Change-Id: Ibf6b1d93350304550addbc459c1440bd5cefc057
Pick-to: 6.8
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
5 files changed, 25 insertions, 15 deletions
diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp index 6ba76200a..bbc289231 100644 --- a/sources/pyside6/libpyside/pysideproperty.cpp +++ b/sources/pyside6/libpyside/pysideproperty.cpp @@ -470,16 +470,20 @@ static PyObject *getFromType(PyTypeObject *type, PyObject *name) namespace PySide::Property { 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," + "PySide6.QtCore.Property(self,type:type," + "fget:typing.Optional[typing.Callable[[typing.Any],typing.Any]]," + "fset:typing.Optional[typing.Callable[[typing.Any,typing.Any],None]]," + "freset:typing.Optional[typing.Callable[[typing.Any,typing.Any],None]]," + "doc:str=None," + "notify:typing.Optional[typing.Callable[[],None]]," + "designable:bool=True,scriptable:bool=True," "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", - "PySide6.QtCore.Property.setter(self,fset:typing.Callable)->PySide6.QtCore.Property", - "PySide6.QtCore.Property.write(self,fset:typing.Callable)->PySide6.QtCore.Property", - "PySide6.QtCore.Property.__call__(self, func:typing.Callable)->PySide6.QtCore.Property", + "PySide6.QtCore.Property.deleter(self,fdel:typing.Callable[[typing.Any],None])->PySide6.QtCore.Property", + "PySide6.QtCore.Property.getter(self,fget:typing.Callable[[typing.Any],typing.Any])->PySide6.QtCore.Property", + "PySide6.QtCore.Property.read(self,fget:typing.Callable[[typing.Any],typing.Any])->PySide6.QtCore.Property", + "PySide6.QtCore.Property.setter(self,fset:typing.Callable[[typing.Any,typing.Any],None])->PySide6.QtCore.Property", + "PySide6.QtCore.Property.write(self,fset:typing.Callable[[typing.Any,typing.Any],None])->PySide6.QtCore.Property", + "PySide6.QtCore.Property.__call__(self, func:typing.Callable[...,typing.Any])->PySide6.QtCore.Property", nullptr}; // Sentinel void init(PyObject *module) diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp index 23e8068d6..0a448852e 100644 --- a/sources/pyside6/libpyside/pysideslot.cpp +++ b/sources/pyside6/libpyside/pysideslot.cpp @@ -168,7 +168,7 @@ DataList *dataListFromCapsule(PyObject *capsule) static const char *Slot_SignatureStrings[] = { "PySide6.QtCore.Slot(self,*types:type,name:str=nullptr,result:type=nullptr)", - "PySide6.QtCore.Slot.__call__(self,function:typing.Callable)->typing.Any", + "PySide6.QtCore.Slot.__call__(self,function:typing.Callable[[typing.Any],typing.Any])->typing.Any", nullptr}; // Sentinel void init(PyObject *module) diff --git a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp index c66d870b9..5722dd441 100644 --- a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp +++ b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp @@ -280,8 +280,11 @@ void QmlListPropertyPrivate::metaCall(PyObject *source, QMetaObject::Call call, } static const char *PropertyList_SignatureStrings[] = { - "PySide6.QtQml.ListProperty(self,type:type,append:typing.Callable," - "at:typing.Callable=None,clear:typing.Callable=None,count:typing.Callable=None)", + "PySide6.QtQml.ListProperty(self,type:type," + "append:typing.Optional[typing.Callable[...,typing.Any]]=None," + "at:typing.Optional[typing.Callable[...,typing.Any]]=None," + "clear:typing.Optional[typing.Callable[...,typing.Any]]=None," + "count:typing.Optional[typing.Callable[...,typing.Any]]=None)", nullptr // Sentinel }; diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 22b9e1e5f..b2eb4e65e 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -32,7 +32,7 @@ class ellipsis(object): ellipsis = ellipsis() Point = typing.Tuple[int, int] Variant = typing.Any -QImageCleanupFunction = typing.Callable +QImageCleanupFunction = typing.Callable[..., typing.Any] # unfortunately, typing.Optional[t] expands to typing.Union[t, NoneType] # Until we can force it to create Optional[t] again, we use this. @@ -216,7 +216,7 @@ type_map.update({ "long": int, "long long": int, "nullptr": None, - "PyCallable": typing.Callable, + "PyCallable": typing.Callable[..., typing.Any], "PyObject": object, "PyObject*": object, "PyArrayObject": ArrayLikeVariable(typing.Any), # numpy @@ -308,7 +308,7 @@ type_map.update({ # This can be refined by importing numpy.typing optionally, but better than nothing. "numpy.ndarray": typing.List[typing.Any], "std.array[int, 4]": typing.List[int], - "std.array[float, 4]": typing.List[float] + "std.array[float, 4]": typing.List[float], }) type_map.update({ diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py index 896afe0f9..750810dcf 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py @@ -337,6 +337,9 @@ def _resolve_type(thing, line, level, var_handler, func_name=None): # Now the nested structures are handled. if "[" in thing: + # Special case: Callable[[], + if thing == "[]": + return thing # handle primitive arrays if re.search(r"\[\d*\]$", thing): thing = _resolve_arraytype(thing, line) |
