aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-04-19 16:46:18 +0200
committerChristian Tismer <tismer@stackless.com>2020-04-21 13:20:45 +0200
commit205f77e056cc1bf0b48ac334fb106c1490d84f77 (patch)
treeb20c75523a1976985ee061c1cc52b0e680f441a4 /sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
parentb0bfeaf894344e31b5175dbbd3ce371fae5dee5b (diff)
signature: Fix and simplify for mypy compatibility
There was a problem with the typing module for Python2 that showed the wrong name. The generated signature files are further simplified. They no longer contain fancy definitions like "Char", which made little sense and was replaced by "int", which our competitor does as well. The mypy compatibility should be considered mostly complete. Update.. QChar was not changed to "int" but "str" because we got clashes. Therefore, recreation of the registry was necessary. Hard to solve stay the definitions "Virtual, Missing, Invalid, Default, Instance". They are very rarely used for special cases. Mypy cannot see these definitions since the module path does not exist in the file system. I tried hard to fix this by building a mypy plugin, but I seem to be forced to generate real files in a temp dir. This was too much effort. A plugin may make sense in the future when we need to improve the type support. Change-Id: Id80c2da1a4a379a80ec5f3019a916a9c00cc87ff Task-number: PYSIDE-1100 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py')
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
index a0367883a..6564786b9 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
@@ -152,10 +152,12 @@ if sys.version_info >= (3,):
import inspect
inspect.formatannotation = formatannotation
else:
- if "typing" not in sys.modules:
+ tp_name = "typing"
+ if tp_name not in sys.modules:
orig_typing = False
from shibokensupport import typing27 as typing
- sys.modules["typing"] = typing
+ sys.modules[tp_name] = typing
+ typing.__name__ = tp_name
else:
import typing
import inspect