Skip to content

Support for PySide6's snake_case __feature__ #67

Open
@HealsCodes

Description

@HealsCodes

When using qasync together with the snake_case feature of PySide6 the following messages will be printed every few milliseconds:

Traceback (most recent call last):
File "REDACTED/.venv/lib/python3.10/site-packages/qasync/init.py", line 287, in timerEvent
self.killTimer(timerid)
Traceback (most recent call last):
File "REDACTED/.venv/lib/python3.10/site-packages/qasync/init.py", line 285, in timerEvent
del self.__callbacks[timerid]
KeyError: 1

The base issue is that snake_case causes PySide to export all methods in snake_case instead of camelCase.
A fix would be for qasync to check for the existence of the expected method and otherwise assume snake_case:

class _SimpleTimer(QtCore.QObject):
    def __killTimer(self, timerId):
        try:
          self.killTimer(timerId)
        except AttributeError:
          self.kill_timer(timerId)

snake_case is one of the new features added in PySide6 which cane be user enabled but affect the whole runtime.
true_property would be another which replaces the .getXY() and .xy pairs with real assignable object properties.

Both of them can be enabled like this:

import PySide6
from __feature__ import (snake_case, true_property)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions