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

Some packages are not detected for autoImport functionality #6964

Open
AlsonYang opened this issue Feb 20, 2025 · 3 comments
Open

Some packages are not detected for autoImport functionality #6964

AlsonYang opened this issue Feb 20, 2025 · 3 comments
Assignees
Labels
needs repro Issue has not been reproduced yet user responded Was "waiting for user response" and they responded

Comments

@AlsonYang
Copy link

Environment data

  • Pylance version: Pylance language server 2024.8.1 (pyright version 1.1.373, commit ee424479)
  • OS and version: Apple M1 Pro MacOS 15.2 (24C101)
  • Python version (& distribution if applicable, e.g. Anaconda): python=3.11. langgraph="0.2.73"

Code Snippet

langgraph

Repro Steps

Type the above comment with this setting "python.analysis.autoImportCompletions": true,.

Expected behavior

I would expect to see langgraph auto import pops up while typing the above codes.

Actual behavior

When I type langgraph, langgraph is not shown on the list, but langgraph_cli and langgraph sdk showed.
I have both langgraph and pydantic installed and have the env activated. The auto import works for pydantic, but not langgraph

Logs

XXX
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Feb 20, 2025
@debonte
Copy link
Contributor

debonte commented Feb 28, 2025

@heejaechang would know better than me, but I think this may be intentional given that langgraph doesn't have an __init__.py. It contains a bunch of submodules, but to use those you would need to explicitly import them (ex. import langgraph.channels).

Put another way, how are you intending to use the langgraph symbol after importing it? Maybe a more complete code sample would help us here.

@debonte debonte added the waiting for user response Requires more information from user label Feb 28, 2025
@AlsonYang
Copy link
Author

AlsonYang commented Mar 1, 2025

@debonte Thanks for the chasing this up.

I don't use the langgraph symbol directly, but the submodule that it contains. Anything that relates to the LangGraph package is not detected. The reason I had langgraph in the issue body is because even the main module is not detected.

This is the way that LangGraph is normally used

from langgraph.graph import StateGraph
graph_builder = StateGraph()

Issue: When I type StateGraph, the auto import doesn't pop up, so I would need to manually add in the import line myself.

Same issue with the LangChain package with the below usage

from langchain_core.messages import HumanMessage
HumanMessage(content="Hello, world!")

@github-actions github-actions bot added user responded Was "waiting for user response" and they responded and removed waiting for user response Requires more information from user labels Mar 1, 2025
@PabloLION
Copy link

Same here. I want to auto-import some symbol from the package I'm writing, but pylance stopped doing that a while ago. and I tried to modify these settings python.analysis.userFileIndexingLimit, "python.analysis.userFileIndexingLimit": -1,, Added my package to python.analysis.packageIndexDepths, with "includeAllSymbols": true, "python.analysis.showOnlyDirectDependenciesInAutoImport": true, adding the package into "python.autoComplete.extraPaths"

And I have the workspace settings like this (my package name is line_length_lint):

  "python.analysis.extraPaths": ["line_length_lint/**"],
  "python.autoComplete.extraPaths": ["line_length_lint/**"],
  "python.analysis.packageIndexDepths": [
    {
      "name": "line_length_lint",
      "depth": 100,
      "includeAllSymbols": true
    }
  ],
  "python.analysis.userFileIndexingLimit": -1

And my user setting is like this

  "python.analysis.autoFormatStrings": true,
  "python.analysis.autoImportCompletions": true,
  "python.analysis.completeFunctionParens": true,
  "python.analysis.diagnosticMode": "workspace",
  "python.analysis.enableExperimentalServer": false,
  "python.analysis.exclude": [
    "dist",
    "**/site-packages/**", // Exclude installed packages
    "**/venv/**", // Exclude virtual environments
    "**/.venv/**", // Exclude virtual envs with .venv naming
    "**/__pycache__/**", // Exclude Python cache files
    "**/.git/**", // Exclude Git repository files
    "**/.vscode/**" // Exclude VS Code workspace settings
  ],
  "python.analysis.extraCommitChars": true,
  "python.analysis.fixAll": [
    "source.convertImportFormat",
    "source.unusedImports"
  ],
  "python.analysis.generateWithTypeAnnotation": true,
  "python.analysis.indexing": true,
  "python.analysis.inlayHints.callArgumentNames": "all",
  "python.analysis.inlayHints.functionReturnTypes": true,
  "python.analysis.inlayHints.pytestParameters": true,
  "python.analysis.inlayHints.variableTypes": true,
  "python.analysis.languageServerMode": "full",
  "python.analysis.logLevel": "Trace",
  "python.analysis.packageIndexDepths": [
    {
      "depth": 0,
      "name": "ctypes"
    },
    {
      "depth": 0,
      "name": "ast"
    },
    {
      "depth": 2,
      "name": "sklearn"
    },
    {
      "depth": 2,
      "name": "matplotlib"
    },
    {
      "depth": 2,
      "name": "scipy"
    },
    {
      "depth": 2,
      "name": "django"
    },
    {
      "depth": 2,
      "name": "flask"
    },
    {
      "depth": 2,
      "name": "fastapi"
    },
    {
      "depth": 4,
      "name": "pillow"
    }
  ],
  "python.analysis.showOnlyDirectDependenciesInAutoImport": true,
  "python.analysis.supportDocstringTemplate": true,
  "python.analysis.typeCheckingMode": "strict",
  "python.analysis.typeEvaluation.deprecateTypingAliases": true,
  "python.analysis.typeEvaluation.disableBytesTypePromotions": true,
  "python.analysis.typeEvaluation.enableExperimentalFeatures": false,
  "python.analysis.typeEvaluation.enableReachabilityAnalysis": true,
  "python.analysis.typeEvaluation.strictDictionaryInference": true,
  "python.analysis.typeEvaluation.strictListInference": true,
  "python.analysis.typeEvaluation.strictSetInference": true,
  "python.analysis.userFileIndexingLimit": -1,
  "python.createEnvironment.contentButton": "show",
  "python.defaultInterpreterPath": "/usr/local/bin/python3",
  "python.languageServer": "Pylance",
  "python.testing.pytestArgs": ["tests", "-vv", "-rA", "--capture=fd"],
  "python.testing.pytestEnabled": true,

Then the auto-import function is still not detecting the symbol. However, the add import code action works (it's much harder to use than auto-import).

I also tried to bisect extensions in VSCode-insiders, yet I cannot do it with "pylance" always on. So it wasn't fruitful at all. Is there a way to fix this problem? Should I create a new issue?

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 user responded Was "waiting for user response" and they responded
Projects
None yet
Development

No branches or pull requests

3 participants