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

Unable to show docstrings and source using aliased import and stub file #6627

Open
Delgan opened this issue Nov 3, 2024 · 0 comments
Open
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@Delgan
Copy link

Delgan commented Nov 3, 2024

Summary

Environment data

  • Pylance version: 2024.10.1
  • OS and version: Linux 6.11.6-arch1-1
  • Python version: 3.12.7

Code Snippet

# app.py

from mylib import foo

foo.func()  # Missing docstrings on hover here.
# mylib/__init__.py

from ._private import Foo as _Foo

foo = _Foo()
# mylib/_private.py

class Foo:
    """Some class documentation."""

    def func(self) -> int:
        """Some function documentation."""
        return 1
# mylib/__init__.pyi

class Foo:
    def func(self) -> int: ...

foo: Foo

Repro Steps

  1. Create the above files as follow:
.
├── app.py
└── mylib
    ├── __init__.py
    ├── __init__.pyi
    └── _private.py
  1. Open a.py, put mouse hover func() and wait for the tooltip to appear

Expected behavior

The docstrings of the func() function should appear.

Image

Actual behavior

No docstrings.

Image

Additional information

Same problem with "Go to Definition" (F12) which redirects to the stub file instead of the actual sources.

Note that a possible workaround is to rename Foo to _Foo in the stub file, and to define a type alias Foo = _Foo.

Logs

2024-11-03 16:01:51.214 [info] [Info  - 4:01:51 PM] (73622) Server root directory: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-11-03 16:01:51.502 [info] [Info  - 4:01:51 PM] (73622) Pylance language server 2024.10.1 (pyright version 1.1.382, commit e46efc6b) starting
2024-11-03 16:01:51.528 [info] (Client) Pylance async client (2024.10.1) started with python extension (2024.18.0)
2024-11-03 16:01:51.589 [info] [Info  - 4:01:51 PM] (73622) Starting service instance "test"
2024-11-03 16:01:53.418 [info] (73622) No configuration file found.
2024-11-03 16:01:53.422 [info] (73622) No pyproject.toml file found.
2024-11-03 16:01:53.453 [info] [Info  - 4:01:53 PM] (73622) Setting environmentName for service "test": "3.12.7 (global)"
2024-11-03 16:01:53.456 [info] [Info  - 4:01:53 PM] (73622) Setting pythonPath for service "test": "/bin/python"
2024-11-03 16:01:53.457 [info] [Info  - 4:01:53 PM] (73622) No include entries specified; assuming /home/delgan/Code/test
2024-11-03 16:01:53.457 [info] [Info  - 4:01:53 PM] (73622) Auto-excluding **/node_modules
2024-11-03 16:01:53.457 [info] [Info  - 4:01:53 PM] (73622) Auto-excluding **/__pycache__
2024-11-03 16:01:53.458 [info] [Info  - 4:01:53 PM] (73622) Auto-excluding **/.*
2024-11-03 16:01:53.458 [info] [Info  - 4:01:53 PM] (73622) Assuming Python version 3.12.7.final.0
2024-11-03 16:01:53.458 [info] (73622) Assuming Python platform Linux
2024-11-03 16:01:53.458 [info] [Info  - 4:01:53 PM] (73622) Execution environment: 3.12.7 (global)
2024-11-03 16:01:53.458 [info] [Info  - 4:01:53 PM] (73622)   Extra paths:
2024-11-03 16:01:53.459 [info] [Info  - 4:01:53 PM] (73622)     (none)
2024-11-03 16:01:53.459 [info] [Info  - 4:01:53 PM] (73622)   Python version: 3.12.7.final.0
2024-11-03 16:01:53.459 [info] [Info  - 4:01:53 PM] (73622)   Python platform: Linux
2024-11-03 16:01:53.459 [info] [Info  - 4:01:53 PM] (73622)   Search paths:
2024-11-03 16:01:53.460 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib
2024-11-03 16:01:53.460 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/Code/test
2024-11-03 16:01:53.460 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/Code/test/typings
2024-11-03 16:01:53.460 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stubs/...
2024-11-03 16:01:53.460 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/bundled/stubs
2024-11-03 16:01:53.461 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12
2024-11-03 16:01:53.461 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12/lib-dynload
2024-11-03 16:01:53.462 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12/site-packages
2024-11-03 16:01:53.463 [info] [Info  - 4:01:53 PM] (73622) Execution environment: 3.12.7 (global)
2024-11-03 16:01:53.464 [info] [Info  - 4:01:53 PM] (73622)   Extra paths:
2024-11-03 16:01:53.464 [info] [Info  - 4:01:53 PM] (73622)     (none)
2024-11-03 16:01:53.464 [info] [Info  - 4:01:53 PM] (73622)   Python version: 3.12.7.final.0
2024-11-03 16:01:53.464 [info] [Info  - 4:01:53 PM] (73622)   Python platform: Linux
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)   Search paths:
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/Code/test
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/Code/test/typings
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stubs/...
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/bundled/stubs
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12/lib-dynload
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622)     /usr/lib/python3.12/site-packages
2024-11-03 16:01:53.465 [info] [Info  - 4:01:53 PM] (73622) Adding fs watcher for library directories:
 file:///usr/lib/python3.12
2024-11-03 16:01:53.466 [info] [Info  - 4:01:53 PM] (73622) Adding fs watcher for directories:
 file:///home/delgan/Code/test
2024-11-03 16:01:53.466 [info] (73622) Searching for source files
2024-11-03 16:01:53.466 [info] [Info  - 4:01:53 PM] (73622) Found 4 source files
2024-11-03 16:01:53.469 [info] (73622) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-11-03 16:01:53.470 [info] (73622) Attempting to resolve using local imports: __builtins__
2024-11-03 16:01:53.470 [info] (73622) [FG] parsing: file:///home/delgan/Code/test/app.py (52ms)
2024-11-03 16:01:53.470 [info] (73622) [FG] parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 3ms] (91ms)
2024-11-03 16:01:53.470 [info] (73622) [FG] binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/builtins.pyi (49ms)
2024-11-03 16:01:53.470 [info] (73622) [FG] binding: file:///home/delgan/Code/test/app.py (1ms)
2024-11-03 16:01:53.473 [info] (73622) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-11-03 16:01:53.473 [info] [Info  - 4:01:53 PM] (73622) Background analysis(1) root directory: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-11-03 16:01:53.473 [info] [Info  - 4:01:53 PM] (73622) Background analysis(1) started
2024-11-03 16:01:53.473 [info] (73622) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-11-03 16:01:53.473 [info] [Info  - 4:01:53 PM] (73622) Indexer background runner(2) root directory: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist (index)
2024-11-03 16:01:53.473 [info] [Info  - 4:01:53 PM] (73622) Indexing(2) started
2024-11-03 16:01:53.473 [info] (73622) Attempting to resolve using local imports: __builtins__
2024-11-03 16:01:53.474 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/app.py ...
2024-11-03 16:01:53.474 [info] (73622) [BG(1)]   parsing: file:///home/delgan/Code/test/app.py (56ms)
2024-11-03 16:01:53.474 [info] (73622) [IDX(2)] scan packages file:///home/delgan/Code/test ...
2024-11-03 16:01:53.474 [info] (73622) [IDX(2)]   read stdlib indices (26ms)
2024-11-03 16:01:53.474 [info] (73622) [BG(1)]   parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (84ms)
2024-11-03 16:01:53.474 [info] (73622) [BG(1)]   binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/builtins.pyi (41ms)
2024-11-03 16:01:53.474 [info] (73622) [BG(1)]   binding: file:///home/delgan/Code/test/app.py (1ms)
2024-11-03 16:01:53.475 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/app.py [found 0] (187ms)
2024-11-03 16:01:53.475 [info] (73622) Workspace indexing done: file:///home/delgan/Code/test/app.py
2024-11-03 16:01:53.475 [info] (73622) Attempting to resolve using local imports: __builtins__
2024-11-03 16:01:53.475 [info] (73622) Attempting to resolve using root path 'file:///home/delgan/Code/test/mylib'
2024-11-03 16:01:53.475 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/__init__.py ...
2024-11-03 16:01:53.475 [info] (73622) [BG(1)]   parsing: file:///home/delgan/Code/test/mylib/__init__.py [fs read 0ms] (1ms)
2024-11-03 16:01:53.475 [info] (73622) [BG(1)]   binding: file:///home/delgan/Code/test/mylib/__init__.py (1ms)
2024-11-03 16:01:53.476 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/__init__.py [found 1] (3ms)
2024-11-03 16:01:53.476 [info] (73622) Workspace indexing done: file:///home/delgan/Code/test/mylib/__init__.py
2024-11-03 16:01:53.476 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/__init__.pyi ...
2024-11-03 16:01:53.476 [info] (73622) [BG(1)]   parsing: file:///home/delgan/Code/test/mylib/__init__.pyi [fs read 0ms] (0ms)
2024-11-03 16:01:53.476 [info] (73622) [BG(1)]   binding: file:///home/delgan/Code/test/mylib/__init__.pyi (0ms)
2024-11-03 16:01:53.476 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/__init__.pyi [found 2] (1ms)
2024-11-03 16:01:53.476 [info] (73622) Workspace indexing done: file:///home/delgan/Code/test/mylib/__init__.pyi
2024-11-03 16:01:53.477 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/_private.py ...
2024-11-03 16:01:53.477 [info] (73622) [BG(1)]   parsing: file:///home/delgan/Code/test/mylib/_private.py [fs read 0ms] (0ms)
2024-11-03 16:01:53.490 [info] (73622) [BG(1)]   binding: file:///home/delgan/Code/test/mylib/_private.py (0ms)
2024-11-03 16:01:53.491 [info] (73622) [BG(1)] indexing: file:///home/delgan/Code/test/mylib/_private.py [found 1] (2ms)
2024-11-03 16:01:53.493 [info] (73622) Workspace indexing done: file:///home/delgan/Code/test/mylib/_private.py
2024-11-03 16:01:53.495 [info] (73622) [BG(1)] analyzing: file:///home/delgan/Code/test/app.py ...
2024-11-03 16:01:53.495 [info] (73622) [BG(1)]   parsing: file:///home/delgan/Code/test/app.py (1ms)
2024-11-03 16:01:53.497 [info] (73622) [BG(1)]   binding: file:///home/delgan/Code/test/app.py (0ms)
2024-11-03 16:01:53.497 [info] (73622) [BG(1)]   checking: file:///home/delgan/Code/test/app.py ...
2024-11-03 16:01:53.497 [info] (73622) [BG(1)]     parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/typing.pyi [fs read 1ms] (33ms)
2024-11-03 16:01:53.497 [info] (73622) [BG(1)]     binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/typing.pyi (14ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (11ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/types.pyi (5ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 1ms] (5ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (3ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (2ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/abc.pyi (2ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     parsing: file:///home/delgan/Code/test/mylib/__init__.pyi [fs read 0ms] (0ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]     binding: file:///home/delgan/Code/test/mylib/__init__.pyi (0ms)
2024-11-03 16:01:53.498 [info] (73622) [BG(1)]   checking: file:///home/delgan/Code/test/app.py (140ms)
2024-11-03 16:01:53.499 [info] (73622) [BG(1)] analyzing: file:///home/delgan/Code/test/app.py (142ms)
2024-11-03 16:01:53.502 [info] (73622) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-11-03 16:01:53.502 [info] (73622) [IDX(2)] scan packages file:///home/delgan/Code/test (305ms)
2024-11-03 16:01:53.503 [info] [Info  - 4:01:53 PM] (73622) scanned(2) 15 files over 1 exec env
2024-11-03 16:01:53.503 [info] (73622) [IDX(2)] index packages file:///home/delgan/Code/test ...
2024-11-03 16:01:53.503 [info] (73622) [IDX(2)]   index execution environment file:///home/delgan/Code/test [found 730 in 15 files] (5ms)
2024-11-03 16:01:53.503 [info] (73622) [IDX(2)] index packages file:///home/delgan/Code/test [found 730 in 1 exec envs] (17ms)
2024-11-03 16:01:53.503 [info] [Info  - 4:01:53 PM] (73622) indexed(2) 15 files over 1 exec env
2024-11-03 16:01:53.503 [info] [Info  - 4:01:53 PM] (73622) Indexing finished(2).
2024-11-03 16:01:53.504 [info] (73622) [BG(1)] SemanticTokens full at file:///home/delgan/Code/test/app.py (2ms)
2024-11-03 16:01:53.505 [info] (73622) [BG(1)] SemanticTokens range 0:0 - 5:0 at file:///home/delgan/Code/test/app.py (0ms)
2024-11-03 16:01:55.056 [info] (73622) [BG(1)] SemanticTokens delta previousResultId:1730646113413 at file:///home/delgan/Code/test/app.py (0ms)
2024-11-03 16:02:02.163 [info] (73622) [FG] parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/typing.pyi [fs read 1ms] (22ms)
2024-11-03 16:02:02.178 [info] (73622) [FG] binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/typing.pyi (15ms)
2024-11-03 16:02:02.208 [info] (73622) [FG] parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (12ms)
2024-11-03 16:02:02.214 [info] (73622) [FG] binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/types.pyi (6ms)
2024-11-03 16:02:02.227 [info] (73622) [FG] parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 1ms] (7ms)
2024-11-03 16:02:02.232 [info] (73622) [FG] binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (4ms)
2024-11-03 16:02:02.241 [info] (73622) [FG] parsing: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/abc.pyi [fs read 1ms] (1ms)
2024-11-03 16:02:02.242 [info] (73622) [FG] binding: file:///home/delgan/.vscode/extensions/ms-python.vscode-pylance-2024.10.1/dist/typeshed-fallback/stdlib/abc.pyi (0ms)
2024-11-03 16:02:02.245 [info] (73622) [FG] parsing: file:///home/delgan/Code/test/mylib/__init__.pyi [fs read 0ms] (0ms)
2024-11-03 16:02:02.246 [info] (73622) [FG] binding: file:///home/delgan/Code/test/mylib/__init__.pyi (1ms)
2024-11-03 16:02:02.255 [info] (73622) Attempting to resolve using local imports: __builtins__
2024-11-03 16:02:02.256 [info] (73622) Attempting to resolve using root path 'file:///home/delgan/Code/test/mylib'
2024-11-03 16:02:02.256 [info] (73622) [FG] parsing: file:///home/delgan/Code/test/mylib/__init__.py [fs read 0ms] (1ms)
2024-11-03 16:02:02.257 [info] (73622) [FG] binding: file:///home/delgan/Code/test/mylib/__init__.py (1ms)
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants