Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2379

pyside6-lupdate names the context incorrectly when indentation detection is offset by oddly indented multiline string or similar

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.6.0
    • 6.5.2
    • Tooling
    • None
    • acb4e247f (dev), 4710b9628 (6.5), 2445e3e57 (6.6)

    Description

      Consider the following code:

      """
           5 or more space indentation and a ) or ] or }
      """
      
      from __future__ import (barry_as_FLUFL,
                              annotations,  # 5 or more space indentation inside parentheses
      )
      
      from typing import Literal
      
      from PySide6.QtCore import QObject
      
      egg = ['spam',
             'egg']  # 5 or more space indentation inside brackets
      spam = {'spam',
              'egg'}  # 5 or more space indentation inside braces
      
      def bar(spam: Literal[')'],
              egg: Literal['(']):  # 5 or more space indentation inside parentheses
          pass
      
      class Spam(QObject):
          """
              this line does NOT cause any trouble :-)
          """
          class Egg:
              pass
      
          def spam(self) -> None:
              self.tr('NOT in the Egg class!')
      

      When I feed any of them to pyside6-lupdate, I get the following TS file:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE TS>
      <TS version="2.1">
      <context>
          <name>Egg</name>
          <message>
              <source>NOT in the Egg class!</source>
          </message>
      </context>
      </TS>
      

      The context name is incorrect. It happens if I have a line that is indented by more than 4 spaces (i.e., of imported stuff or docs, copyright, etc.) and inside parentheses/brackets/braces before the class. I got several cases here to test. Any single one of them reproduces the issue.

      The same problem occurs with lupdate for PyQt5, and I guess that PySide2 may experience it as well.

      Attachments

        1. pyside2379_diag.diff
          4 kB
        2. pyside2379_log.txt
          0.5 kB
        3. pyside2379.py
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            stsav012 Anton Yablokov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes