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

pyside2uic >= 5.13.0 Broke Backward API Compatibility

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.13.0, 5.13.1
    • PySide
    • None
    • All

    Description

      The public pyside2uic.Compiler.compiler.UICompiler() constructor is an integral component of the public API for the pyside2uic package. Ideally, this API and hence this constructor would preserve backward compatibility with prior pyside2uic versions.

      Sadly, it did not. pyside2uic >= 5.13.0 broke backward API compatibility by requiring the public pyside2uic.Compiler.compiler.UICompiler() constructor be passed a new mandatory all_pyside2_modules parameter. Since the pyside2uic.init.compileUi() function defaults this parameter to simply PySide2.__all__ (i.e., the list of the basenames of all installed PySide2 C extensions), it would have been trivial for Qt engineers to render this parameter optional using the same default.

      Currently, this constructor's implementation resembles:

      class UICompiler(UIParser):
          def __init__(self, all_pyside2_modules):
              UIParser.__init__(self, qtproxies.QtCore, qtproxies.QtGui, qtproxies.QtWidgets,
                      CompilerCreatorPolicy(all_pyside2_modules))
      

      Ideally, this constructor's implementation would instead resemble:

      class UICompiler(UIParser):
          def __init__(self, all_pyside2_modules = PySide2.__all__):
              UIParser.__init__(self, qtproxies.QtCore, qtproxies.QtGui, qtproxies.QtWidgets,
                      CompilerCreatorPolicy(all_pyside2_modules))
      

      Note the defaulting of the now optional all_pyside2_modules parameter to PySide2.__all__.

      Our PySide2-based multiphysics biology simulator currently circumvents this issue via the following conditional logic:

          try:
              ui_compiler = pyside2uic.Compiler.compiler.UICompiler(PySide2.__all__)
          except TypeError:
              ui_compiler = pyside2uic.Compiler.compiler.UICompiler()
      

      While non-ideal, this does technically work – for now, anyway. As this constructor continues to add parameters, however, the above kludge will inevitably fail to scale.

      In theory, that too could probably be circumvented by explicitly testing the current version of the pyside2uic package and calling this constructor accordingly. Sadly, that fails too. Why? Because the pyside2uic.__init__ submodule fails to set a version – in flagrant violation of PEP 8 and all human decency:

      __version__ = ""
      

      So, that's two awful things that complicate instantiating the public pyside2uic.Compiler.compiler.UICompiler class in a backward-compatible manner. Just... ugh.

      It would have been preferable for backward API compatibility to have been preserved. Since we can't rewind time ala indy darling "Braid", would it be feasible for the next pyside2uic release to instead repair past transgressions by:

      • Making the all_pyside2_modules parameter optional?
      • Setting the pyside2uic.__version__ string to something sane?

      A little API sanity. It's all I ask.

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            leycec Cecil Curry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes