Skip to content

Support for PySide6's snake_case __feature__ #67

Open

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)

Activity

  1. hosaka commented on Nov 15, 2022

    @hosaka
    Collaborator

    Would be quite a change to add support for this, at least snake_case and true_property would have to be separate PRs. I am not able to even run a basic app:

    Traceback (most recent call last):
      File "E:\qasync\qasync\__init__.py", line 347, in __init__
        signaller.signal.connect(lambda callback, args: self.call_soon(callback, *args))
    AttributeError: 'Signaller' object has no attribute 'disconnectNotify'
    

    Is there anything special about installing pyside6 with snake_case enabled? If we could pick-up which features are enabled and use different variants based on that, instead of a bunch of try/excepts, I could look into it.

  2. HealsCodes commented on Nov 15, 2022

    @HealsCodes
    Author

    Is there anything special about installing pyside6 with snake_case enabled? If we could pick-up which features are enabled and use different variants based on that, instead of a bunch of try/excepts, I could look into it.

    Sadly, no.
    Both are features you can enable at runtime and part of the normal PySide6 as is available from PyPi.
    And sadly no way I know off to test in a module like qasync if the parent module has them enabled outside of inspecting a "known good" class like QObject.

    >>> import PySide6
    >>> from PySide6.QtCore import QObject
    
    >>> hasattr(QObject, 'objectName')
    True
    
    >>> hasattr(QObject, 'setObjectName')
    True
    
    >>> hasattr(QObject, 'object_name')
    False
    
    
    >>> from __feature__ import(snake_case, true_property)
    
    >>> hasattr(QObject, 'objectName')
    False
    
    >>> hasattr(QObject, 'setObjectName')
    False
    
    >>> hasattr(QObject, 'object_name')
    True

    Something like this would work to check the current state:

    from PySide6.QtCore import QObject
    
    def is_snake_case_enabled() -> bool:
        return hasattr(QObject, 'object_name')
    
    def is_true_property_enabled() -> bool:
        return hasattr(QObject, 'setObjectName') == False and hasattr(QObject, 'set_object_name') == False
  3. added
    enhancement
    on Nov 16, 2022
  4. changed the title [-]Nasty error loop if used together with PySide6's snake_case __feature__[/-] [+]Support for PySide6's snake_case __feature__[/+] on Oct 6, 2023
  5. added
    help wanted
    on Jul 24, 2025
  6. SoulMelody commented on Feb 6, 2026

    @SoulMelody

    This issue has been resolved since PySide6 version 6.10.2. You can now call qasync directly from a project that uses the snake_case feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions