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 async do_complete in the debugger #520

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Nov 13, 2024

A number of methods of ipykernel can optinally return awaitable[T] instead of just T, this is the case for do_complete.

I think it's a mistake ; see ipython/ipykernel#1295 ; in particular because it's easy to forget / hard to properly type-check, and I'd like to make it mandatory in the long term to have await.

Spyder seem to not handle the case where do_completer return an awaitable (or more partiularly is do_complete is a coroutine function.

This tries to handle it – and as of course do_completer can be async, all caller must be async. So I try to do all the required updates.

Note: I also add explict imports in some test, to get better error message in case those deps are not installed.

@Carreau
Copy link
Contributor Author

Carreau commented Nov 13, 2024

This is more to start a discussion than a "this must be merged". It's mostly to start some discussion also with upstream as we sort of disagree that having def f(...): -> T | Awaitable[T] is a good thing.

A number of methods of ipykernel can optinally return `awaitable[T]`
instead of just `T`, this is the case for `do_complete`.

I think it's a mistake ; see ipython/ipykernel#1295 ; in particular
because it's easy to forget / hard to properly type-check, and I'd like
to make it mandatory in the long term to have await.

Spyder seem to not handle the case where do_completer return an
awaitable (or more partiularly is `do_complete` is a coroutine function.

This tries to handle it – and as of course `do_completer` _can_ be
async, all caller _must_ be async. So I try to do all the required
updates.

Note: I also add explict imports in some test, to get better error
message in case those deps are not installed.
@Carreau
Copy link
Contributor Author

Carreau commented Feb 24, 2025

Rebased. I think we agree upstream that things should mostly be async when possible. so +1 to merge this once tests are passing, and you agree.,

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.

Thanks @Carreau! A couple of small questions, the rest looks good to me.

@@ -1435,6 +1439,7 @@ def test_django_settings(kernel):

This is a regression test for issue spyder-ide/spyder#19516
"""
import django
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary now? It wasn't before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not remember.

I would say better error messages in pytest short summary:

- FAILED spyder_kernels/...::test_save_load_hdf5_files - assert '(None, "No m...ed \'h5py\'")' == "({'a': array...(4.5)}, None)"
+ FAILED spyder_kernels/...::test_save_load_hdf5_files - ModuleNotFoundError: No module named 'h5py'

and

- FAILED spyder_kernels/...::test_django_settings - assert "'settings':" in '{}'
+ FAILED spyder_kernels/...::test_django_settings - ModuleNotFoundError: No module named 'django'

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks for the clarification. Merging then.

@ccordoba12 ccordoba12 added this to the v3.1.0 milestone Mar 5, 2025
@ccordoba12 ccordoba12 added the type:Enhancement New feature or request label Mar 5, 2025
@ccordoba12 ccordoba12 changed the title Handle async do_complete. Handle async do_complete in the debugger Mar 5, 2025
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.

Thanks @Carreau!

@ccordoba12 ccordoba12 merged commit 9c0f9f2 into spyder-ide:master Mar 5, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants