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

pyside6-metaobjectdump fails on metaclass

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.5.0, 6.4.3
    • 6.4.2
    • PySide, Tooling
    • None
    • Linux/Wayland
    • dd79ee6d2 (dev), 0809bf631 (6.4)

    Description

      Using `pyside6-metaobjectdump` on this MWE will fail

      AttributeError: 'Call' object has no attribute 'id'
      
      from abc import ABC, abstractmethod
      from PySide6.QtCore import QObject
      
      class Dialog(ABC):
      
          @abstractmethod
          def execute(self) -> bool:
              raise NotImplementedError("User must define 'execute' to use this interface")
      
      class MyMetaQMLClass(type(QObject), type(Dialog)):
          pass
      
      class MyQMLObject(Dialog, QObject, metaclass=MyMetaQMLClass):
          pass
      

      Looking at the source in metaobjectdump,

      def _name(node: Union[ast.Name, ast.Attribute]) -> str:
          """Return the name of something that is either an attribute or a name,
             such as base classes or call.func"""
          if isinstance(node, ast.Attribute):
              qualifier, name = _attribute(node)
              return f"{qualifier}.{node.attr}"
          return node.id
      

      I don't know why the node doesn't have an id, but maybe the way we create our metaclass is wrong? It fails on the `(` in class MyMetaQMLClass*(*

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              roussinm Maxime Roussin-BĂ©langer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes