python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

Analysis starts passively and fails with attribute in f-string or with type hint.

Open mozkileo opened this issue 5 years ago • 0 comments

Environment data

  • Version Info

    • MS Language Server: 0.5.45
    • OS: Windows10 19041 x64
    • Python: Python 3.8.3 64-bit
    • VS Code: 1.45.1
    • Python Extension:2020.5.80290
  • Settings

    {
        "python.jediEnabled": false,
        "python.analysis.memory.keepLibraryAst": true,
        "python.analysis.memory.keepLibraryLocalVariables": true,
        "python.linting.mypyEnabled": true
    }
    

Steps to reproduce

I made some tests and found 3 similar issues:

  1. Analysis starts passively and I have to find refs one by one.
  2. Can't find refs of attribute named with double underlines in f-string.
  3. Can't find any ref of attributes with type hint.

Details are as follows.

1. Analysis starts passively

Recording

1

Code Snippet

class A():
    def __init__(self):
        self.data = {
            '1': 1,
            '2': 2
        }

    def f1(self):
        return f"{self.data}"

    def f2(self):
        if self.data:
            ...

Logs

[Info  - 12:20:53 p.m.] Analysis cache path: C:\Users\MozkiLeo\AppData\Local\Microsoft\Python Language Server
[Info  - 12:20:53 p.m.] Microsoft Python Language Server version 0.5.45.0
[Info  - 12:20:53 p.m.] Workspace root:
[Info  - 12:20:53 p.m.] GetCurrentSearchPaths C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:20:53 p.m.] Interpreter search paths:
[Info  - 12:20:53 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\dlls
[Info  - 12:20:53 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib
[Info  - 12:20:53 p.m.]     c:\users\mozkileo\appdata\local\microsoft\windowsapps\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0
[Info  - 12:20:53 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0
[Info  - 12:20:53 p.m.]     c:\users\mozkileo\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
[Info  - 12:20:53 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\site-packages
[Info  - 12:20:53 p.m.] User search paths:
[Info  - 12:20:53 p.m.] Initializing for C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:20:53 p.m.] Analysis caching mode: None.
Opening document file:///e:/Programming/Python/py-final-work/test.py
Analysis of test (User) queued. Dependencies:
Analysis version 1 of 1 entries has started.
Analysis of test (User) on depth 0 completed in 3.99 ms.
Indexing libraries.
Analysis complete: 1 modules in 28.64 ms.
Analysis version 1 of 1 entries has been completed in 8.29 ms.

Hover in file:///e:/Programming/Python/py-final-work/test.py at (1, 16)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (2, 15)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (2, 15)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (2, 15) - (2, 15)
References in file:///e:/Programming/Python/py-final-work/test.py at (2, 15)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (8, 24)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (8, 24) - (8, 24)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (8, 25)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (8, 25) - (8, 25)
References in file:///e:/Programming/Python/py-final-work/test.py at (8, 25)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (11, 19)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 19) - (11, 19)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 18) - (11, 18)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)

2. Can't find refs of attribute named with double underlines in f-string.

Recording

2

Code Snippet

class A():
    def __init__(self):
        self.__data = {
            '1': 1,
            '2': 2
        }

    def f1(self):
        return f"{self.__data}"

    def f2(self):
        if self.__data:
            ...

Logs

[Info  - 12:22:02 p.m.] Analysis cache path: C:\Users\MozkiLeo\AppData\Local\Microsoft\Python Language Server
[Info  - 12:22:02 p.m.] Microsoft Python Language Server version 0.5.45.0
[Info  - 12:22:02 p.m.] Workspace root:
[Info  - 12:22:02 p.m.] GetCurrentSearchPaths C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:22:02 p.m.] Interpreter search paths:
[Info  - 12:22:02 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\dlls
[Info  - 12:22:02 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib
[Info  - 12:22:02 p.m.]     c:\users\mozkileo\appdata\local\microsoft\windowsapps\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0
[Info  - 12:22:02 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0
[Info  - 12:22:02 p.m.]     c:\users\mozkileo\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
[Info  - 12:22:02 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\site-packages
[Info  - 12:22:02 p.m.] User search paths:
[Info  - 12:22:03 p.m.] Initializing for C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:22:03 p.m.] Analysis caching mode: None.
Opening document file:///e:/Programming/Python/py-final-work/test.py
Analysis of test (User) queued. Dependencies:
Analysis version 1 of 1 entries has started.
Analysis of test (User) on depth 0 completed in 3.1 ms.
Indexing libraries.
Analysis complete: 1 modules in 26.75 ms.
Analysis version 1 of 1 entries has been completed in 6.24 ms.

Hover in file:///e:/Programming/Python/py-final-work/test.py at (1, 13)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (3, 16)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (2, 16)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (2, 16)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (2, 16) - (2, 16)
References in file:///e:/Programming/Python/py-final-work/test.py at (2, 16)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (8, 26)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (8, 26) - (8, 26)
References in file:///e:/Programming/Python/py-final-work/test.py at (8, 26)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (11, 19)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 19) - (11, 19)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 19)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 18) - (11, 18)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (8, 26)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (8, 26) - (8, 26)
References in file:///e:/Programming/Python/py-final-work/test.py at (8, 26)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (11, 19)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 19) - (11, 19)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 19)

3. Can't find any ref of attributes with type hint.

Recording

3

Code Snippet

class A():
    def __init__(self):
        self.data: dict = {
            '1': 1,
            '2': 2
        }

    def f1(self):
        return f"{self.data}"

    def f2(self):
        if self.data:
            ...

Logs

[Info  - 12:59:10 p.m.] Analysis cache path: C:\Users\MozkiLeo\AppData\Local\Microsoft\Python Language Server
[Info  - 12:59:10 p.m.] Microsoft Python Language Server version 0.5.45.0
[Info  - 12:59:10 p.m.] Workspace root:
[Info  - 12:59:10 p.m.] GetCurrentSearchPaths C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:59:10 p.m.] Interpreter search paths:
[Info  - 12:59:10 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\dlls
[Info  - 12:59:10 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib
[Info  - 12:59:10 p.m.]     c:\users\mozkileo\appdata\local\microsoft\windowsapps\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0
[Info  - 12:59:10 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0
[Info  - 12:59:10 p.m.]     c:\users\mozkileo\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
[Info  - 12:59:10 p.m.]     c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\site-packages
[Info  - 12:59:10 p.m.] User search paths:
[Info  - 12:59:11 p.m.] Initializing for C:\Users\MozkiLeo\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
[Info  - 12:59:11 p.m.] Analysis caching mode: None.
Opening document file:///e:/Programming/Python/py-final-work/test.py
Analysis of test (User) queued. Dependencies:
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (2, 27) - (2, 27)
Analysis version 1 of 1 entries has started.
Analysis of test (User) on depth 0 completed in 2.87 ms.
Indexing libraries.
Analysis complete: 1 modules in 26.47 ms.
Analysis version 1 of 1 entries has been completed in 6.72 ms.

Hover in file:///e:/Programming/Python/py-final-work/test.py at (2, 17)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (2, 18)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (2, 15)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (2, 15) - (2, 15)
References in file:///e:/Programming/Python/py-final-work/test.py at (2, 15)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (8, 27)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (8, 24)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (8, 24) - (8, 24)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (8, 24)
References in file:///e:/Programming/Python/py-final-work/test.py at (8, 24)
Hover in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Document highlight in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 18) - (11, 18)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 18)
Code Action in file:///e:/Programming/Python/py-final-work/test.py at (11, 17) - (11, 17)
References in file:///e:/Programming/Python/py-final-work/test.py at (11, 17)

Additional lnformation

The issues above didn't turn up with Jedi enabled.

By the way, sometime I must try at least twice to find refs of one stuff, either in this test or normal codes this happens frequently.

mozkileo avatar Jun 06 '20 06:06 mozkileo