diff options
author | Christian Tismer <tismer@stackless.com> | 2020-05-04 17:38:04 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-05-14 15:26:11 +0200 |
commit | d6b81b6303957803582d0fae95a9b25483d8e7f2 (patch) | |
tree | aab5f9f3438eb59c21ecc18530c0c48e5c10a393 /sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py | |
parent | f6519b1d343bc26a53374d3066e90495f1959c78 (diff) |
shiboken: Prepare for introduction of __qualname__
To remove the groundwork from the next checkin, the step
of replacing PyType_FromSpec with SbkType_FromSpec
is extracted.
This change introduces a packageLevel number that is generated
as a name prefix in the class creation but does not use it, yet.
Change-Id: Ic9061231708b546dbd3620d148bca24c27df60a5
Task-number: PYSIDE-1286
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@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.py | 8 |
1 files changed, 6 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 6564786b9..1efc6fde5 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py @@ -75,14 +75,18 @@ try: except NameError: ModuleNotFoundError = ImportError +def _qualname(x): + return getattr(x, "__qualname__", x.__name__) + # patching inspect's formatting to keep the word "typing": def formatannotation(annotation, base_module=None): # if getattr(annotation, '__module__', None) == 'typing': # return repr(annotation).replace('typing.', '') if isinstance(annotation, type): + name = _qualname(annotation) if annotation.__module__ in ('builtins', base_module): - return annotation.__qualname__ - return annotation.__module__ + '.' + annotation.__qualname__ + return name + return annotation.__module__ + '.' + name return repr(annotation) # Note also that during the tests we have a different encoding that would |