From 4ccf122a4bddc5f81cd5b4da76c55fe30960eda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Thu, 3 Aug 2023 14:47:22 +0200 Subject: stubs: add type for os.PathLike type hints Specifying 'str' for os.PathLike solves the issues found with tools like pyright. For example, for QUrl.fromLocalFile: error: Type of "fromLocalFile" is partially unknown Type of "fromLocalFile" is "(localfile: str | bytes | PathLike[Unknown]) -> QUrl" (reportUnknownMemberType) Using the string of the annotation to avoid an issue when Python tries to evaluate it at Runtime (see mypy issue #5667) Fixes: PYSIDE-2280 Change-Id: Ib63bfe8636fbf6cbf1e393d29ef3caf9af0fb4c7 Reviewed-by: Shyamnath Premnadh (cherry picked from commit 0e62a3d9903dd22391b769e0df0d37fdb9110d88) Reviewed-by: Qt Cherry-pick Bot --- .../shibokenmodule/files.dir/shibokensupport/signature/mapping.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 3b550b478..944a928e6 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -212,9 +212,9 @@ type_map.update({ "PyCallable": typing.Callable, "PyObject": object, "PyObject*": object, - "PyArrayObject": ArrayLikeVariable, # numpy - "PyPathLike": typing.Union[str, bytes, os.PathLike], - "PySequence": typing.Iterable, # important for numpy + "PyArrayObject": ArrayLikeVariable, # numpy + "PyPathLike": typing.Union[str, bytes, os.PathLike[str]], + "PySequence": typing.Iterable, # important for numpy "PyTypeObject": type, "QChar": str, "QHash": typing.Dict, -- cgit v1.2.3