From acb4e247fdf42af633b03e86da4eaf771f66c125 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Jul 2023 14:40:03 +0200 Subject: lupdate: Improve indentation calculation for Python code Introduce a "def" token for function definitions and perform the calculation of the indentation as well as the pushing/popping of class contexts only for "class" and "def". Fixes: PYSIDE-2379 Pick-to: 6.6 6.5 Change-Id: Ic59af41afbb5ca602c110c3f25dfc953000467d8 Reviewed-by: Shyamnath Premnadh Reviewed-by: Cristian Maureira-Fredes --- .../auto/linguist/lupdate/testdata/good/parsepython/main.py | 10 ++++++++-- .../lupdate/testdata/good/parsepython/project.ts.result | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py b/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py index 6375ff4da..e2bf9ac93 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py +++ b/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py @@ -5,10 +5,10 @@ from PySide6.QtCore import (QItemSelection, QLibraryInfo, QLocale, QTranslator, Qt, Slot) from PySide6.QtWidgets import (QAbstractItemView, QApplication, QListWidget, QMainWindow, QWidget) - - import linguist_rc +"""" + Misleading indentation (5) for PYSIDE-2379""" class Window(QMainWindow): def __init__(self): @@ -66,6 +66,12 @@ class Window(QMainWindow): "THIS SHOULD NOT WORK" ) + class NestedClass: + def foo(self): + msg = self.tr("Nested Message") + + def window_method(self): # PYSIDE-2379, Don't put this into NestedClass + msg = self.tr("Window Message") if __name__ == '__main__': diff --git a/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result index f081bc23a..658485339 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result @@ -37,6 +37,14 @@ + + NestedClass + + + Nested Message + + + Window @@ -72,5 +80,10 @@ + + + Window Message + + -- cgit v1.2.3