diff options
Diffstat (limited to 'sources/pyside2')
| -rw-r--r-- | sources/pyside2/PySide2/support/generate_pyi.py | 11 | ||||
| -rw-r--r-- | sources/pyside2/tests/registry/existence_test.py | 14 | ||||
| -rw-r--r-- | sources/pyside2/tests/registry/init_platform.py | 26 | ||||
| -rw-r--r-- | sources/pyside2/tests/registry/util.py | 2 |
4 files changed, 27 insertions, 26 deletions
diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py index d5bbe5d7c..e60645701 100644 --- a/sources/pyside2/PySide2/support/generate_pyi.py +++ b/sources/pyside2/PySide2/support/generate_pyi.py @@ -161,14 +161,11 @@ class Formatter(Writer): if self.level == 0: self.print() here = self.outfile.tell() - self.print("{spaces}class {class_str}:".format(**locals())) - pos = self.outfile.tell() - yield - if pos == self.outfile.tell(): - # we have not written any function - self.outfile.seek(here) - self.outfile.truncate() + if self.have_body: + self.print("{spaces}class {class_str}:".format(**locals())) + else: self.print("{spaces}class {class_str}: ...".format(**locals())) + yield if "<" in class_name: # This is happening in QtQuick for some reason: ## class QSharedPointer<QQuickItemGrabResult >: diff --git a/sources/pyside2/tests/registry/existence_test.py b/sources/pyside2/tests/registry/existence_test.py index fd81901b4..f5f614d04 100644 --- a/sources/pyside2/tests/registry/existence_test.py +++ b/sources/pyside2/tests/registry/existence_test.py @@ -103,8 +103,10 @@ except SyntaxError: print("*** not a python file, removed:", shortpath) os.unlink(effectiveRefPath) have_refmodule = False -if have_refmodule and not hasattr(sig_exists, "dict"): - print("*** wrong module without 'dict', removed:", shortpath) +dict_name = "sig_dict" +if have_refmodule and not hasattr(sig_exists, dict_name): + print("*** wrong module without '{dict_name}', removed:" + .format(**locals()), shortpath) os.unlink(effectiveRefPath) have_refmodule = False @@ -129,12 +131,12 @@ class TestSignaturesExists(unittest.TestCase): "Actual {len_act} {actual} vs. expected {len_exp} {expect}')" .format(**locals())) - for key, value in sig_exists.dict.items(): + for key, value in sig_exists.sig_dict.items(): name = key.rsplit(".", 1)[-1] if name in ("next", "__next__"): # ignore problematic cases continue if key not in found_sigs: - warn("missing key: '{}'".format(key)) + warn("missing key: '{}'".format(key), stacklevel=3) else: found_val = found_sigs[key] if type(value) is list and ( @@ -142,7 +144,7 @@ class TestSignaturesExists(unittest.TestCase): len(found_val) < len(value)): # We check that nothing got lost. But it is ok when an older # registry file does not know all variants, yet! - warn(multi_signature_msg(key, found_val, value)) + warn(multi_signature_msg(key, found_val, value), stacklevel=3) def test_signatures(self): found_sigs = enum_all() @@ -206,7 +208,7 @@ class TestSignaturesExists(unittest.TestCase): self.assertFalse(check_warnings(), "you ignore when arity got bigger") -tested_versions = (5, 6), (5, 9), (5, 11), (5, 12) +tested_versions = (5, 6), (5, 9), (5, 11), (5, 12), (5, 14) if not have_refmodule and is_ci and qt_version()[:2] in tested_versions: class TestFor_CI_Init(unittest.TestCase): diff --git a/sources/pyside2/tests/registry/init_platform.py b/sources/pyside2/tests/registry/init_platform.py index 31e212287..1c4261b4b 100644 --- a/sources/pyside2/tests/registry/init_platform.py +++ b/sources/pyside2/tests/registry/init_platform.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2018 The Qt Company Ltd. +## Copyright (C) 2019 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of Qt for Python. @@ -201,39 +201,41 @@ class Formatter(object): """ def __init__(self, outfile): self.outfile = outfile + self.last_level = 0 def print(self, *args, **kw): print(*args, file=self.outfile, **kw) if self.outfile else None @contextmanager def module(self, mod_name): - self.mod_name = mod_name self.print("") self.print("# Module", mod_name) - self.print('if "{}" in sys.modules:'.format(mod_name)) - self.print(" dict.update({") + self.print("sig_dict.update({") yield - self.print(" })") + self.print(' }}) if "{mod_name}" in sys.modules else None'.format(**locals())) @contextmanager def klass(self, class_name, class_str): - self.class_name = class_name self.print() - self.print(" # class {}.{}:".format(self.mod_name, class_name)) + self.print("# class {self.mod_name}.{class_name}:".format(**locals())) yield @contextmanager def function(self, func_name, signature): - if self.class_name is None: - key = viskey = "{}".format(func_name) + if self.last_level > self.level: + self.print() + self.last_level = self.level + class_name = self.class_name + if class_name is None: + key = viskey = "{self.mod_name}.{func_name}".format(**locals()) else: - key = viskey = "{}.{}".format(self.class_name, func_name) + key = viskey = "{self.mod_name}.{class_name}.{func_name}".format(**locals()) if key.endswith("lY"): # Some classes like PySide2.QtGui.QContextMenuEvent have functions # globalX and the same with Y. The gerrit robot thinks that this # is a badly written "globally". Convince it by hiding this word. viskey = viskey[:-1] + '""Y' - self.print(' "{}": {},'.format(viskey, signature)) + self.print(' "{viskey}": {signature},'.format(**locals())) yield key @@ -268,7 +270,7 @@ def generate_all(): '''.format(module))) fmt.print("import sys") fmt.print("") - fmt.print("dict = {}") + fmt.print("sig_dict = {}") for mod_name in all_modules: enu.module(mod_name) fmt.print("# eof") diff --git a/sources/pyside2/tests/registry/util.py b/sources/pyside2/tests/registry/util.py index 415b8aa45..3033608e6 100644 --- a/sources/pyside2/tests/registry/util.py +++ b/sources/pyside2/tests/registry/util.py @@ -91,7 +91,7 @@ def check_warnings(): return True return False -def warn(message, category=None, stacklevel=1): +def warn(message, category=None, stacklevel=2): """Issue a warning with the default 'RuntimeWarning'""" if category is None: category = UserWarning |
