-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Fix QIntValidator to handle '+' sign #20070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maurerle for checking into this! However, testing locally the changes here I think more changes are needed to prevent errors with the go to line dialog. Putting +
still makes the Ok
button enabled and clicking it causes another error:
Traceback (most recent call last):
File "e:\acer\documentos\spyder\spyder otros\maurerle\spyder\spyder\plugins\editor\widgets\editor.py", line 862, in go_to_line
self.get_current_editor().exec_gotolinedialog()
File "e:\acer\documentos\spyder\spyder otros\maurerle\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 3097, in exec_gotolinedialog
self.go_to_line(dlg.get_line_number())
File "e:\acer\documentos\spyder\spyder otros\maurerle\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 3089, in go_to_line
self.text_helper.goto_line(line, column=start_column,
File "e:\acer\documentos\spyder\spyder otros\maurerle\spyder\spyder\plugins\editor\utils\editor.py", line 209, in goto_line
line = min(line, self.line_count())
TypeError: '<' not supported between instances of 'int' and 'NoneType'
I think that case is already covered on the implementation done at #13333
Taking that into account, maybe you could undo the changes done for the go to line functionality here and we could see if we can move #13333 to use 5.x as base and then merge the changes to fix the error on the importwizard dialog you did here?
What do you think?
a4e283d
to
5b4b2f3
Compare
I fixed this by checking in the enabled field - which is only two small changes. But I am also quite emotionless on removing the gotoline part and merging the other PR. So it is up to you - if you merge the other branch, I will adjust my PR to it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking the error here @maurerle ! Since you already implemented the handling lets mark this as superseding #13333
I just left a suggestion to clear the line edit too if the input is not valid (the +
sign). And a couple of comments to add comments to link the fix with this PR and the issue.
Also, maybe it could be worthy to add a test for this fix to prevent regressions on the validation?
Other than that this LGTM 👍
5b4b2f3
to
c95c9fe
Compare
Found another bug in the import dialog |
Can you maybe give me a hint on how to add a test for this? |
c95c9fe
to
859421f
Compare
Regarding the test maybe a look to the |
- interprete no comments if comments empty - better error message in import dialog assertion
Hi @dalthviz, I hope it is okay to have that second commit in the same PR as it was found while testing, but I can also open another PR for it. |
@maurerle I think is okay here since it is related with the skip rows value which is something being changed here for the importwizard dialog 👍 |
Thanks. Can you give me a hint how I can create the I currently have: def test_gotolinedialog_has_cancel_button(codeeditor, qtbot, tmpdir):
"""
Test that GoToLineDialog has a Cancel button.
Test that a GoToLineDialog has a button in a dialog button box and that
this button cancels the dialog window.
"""
editor = codeeditor
dialog = GoToLineDialog(editor)
button = dialog.findChild(QDialogButtonBox).findChild(QPushButton)
with qtbot.waitSignal(dialog.rejected):
button.click() which produces a timeout |
Maybe something like: def test_gotolinedialog_has_cancel_button(codeeditor, qtbot, tmpdir):
"""
Test that GoToLineDialog has a Cancel button.
Test that a GoToLineDialog has a button in a dialog button box and that
this button cancels the dialog window.
"""
editor = codeeditor
dialog = GoToLineDialog(editor)
cancel_button = dialog.findChild(QDialogButtonBox).button(QDialogButtonBox.Cancel)
# Check cancel button is enabled
assert cancel_button.isEnabled()
with qtbot.waitSignal(dialog.rejected):
cancel_button.click() You could also test more things like the ones related to the changes here with another function like: def test_gotolinedialog_input(codeeditor, qtbot):
"""
Regression test for spyder-ide/spyder#12693
"""
editor = codeeditor
dialog = GoToLineDialog(editor)
lineedit = dialog.lineedit
ok_button = dialog.findChild(QDialogButtonBox).button(QDialogButtonBox.Ok)
# Check ok button is disabled
assert not ok_button.isEnabled()
# Check + sign being cleared and ok button still is disabled
lineedit.setText("+")
assert lineedit.text() == None
assert not ok_button.isEnabled()
# Check valid text and ok button enabled
lineedit.setText("1")
assert lineedit.text() == "1"
assert ok_button.isEnabled()
with qtbot.waitSignal(dialog.accepted):
ok_button.click() |
Thank you! I hope it looks good now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maurerle for all the work here! Left some suggestions for comments and code formatting but other than that this should be ready for a merge 👍
Co-authored-by: Daniel Althviz Moré <d.althviz10@uniandes.edu.co>
9f851dc
to
29d676c
Compare
Great, thank you! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maurerle !
Description of Changes
Somehow Qt QIntValidator allows to enter only a plus sign: '+'
While searching for QIntValidator, I found another occurance in the import dialog of the variable explorer.
Issue(s) Resolved
Supersedes #13333
Fixes #12693
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: Florian Maurer