Skip to content
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

Handle no selectionmodel on clear selection #8200

Merged
merged 2 commits into from
May 20, 2024

Conversation

toofar
Copy link
Member

@toofar toofar commented May 19, 2024

  • Change on_clear_completion_selection() back to call the Qt getter instead of our one that does an assert not None check, it already handles None being returned fine
  • Add a half-hearted unit test (which was failing previously because of the assertion error)

I didn't put much effort into reproducing it beyond manually hammering the completion in a temp basedir (possibly if the completion was slower because of more items it would be easier to reproduce). That commit history was pretty clear, we've always handled this situation (whatever it is) until adapting to type hints recently.
An alternate implementation is adding an allow_none or similar kwarg to our getter.

Fixes: #7901

Change `CompletionView.on_clear_completion_selection()` to call the Qt
selection model getter, instead of our one. Since it can be called when the
selection model has already been cleared and our one asserts that there
is a selection model to return.

Back in the distant past there was a change to handle the completion widget's
selection model being None when the `on_clear_completion_selection()` slot was
called: 88b522fa167e2f97b

More recently a common getter for the selection model was added so we could
have a single place to apply type narrowing to the returned object from the Qt
getter (the type hints had been updated to be wrapped in `Optional`): 92dea988c01e745#diff-1559d42e246323bea35fa064d54d48c990999aaf4c732b09ccd448f994da74cf

It seems this is one place where it does, and already did, handle that
optional. So it didn't need to change to use the new getter. This is called
from the `Command.on_mode_left` signal, not sure why the selection model is
None here. Perhaps it already gets cleared by the effects of the `hide_cmd`
signal that gets fired earlier, or perhaps even from the `self.hide()` on the
line before. Anyway, this was working for several years and seems harmless
enough.
@toofar toofar requested a review from rcorre as a code owner May 19, 2024 02:41
@toofar toofar merged commit c0d8838 into main May 20, 2024
63 of 65 checks passed
@toofar toofar deleted the feat/7901_handle_no_selectionmodel_on_clear_selection branch May 20, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AssertionError for assert model is not None in completionwidget.py
2 participants