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

mark boolean setters parameter as positional-only

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.x
    • Type hints
    • None

    Description

      QTableView.setAlternatingRowColors, QTableView.setShowGrid, QTableView.setSortingEnabled, QTableView.setWordWrap, QHeaderView.setCascadingSectionResizes, QHeaderView.setStretchLastSection, QHeaderView.setVisible, are just some examples of the various setters the PySide object expose.

      In their type hints, you can see (for example)

      def setVisible(self, v: bool) -> None: ...

      but if you try to invoke the methods by keword (as for example suggested by some linters, like https://docs.astral.sh/ruff/rules/boolean-positional-value-in-call/ ) there are runtime errors, like

      TypeError: QHeaderView.setVisible() takes no keyword arguments

      you could mark the various methods to accept positional only parameters, just adding a ,/ after the boolean parameter

      ref: pep 570

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ctismer Christian Tismer
            zeed Vito De Tullio
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes