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

Python: fix nice locations for import aliases #13941

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yoff
Copy link
Contributor

@yoff yoff commented Aug 10, 2023

The computation of nice location for import statements did not take aliases into account.
This has causes problems for some of our downstream CI.

See also https://github.com/github/codeql-team/issues/2260

there are errors both on lines 2 and 3 due to
locations being computed wrongly.
@yoff yoff requested a review from a team as a code owner August 10, 2023 12:22
These were computed wrongly before.
@yoff yoff changed the title Python: test nice locations Python: fix nice locations for import aliases Aug 10, 2023
@RasmusWL
Copy link
Member

I had to look up what NiceLocationExpr even was, since I had never heard about it before. It seems to only be used in our jump-to-definition queries... although the reason for needing these is a bit obscure to me, it seems to be to ensure spans for things we have definitions for are not overlapping 🤔

For reference, here is how it works for ImportMember:

Using Expr

image

ImportMember covers whole resource_provider as rp_obj

Using NiceLocaitonExpr

image

ImportMember only covers rp_obj

Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Minor suggestion for change note 😊

Did you test out jump-to-def locally before/after changes? (just curious, I think this change is fine to merge evne without doing this)

---
category: fix
---
* Fixed the computation of display locations for imports with aliases.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Fixed the computation of display locations for imports with aliases.
* Fixed the computation of locations for imports with aliases in jump-to-definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants