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

typing.Annotated is not suggested for auto-import in Quick Fix menu #6602

Open
reuben opened this issue Oct 25, 2024 · 1 comment
Open

typing.Annotated is not suggested for auto-import in Quick Fix menu #6602

reuben opened this issue Oct 25, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@reuben
Copy link

reuben commented Oct 25, 2024

Environment data

  • Pylance version: v2024.10.1
  • OS and version:
    • Host: macOS Sequoia 15.1 (24B82)
    • Remote: Ubuntu 20.04.6 LTS
  • Python version: 3.10.13

Code Snippet

Define an Annotated type Result:

from typing import Annotated, Generic, Literal, TypeVar

from pydantic import BaseModel, Field

T_co = TypeVar("T_co", covariant=True)
E_co = TypeVar("E_co", covariant=True)


class Success(BaseModel, Generic[T_co]):
    type: Literal["success"] = "success"
    value: T_co


class Error(BaseModel, Generic[E_co]):
    type: Literal["error"] = "error"
    error: E_co


Result = Annotated[
    Success[T_co] | Error[E_co],
    Field(discriminator="type"),
]

Repro Steps

Introduce a new usage of an Annotated type and use "Quick Fix" in VSCode.

  1. In a different file write:
foo: Result[int, str] = Success(value=10)
# cursor: |
  1. Use Quick Fix shortcut

Expected behavior

Import of module defining Result is suggested.

Actual behavior

Module defining Result is not suggested.

Logs

2024-10-25 16:18:54.319 [info] [Info  - 4:18:54 PM] (2069442) Server root directory: file:///home/reuben/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-25 16:18:54.320 [info] [Info  - 4:18:54 PM] (2069442) Pylance language server 2024.10.1 (pyright version 1.1.382, commit e46efc6b) starting
2024-10-25 16:18:54.325 [info] [Info  - 4:18:54 PM] (2069442) Starting service instance "redacted"
2024-10-25 16:18:54.958 [info] [Info  - 4:18:54 PM] (2069442) Setting environmentName for service "redacted": "3.10.13 (next-vavphVWf venv)"
2024-10-25 16:18:54.975 [info] [Info  - 4:18:54 PM] (2069442) Setting pythonPath for service "redacted": "/home/reuben/.local/share/virtualenvs/next-vavphVWf/bin/python"
2024-10-25 16:18:54.976 [info] [Info  - 4:18:54 PM] (2069442) No include entries specified; assuming /home/reuben/dev/redacted
2024-10-25 16:18:54.982 [info] [Info  - 4:18:54 PM] (2069442) Auto-excluding **/node_modules
2024-10-25 16:18:54.982 [info] [Info  - 4:18:54 PM] (2069442) Auto-excluding **/__pycache__
2024-10-25 16:18:55.003 [info] [Info  - 4:18:55 PM] (2069442) Auto-excluding **/.*
2024-10-25 16:18:55.025 [info] [Info  - 4:18:55 PM] (2069442) Assuming Python version 3.10.13.final.0
2024-10-25 16:18:55.296 [info] [Info  - 4:18:55 PM] (2069442) Found 1047 source files
2024-10-25 16:18:55.705 [info] [Info  - 4:18:55 PM] (2069442) Background analysis(1) root directory: file:///home/reuben/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-25 16:18:55.705 [info] [Info  - 4:18:55 PM] (2069442) Background analysis(1) started
2024-10-25 16:18:55.706 [info] [Info  - 4:18:55 PM] (2069442) Indexer background runner(2) root directory: file:///home/reuben/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist (index)
2024-10-25 16:18:55.706 [info] [Info  - 4:18:55 PM] (2069442) Indexing(2) started
2024-10-25 16:18:56.156 [info] [Info  - 4:18:56 PM] (2069442) scanned(2) 544 files over 1 exec env
2024-10-25 16:18:56.429 [info] [Info  - 4:18:56 PM] (2069442) indexed(2) 544 files over 1 exec env
2024-10-25 16:18:56.552 [info] [Info  - 4:18:56 PM] (2069442) Indexing finished(2).
2024-10-25 16:19:01.116 [info] [Info  - 4:19:01 PM] (2069442) Starting service instance "<default>"
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) Setting environmentName for service "<default>": "3.10.13 (next-vavphVWf venv)"
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) Setting pythonPath for service "<default>": "/home/reuben/.local/share/virtualenvs/next-vavphVWf/bin/python"
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) No include entries specified; assuming /<default workspace root>
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) Auto-excluding **/node_modules
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) Auto-excluding **/__pycache__
2024-10-25 16:19:01.131 [info] [Info  - 4:19:01 PM] (2069442) Auto-excluding **/.*
2024-10-25 16:19:01.162 [info] [Info  - 4:19:01 PM] (2069442) Assuming Python version 3.10.13.final.0
2024-10-25 16:19:01.221 [info] [Error - 4:19:01 PM] (2069442) File or directory "/<default workspace root>" does not exist.
2024-10-25 16:19:01.221 [info] [Info  - 4:19:01 PM] (2069442) No source files found.
2024-10-25 16:19:01.225 [info] [Info  - 4:19:01 PM] (2069442) [id_0] Logging started
2024-10-25 16:19:01.440 [info] [Info  - 4:19:01 PM] (2069442) Found 1047 source files
2024-10-25 16:19:01.516 [info] [Error - 4:19:01 PM] (2069442) File or directory "/<default workspace root>" does not exist.
2024-10-25 16:19:01.516 [info] [Info  - 4:19:01 PM] (2069442) No source files found.
2024-10-25 16:19:01.520 [info] [Info  - 4:19:01 PM] (2069442) Background analysis(3) root directory: file:///home/reuben/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-25 16:19:01.520 [info] [Info  - 4:19:01 PM] (2069442) Background analysis(3) started
2024-10-25 16:19:04.436 [info] (Client) The existing extension didn't exit within 10 seconds. New instance will start, but you might encounter issues.
2024-10-25 16:19:04.436 [info] (Client) Pylance async client (2024.10.1) started with python extension (2024.16.1)
2024-10-25 16:19:14.616 [info] [Info  - 4:19:14 PM] (2069442) [id_0] Logging stopped at /tmp/pyright-2069442-JlwFjC36EsjZ/pylance_2024.10.1_id_0.txt
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Oct 25, 2024
@reuben reuben changed the title typing.Annotated is not suggested for auto-import typing.Annotated is not suggested for auto-import in Quick Fix menu Oct 25, 2024
@KacieKK
Copy link
Contributor

KacieKK commented Oct 26, 2024

Thanks for reporting, I can reproduce

@KacieKK KacieKK added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants