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

PR: Fix completions bug in Kite introduced by PR 10605 #10630

Merged
merged 5 commits into from
Nov 7, 2019

Conversation

metalogical
Copy link
Contributor

Description of Changes

Fixes exception raised due to #10605 (described here)

How can we make sure we don't regress again? Maybe we need fixturized test cases with sample completions dicts that we return to the completions logic and ensure it works properly with textEdits. Thoughts?

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: @metalogical

@metalogical
Copy link
Contributor Author

I'm currently trying to add a test that mocks the completions response in various ways.

@ccordoba12 ccordoba12 changed the title PR: fix completions bug introduced by #10605 PR: Fix completions bug introduced by #10605 Nov 6, 2019
@ccordoba12 ccordoba12 added this to the v4.0.0 milestone Nov 6, 2019
@ccordoba12
Copy link
Member

I'm currently trying to add a test that mocks the completions response in various ways.

That sounds very nice, thanks! However, we'd prefer integration tests, so if you could add tests that call Kite directly, that would be much better.

@pep8speaks
Copy link

pep8speaks commented Nov 7, 2019

Hello @metalogical! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-11-07 17:58:33 UTC

@metalogical
Copy link
Contributor Author

@ccordoba12 I added a unit test (and fixtures) that allow mocking the completions responses, and verify that a simple dict key completion example with textEdit works correctly.

I agree that integration tests would be nice, but I'm not sure what the best approach to get that working is. We have a kited_test binary that we use in CI for other editor plugins, which disables some excess logic (such as authentication, etc), and also exposes some additional endpoints useful for testing.

However, we'd need to set up a way to retrieve the this binary from the web or somewhere else. I think it's worth investing in (and we'd be willing to spend resources here whenever we have them), but would prefer to tackle this as a separate issue.

spyder/plugins/editor/widgets/tests/conftest.py Outdated Show resolved Hide resolved
spyder/plugins/editor/widgets/tests/test_introspection.py Outdated Show resolved Hide resolved
spyder/plugins/editor/widgets/tests/test_introspection.py Outdated Show resolved Hide resolved
# Set cursor to start
code_editor.go_to_line(1)

qtbot.keyClicks(code_editor, 'my_dict.')
Copy link
Member

Choose a reason for hiding this comment

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

Why the . at end of my_dict is necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I use this test case is because this is a type of completion that Kite returns (it allows users to quickly access dict keys with a .), and it's a case where the completion ["dict-key"] replacing the . can't be represented with just insertText.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I didn't know that and it's pretty cool!

spyder/plugins/editor/widgets/tests/conftest.py Outdated Show resolved Hide resolved
spyder/plugins/editor/widgets/tests/conftest.py Outdated Show resolved Hide resolved
@metalogical
Copy link
Contributor Author

Thanks for the look-over @ccordoba12

I addressed your comments.

@andfoy
Copy link
Member

andfoy commented Nov 7, 2019

Just for the record, a contributor is migrating pyls completions to use textEdit: palantir/python-language-server#690

@metalogical
Copy link
Contributor Author

metalogical commented Nov 7, 2019

@andfoy interesting

Note that currently Spyder's support for textEdit completions is very limited: if the user keeps typing, it filters out all such completions, due to the fact that the replacement range may be out-of-date. I didn't want to add a lot of complexity, so Spyder just depends on completions being re-requested in these cases.

If pyls starts returning those, it may be wise to invest further in expanding support for those completions. Especially since re-requesting completions with pyls may be slow.

EDIT: on further investigation, that PR doesn't remove insertText, so Spyder would just default to that I think.

Copy link
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.

Looks good to me now. Thanks @metalogical!

@ccordoba12 ccordoba12 changed the title PR: Fix completions bug introduced by #10605 PR: Fix completions bug in Kite introduced by PR 10605 Nov 7, 2019
@ccordoba12 ccordoba12 merged commit 147ca12 into spyder-ide:master Nov 7, 2019
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.

None yet

4 participants