Skip to content

PR: Add wrapers to fix argument name in QFileDialog get*methods#433

Merged
dalthviz merged 4 commits intospyder-ide:masterfrom
Czaki:dialog_compat
Jun 30, 2023
Merged

PR: Add wrapers to fix argument name in QFileDialog get*methods#433
dalthviz merged 4 commits intospyder-ide:masterfrom
Czaki:dialog_compat

Conversation

@Czaki
Copy link
Copy Markdown
Contributor

@Czaki Czaki commented May 24, 2023

closes #432

What did you think about this as idea?

@Czaki Czaki changed the title Add frapers to fix argument name in QFileDialog get*methods Add wrapers to fix argument name in QFileDialog get*methods May 24, 2023
@dalthviz dalthviz added this to the v2.4.0 milestone May 28, 2023
@dalthviz
Copy link
Copy Markdown
Member

Thanks @Czaki for your work here! Seems like we can go with this approach. Then the only missing thing here would be to try to add a test for this but other than that this LGTM 👍

@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented May 29, 2023

After last PySide6 problems I need find way to test it.

@Czaki Czaki marked this pull request as ready for review June 1, 2023 09:19
@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 1, 2023

How to deal with

UserWarning: Existing QApplication <PySide6.QtCore.QCoreApplication(0x55e7bf91d090) at 0x7f4563b26b70> is not an instance of qapp_cls: <class 'PySide6.QtWidgets.QApplication'>

@dalthviz
Copy link
Copy Markdown
Member

dalthviz commented Jun 2, 2023

UserWarning: Existing QApplication <PySide6.QtCore.QCoreApplication(0x55e7bf91d090) at 0x7f4563b26b70> is not an instance of qapp_cls: <class 'PySide6.QtWidgets.QApplication'>

My guess is that that could come from using the qapp fixture maybe? Or where are you seeing that warning?

Also, for the test, maybe using a QTimer singleshot instead of a QThread to handle the dialog could help? Or maybe the thread code should run inside a while True block which breaks when an instance of QFileDialog is found and closed?

@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 2, 2023

Also, for the test, maybe using a QTimer singleshot instead of a QThread

No. Timers are implemented in Qt as events put in the main queue event (for performance). Especially in documentation, there is:

On Windows, the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not nullptr then it will position the dialog just below the parent's title bar.

I have also observed problems with timers in such scenarios in the past. It happens that they are not triggered on CI when another event loop is started.

There is a check if the thread is closed before the end of the new test.

My guess is that that could come from using the qapp fixture maybe? Or where are you seeing that warning?

Yes but I do not know where it is created.

@dalthviz
Copy link
Copy Markdown
Member

dalthviz commented Jun 2, 2023

My guess is that that could come from using the qapp fixture maybe? Or where are you seeing that warning?

Yes but I do not know where it is created.

Seems like there is a fixture that is called qapp_cls. Maybe the warning is related with it? https://pytest-qt.readthedocs.io/en/latest/_modules/pytestqt/plugin.html#qapp_cls

@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 2, 2023

It looks like source of all problems was lack of some libraries in system. It looks like it is possible to unskip more tests.

Are you think it is worth?

@dalthviz
Copy link
Copy Markdown
Member

dalthviz commented Jun 3, 2023

It looks like source of all problems was lack of some libraries in system. It looks like it is possible to unskip more tests.

Are you think it is worth?

Oh that's good to know! I think it would be great if we can unskip tests!

@dalthviz dalthviz changed the title Add wrapers to fix argument name in QFileDialog get*methods PR: Add wrapers to fix argument name in QFileDialog get*methods and unskip some tests Jun 3, 2023
@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 3, 2023

Oh that's good to know! I think it would be great if we can unskip tests!

done in #434

@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 4, 2023

It is ready. I prefer to fix #434 first and then resolve conflicts.

@dalthviz dalthviz changed the title PR: Add wrapers to fix argument name in QFileDialog get*methods and unskip some tests PR: Add wrapers to fix argument name in QFileDialog get*methods Jun 5, 2023
@ccordoba12 ccordoba12 requested a review from dalthviz June 28, 2023 00:27
Copy link
Copy Markdown
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor stylistic suggestions for you @Czaki. I'll let @dalthviz review the code.

Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 28, 2023

Too many projects with black and ruff in pre-commit when there is no need to check formatting in base case as it will be auto fixed.

@ccordoba12
Copy link
Copy Markdown
Member

No worries. We're actually behind the times on that front but the thing is we have a lot of code to maintain and little time to do that sort of devops work.

Do you know some simple to set up GH actions to get started with Black and Ruff?

@Czaki
Copy link
Copy Markdown
Contributor Author

Czaki commented Jun 28, 2023

In napari, we activate pre-commit.ci tahat is free for OSS, automatically makes update commits and automatically create PR with the update of items in .pre-commit.yaml

Starting configuration could be two first entries from: https://github.com/napari/napari/blob/main/.pre-commit-config.yaml

Black configuration could be:

[tool.black]
target-version = ['py38', 'py39', 'py310']
line-length = 79
exclude = '''
(
  /(
      \.eggs
    | \.git
    | \.hg
    | \.mypy_cache
    | \.tox
    | \.venv
    | _build
    | buck-out
    | build
    | dist
    | examples
    | vendored
    | _vendor
  )/
  | napari/resources/qt.py
  | tools/minreq.py
)
'''

Our Ruff configuration is here:
https://github.com/napari/napari/blob/78b0f3f05a9eb7876f4875ddf01dbd03cfbe9f49/pyproject.toml#L56-L146

Another project that I maintain has this configuration:

https://github.com/4DNucleome/PartSeg/blob/aacc4284f73ee1b04e8aca6d86be0731fdac3a14/pyproject.toml#L34-L91

Both may be a good starting point requiring adjustment.

Copy link
Copy Markdown
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Czaki for all your work here! Left some questions in the workflow file regarding the new step since it seems like it duplicates partially a previous step. Also left a small suggestion for the test docstring. Other than that this LGTM 👍

On the other hand, regarding the autoformating/pre-commit/black/etc, that's something we need to do indeed! In fact, we have an issue tracking that: #345 Also, thanks for the suggestions! I will put a reference to your comment in the issue so we can check them in the future 👍

Co-authored-by: Daniel Althviz Moré <d.althviz10@uniandes.edu.co>
Copy link
Copy Markdown
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Czaki !

@dalthviz dalthviz merged commit 7b86b6c into spyder-ide:master Jun 30, 2023
@Czaki Czaki deleted the dialog_compat branch June 30, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compatibility layer for keywords arguments of QFileDialog get* class methods

3 participants