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

Fix some language server features not working in the console and in Jupyter notebooks e.g. hover and signature help #6140

Merged
merged 33 commits into from
Jan 31, 2025

Conversation

seeM
Copy link
Contributor

@seeM seeM commented Jan 28, 2025

The main goal of this PR is to address #5739. Along the way, I decided to refactor how we customize Jedi. I've moved away from subclassing to just patching things. Since Jedi wasn't really designed to be customized at this level, patching lets us copy/paste a lot less of their code, which I think is more robust moving forward, and it's more succinct. Since we're patching a vendored version of Jedi, we also don't run the risk of messing with a user's own independent usage of Jedi.

I also added a bunch of tests for different LSP features. I think it's worth having those since we might still want to run a variation of them even if we eventually move away from Jedi.

Release Notes

New Features

  • N/A

Bug Fixes

QA Notes

The linked issues have great repros. They should work in both notebooks and the console when you define an object in one execution, then trigger the LSP in another.

Copy link

github-actions bot commented Jan 28, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@seeM
Copy link
Contributor Author

seeM commented Jan 29, 2025

Will debug the Windows CI issue once I've updated my Windows setup, but this is otherwise ready for review.

isabelizimm
isabelizimm previously approved these changes Jan 30, 2025
Copy link
Contributor

@isabelizimm isabelizimm left a comment

Choose a reason for hiding this comment

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

Since Jedi wasn't really designed to be customized at this level, patching lets us copy/paste a lot less of their code, which I think is more robust moving forward, and it's more succinct. Since we're patching a vendored version of Jedi, we also don't run the risk of messing with a user's own independent usage of Jedi.

This does look a lot cleaner! Moves like this remind me how nice it is we went the vendoring route 🫶

A few questions, but I played around with it a bit and it seems to work as intended!


def _is_pandas_dataframe(value: Union[MixedObject, Value]) -> bool:
return (
value.get_root_context().py__name__() == "pandas.core.frame"
Copy link
Contributor

Choose a reason for hiding this comment

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

pandas dataframes have changed names a handful of times; will this take into account the different names?

"pandas.core.frame.DataFrame": "pandas.DataFrame",

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 can't seem to find the code where we handled other import paths, maybe it became unnecessary at some point?

The tests in this PR pass with our minimum supported pandas (1.5.3) so I assume it's good to go.

fname = oinspect.find_file(self._inspector.value)
if fname is not None:
# Normalize case for consistency in tests on Windows.
return Path(os.path.normcase(fname))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure when module_path is used, but will this not give the wrong value on windows?

Copy link
Contributor Author

@seeM seeM Jan 30, 2025

Choose a reason for hiding this comment

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

I don't think so. os.path.normcase should never "break" a path e.g. if the file system is case insensitive it shouldn't change the case. Jedi seems to normcase almost everywhere as well.

austin3dickey
austin3dickey previously approved these changes Jan 30, 2025
Copy link
Contributor

@austin3dickey austin3dickey left a comment

Choose a reason for hiding this comment

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

Works for me too! Thanks for the refactor; agreed it seems simpler. Thanks for all the tests too.

)


def apply_jedi_patches():
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to have this in its own function

@seeM seeM dismissed stale reviews from austin3dickey and isabelizimm via fa3f73f January 30, 2025 17:40
@seeM seeM merged commit 47d689f into main Jan 31, 2025
30 checks passed
@seeM seeM deleted the 5739-fix-lsp-methods-not-searching-user-namespace branch January 31, 2025 12:11
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants