Skip to content

MNT: parent args passed into Qt provided class __init__ should be positional args not use keyword arguments #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nstelter-slac
Copy link
Collaborator

@nstelter-slac nstelter-slac commented Mar 15, 2025

This stops the following type of error on pyside6:

QtWidgets.QDateTimeEdit.__init__(self, parent=parent)
TypeError: PyDMWritableWidget.__init__() got an unexpected keyword argument 'parent'

For context:

  • Positional args: Func(1, 2)
  • Keyword args: Func(a=1, b=2)

pyqt5 works still if we use the keyword argument 'parent' for super calls to qt provided classes __init__ calls, but pyside6 throws an error (it generally seems a bit more strict about things).

You can inspect an __init__ call (ex: 'print(inspect.signature(QLabel.__init__))') to see if/what keyword arguments are accepted by it.

The __init__ calls changed in this patch don't accept a 'parent' keyword arg, just a positional arg for it.

Also use int casting to avoid type erros in datetime widget.

@nstelter-slac nstelter-slac added the pyside6 for adding pyside6 (qt6) support label Mar 15, 2025
positional args not use keyword arguments

For context:
- Positional args: Func(1, 2)
- Keyword args: Func(a=1, b=2)

pyqt5 works still if we use the keyword argument 'parent' for super
calls to qt class  __init__ calls, but pyside6 throws an error
(it generally seems a bit more strict about things).

You can inspect an __init__ call (ex: 'print(inspect.signature(QLabel.__init__))') to
see if/what keyword arguments are accepted by it.

The __init__ calls changed in this patch don't accept a 'parent' keyword arg,
just a positional arg for it.

Also use int casting to avoid type errros in datetime widget.
@nstelter-slac nstelter-slac force-pushed the fix_init_super_calls_pyside branch from 50b35b5 to 098b60a Compare March 15, 2025 06:38
@nstelter-slac nstelter-slac marked this pull request as draft March 27, 2025 23:13
@nstelter-slac
Copy link
Collaborator Author

realizing there more going on here than i originally thought, need to investigate a bit more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pyside6 for adding pyside6 (qt6) support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant