diff options
4 files changed, 20 insertions, 16 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 791a7799f..d8cadc6f6 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -1841,7 +1841,7 @@ <inject-documentation format="target" mode="append" file="../doc/qtcore.rst" snippet="qobject-findChild"/> <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qobject-findchild-2"/> - <modify-argument index="return" pyi-type="Optional[PlaceHolderType]"> + <modify-argument index="return" pyi-type="Optional[PlaceholderType]"> <parent index="this" action="add"/> </modify-argument> </add-function> @@ -1851,14 +1851,14 @@ Like the method *findChild*, the first parameter should be the child's type. </inject-documentation> <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qobject-findchildren"/> - <modify-argument index="return" pyi-type="Iterable[PlaceHolderType]"> + <modify-argument index="return" pyi-type="List[PlaceholderType]"> <parent index="this" action="add"/> </modify-argument> </add-function> <add-function signature="findChildren(PyTypeObject*@type@,const QRegularExpression&@pattern@,Qt::FindChildOptions@options@=Qt::FindChildrenRecursively)" return-type="PySequence*" > <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qobject-findchildren"/> - <modify-argument index="return" pyi-type="Iterable[PlaceHolderType]"> + <modify-argument index="return" pyi-type="List[PlaceholderType]"> <parent index="this" action="add"/> </modify-argument> </add-function> diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/layout.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/layout.py index da7962ec7..f7b974622 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/layout.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/layout.py @@ -370,7 +370,7 @@ def create_signature_union(props, key): def transform(signature): # Change the annotations of the parameters to use "|" syntax. - parameters = [] + params = [] changed = False for idx, param in enumerate(signature.parameters.values()): ann = param.annotation @@ -379,9 +379,13 @@ def transform(signature): ann = reduce(operator.or_, args) param = param.replace(annotation=ann) changed = True - parameters.append(param) - - return signature.replace(parameters=parameters) if changed else signature + params.append(param) + ann = signature.return_annotation + if typing.get_origin(ann) is typing.Union: + args = typing.get_args(ann) + ann = reduce(operator.or_, args) + changed = True + return signature.replace(parameters=params, return_annotation=ann) if changed else signature def create_signature(props, key): 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 b9d7f71b2..5213b8cab 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 @@ -105,9 +105,9 @@ class Formatter(Writer): @classmethod def last_fixups(cls, source): # PYSIDE-2517: findChild/findChildren type hints: - # PlaceHolderType fix to avoid the '~' from TypeVar.__repr__ - if "~PlaceHolderType" in source: - source = source.replace("~PlaceHolderType", "PlaceHolderType") + # PlaceholderType fix to avoid the '~' from TypeVar.__repr__ + if "~PlaceholderType" in source: + source = source.replace("~PlaceholderType", "PlaceholderType") # Replace all "NoneType" strings by "None" which is a typing convention. return source.replace("NoneType", "None") @@ -115,9 +115,9 @@ class Formatter(Writer): @classmethod def optional_replacer(cls, source): # PYSIDE-2517: findChild/findChildren type hints: - # PlaceHolderType fix to avoid the '~' from TypeVar.__repr__ - if "~PlaceHolderType" in source: - source = source.replace("~PlaceHolderType", "PlaceHolderType") + # PlaceholderType fix to avoid the '~' from TypeVar.__repr__ + if "~PlaceholderType" in source: + source = source.replace("~PlaceholderType", "PlaceholderType") while match := cls.opt_uni_searcher.search(source): start = match.start() @@ -351,7 +351,7 @@ def generate_pyi(import_name, outpath, options): # We use it only in QtCore at the moment, but this # could be extended to other modules. (must import QObject then) if import_name == "PySide6.QtCore": - wr.print("PlaceHolderType = typing.TypeVar(\"PlaceHolderType\", " + wr.print("PlaceholderType = typing.TypeVar(\"PlaceholderType\", " "bound=PySide6.QtCore.QObject)") wr.print() else: diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 204d48dc5..8b4ada77c 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -48,7 +48,7 @@ NoneType = type(None) # PYSIDE-2517: findChild/findChildren type hints: # Placeholder so it does not trigger an UNDEFINED error while building. # Later it will be bound to a QObject, within the QtCore types extensions -PlaceHolderType = TypeVar("PlaceHolderType") +PlaceholderType = TypeVar("PlaceholderType") _S = TypeVar("_S") @@ -497,7 +497,7 @@ def init_PySide6_QtCore(): "NULL": None, # 5.6, MSVC "nullptr": None, # 5.9 # PYSIDE-2517: findChild/findChildren type hints: - "PlaceHolderType": typing.TypeVar("PlaceHolderType", bound=PySide6.QtCore.QObject), + "PlaceholderType": typing.TypeVar("PlaceholderType", bound=PySide6.QtCore.QObject), "PyBuffer": typing.Union[bytes, bytearray, memoryview], "PyByteArray": bytearray, "PyBytes": typing.Union[bytes, bytearray, memoryview], |
