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

Definitions just go until a certain point of the code #518

Closed
weberxw opened this issue Oct 24, 2020 · 10 comments
Closed

Definitions just go until a certain point of the code #518

weberxw opened this issue Oct 24, 2020 · 10 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@weberxw
Copy link

weberxw commented Oct 24, 2020

image
All this views are in the same file, imported through this at the top from base_production import views

As you can see my definitions stop in a certain point of the code, from Deliverable FileList down no definition is accessible.

Is there some limit based on file size or some configuration to fix this or is this a bug?

Thanks guys

@judej judej added the needs investigation Could be an issue - needs investigation label Oct 26, 2020
@github-actions github-actions bot removed the triage label Oct 26, 2020
@huguesv
Copy link
Contributor

huguesv commented Oct 26, 2020

Hi @weberxw

Thank you for the feedback. This does look like a bug.

The only limit that I can think of is a memory threshold during analysis where we sometimes throw away cache data to bring the memory usage back down.

Semantic colorization runs in the background with its own analysis cache, but the Go to Definition command runs in the foreground and does not share that same state.

While the screenshot clearly shows that semantic colorization stopped recognizing your view classes, can you confirm that Go to definition command is also broken for the ones that aren't colored?

Could you also please try to reorder your url calls and see how that changes the result? Like move all the Discipline url calls up above Project url calls. Mostly I'm trying to figure out if it's something in the beginning of the Discipline group that breaks things.

Another question, does it look like this when you first open the file, before you edit anything?

Finally, are there any errors that appear in the Output window, under Python Language Server?

thanks!

@huguesv huguesv added the waiting for user response Requires more information from user label Oct 26, 2020
@weberxw
Copy link
Author

weberxw commented Oct 27, 2020

Hi @huguesv , thank you for the answer.

I made some tests and here are the results..

  1. Its not just semantic colorization
    Captura de tela de 2020-10-27 09-51-57

  2. I changed the order and the result was the same, I was able to access the ones above the limit, no matter the class
    Captura de tela de 2020-10-27 09-54-06

  3. its not just when I open the file, I can change anything, edit, close, reopen, the definitions keep unaccessible from that point bellow

  4. Thats the output log
    Captura de tela de 2020-10-27 09-58-35

Hope this can help.
TY

@huguesv
Copy link
Contributor

huguesv commented Oct 27, 2020

@weberxw thank you

Can you please check the output for Python Language Server, you have to select it from the combo box on the right:
image

Is this an open source project by any chance?

@weberxw
Copy link
Author

weberxw commented Oct 27, 2020

image
Ops, forgot that

No, its a private project

@huguesv huguesv added bug Something isn't working and removed needs investigation Could be an issue - needs investigation waiting for user response Requires more information from user labels Oct 27, 2020
@huguesv
Copy link
Contributor

huguesv commented Oct 27, 2020

Thank you. I ended up reproducing it in a simple django project by copy/pasting several path/url calls.

@huguesv
Copy link
Contributor

huguesv commented Oct 28, 2020

Minimal repro:

mylib.py

class MyClass:
    pass

mytest.py

from . import mylib

data = [
    mylib.MyClass,
    mylib.MyClass,
    mylib.MyClass,
    mylib.MyClass,
    # copy/paste 70 or more of these...
]

After 64 entries, go to definition and semantic colorization on MyClass stops working.

It's the limit specified by maxEntriesToUseForInference
https://github.com/microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/typeEvaluator.ts#L607

@jakebailey
Copy link
Member

Curious; my reading of that limit is that it should only be preventing the creation of large list/dict/set types via literals, but I it's stopping any evaluation of the node. Perhaps if the limit only stopped the addition of the item to the container but still evaluated everything, it'd work due to the evaluation happening?

I'm wondering if this means you can make a large list, then do something invalid at the end and it type check even though it's wrong.

@jakebailey
Copy link
Member

jakebailey commented Oct 28, 2020

In context, this makes sense now; the screenshots in the original post hid the fact that these were appearing in a list literal.

@erictraut
Copy link
Contributor

@weberxw, thanks for the bug report.
@huguesv, thanks for the investigation and repro.

I found the root cause of this bug, and I've checked in a fix.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Oct 28, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.10.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020103-28-october-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

5 participants