Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>Python Graph ViewNew to Visual Studio Code? Get it now.
Python Graph View

Python Graph View

Bamin83

|
6 installs
| (0) | Free
Python import dependency graphs for VS Code workspaces.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Python Graph View

English | 日本語


English

A VS Code extension that visualizes Python workspace import dependencies as an interactive node graph, similar to Obsidian's Graph View.

Demo

✨ Features

  • Force-directed interactive graph inspired by Obsidian's Graph View
  • Two views: Dependency Graph (workspace-wide overview) and Local Graph (1-hop focus)
  • Automatic re-analysis and graph updates on file save (~500 ms debounce)
  • Filter toggles for external / module / test nodes + keyword filtering
  • Related edge highlight on node hover
  • Viewport controls: mouse-wheel zoom, middle-button pan, Fit / Reset buttons
  • AST-based static analysis (no Python execution required)

Prerequisites

  • Python 3.11 or later (resolvable via system PATH or sbAstGrapher.pythonCommand)

📦 Installation

From VS Code Marketplace (Recommended)

Search for "Python Graph View" in the VS Code Extensions panel.

Manual Install via VSIX

code --install-extension .\sb-astgrapher-0.1.0.vsix

Or use the Install from VSIX... command in VS Code and select the .vsix file.

Usage

  1. Open a Python project folder in VS Code
  2. Click the AST Graph icon in the Activity Bar
  3. Check the workspace-wide dependency graph in Dependency Graph
  4. Open a .py file in the editor — Local Graph auto-focuses on it
  5. Alt+click a node in Dependency Graph to pin the Local Graph to that node

The graph updates automatically on every file save. Use the Refresh Graph button for manual updates.

Display Filters

Use the toolbar toggles to control what is shown.

Toggle Effect
external Show/hide external import nodes (third-party & standard library)
module Show/hide module nodes that aggregate packages with __init__.py
test Show/hide test file nodes

Type a keyword in the toolbar input to filter by file path or external module name. Multiple terms separated by spaces act as an AND search; terms prefixed with '-' are excluded.

⚙️ Settings

Key Default Description
sbAstGrapher.pythonCommand python Python interpreter to launch the adapter. Accepts a command name or absolute path
sbAstGrapher.showExternalNodes false Initial visibility of external nodes
sbAstGrapher.excludeFolders [] Array of folder names to exclude from analysis (e.g. ["scratch", "example"])
sbAstGrapher.labelMode compact Label display mode. compact shows abbreviated labels; hidden shows labels only on hover
sbAstGrapher.zoomFadeLabels true Automatically fade out normal node labels when zoomed out

When using .venv, set sbAstGrapher.pythonCommand to the absolute path of .venv\Scripts\python.exe.

⚠️ Known Limitations

Item Details
Python-only MVP Current version supports Python files only
File-level analysis Node granularity is per-file. Class/function-level analysis is not implemented
Single-root only Only the active or selected workspace folder is analyzed
Local environment only Untested on Remote SSH / Dev Containers / WSL / Codespaces
Import resolution Simple AST-based implementation. Namespace packages and dynamic imports are not supported

License

MIT — see LICENSE for details.


日本語

Python ワークスペースの import 依存関係を、Obsidian のグラフビューのようなインタラクティブなノードグラフで可視化する VS Code 拡張機能です。

デモ

✨ 特徴

  • Obsidian のグラフビューライクな force-directed インタラクティブグラフ
  • Dependency Graph(全体俯瞰)と Local Graph(1 hop フォーカス)の 2 ビュー
  • ファイル保存のたびに自動再解析・グラフ更新(~500 ms 集約)
  • external / module / test ノードのフィルタトグル + キーワード絞り込み
  • ノード hover で関連エッジをハイライト
  • マウスホイール zoom・中ボタン pan・Fit / Reset ボタンのビューポート操作
  • AST ベースの静的解析(Python の実行不要)

前提

  • Python 3.11 以上(システム PATH または sbAstGrapher.pythonCommand で解決できること)

📦 インストール

VS Code Marketplace から(推奨)

VS Code の拡張機能パネルで "Python Graph View" を検索してインストールします。

VSIX から手動インストール

code --install-extension .\sb-astgrapher-0.1.0.vsix

または VS Code の Install from VSIX... コマンドから .vsix ファイルを指定します。

使い方

  1. Python プロジェクトのフォルダを VS Code で開く
  2. Activity Bar の AST Graph アイコンをクリック
  3. サイドバーの Dependency Graph でワークスペース全体の依存グラフを確認
  4. .py ファイルをエディタで開くと Local Graph に自動フォーカス
  5. Dependency Graph のノードを Alt+クリック すると Local Graph を任意ノードに固定できます

ファイルを保存するたびにグラフが自動更新されます。手動更新は Refresh Graph ボタンを使います。

表示フィルタ

ツールバーのトグルで表示対象を切り替えられます。

トグル 効果
external 外部 import ノード(サードパーティ・標準ライブラリ)の表示切り替え
module __init__.py を持つパッケージをまとめたモジュールノードの表示切り替え
test テストファイルノードの表示切り替え

ツールバーの入力欄にキーワードを入力すると、ファイルパスや external モジュール名でフィルタできます。スペース区切りで AND 絞り込み、- 始まりで除外条件になります。

Local Graph のフォーカス

  • .py ファイルをエディタで開くと自動でフォーカスが更新されます(active editor 起点)。
  • Dependency Graph のノードを Alt+クリック するとそのノードに固定できます(explicit 起点)。
  • ツールバーの Clear Focus でフォーカスを解除できます。

⚙️ 設定

設定キー 既定値 説明
sbAstGrapher.pythonCommand python adapter を起動するインタープリタ。コマンド名または絶対パスを指定します
sbAstGrapher.showExternalNodes false external ノード(外部 import)の初期表示
sbAstGrapher.excludeFolders [] 解析から除外するフォルダ名の配列(例: ["scratch", "example"])
sbAstGrapher.labelMode compact ラベル表示モード。compact は省略ラベル、hidden は hover 時のみ表示
sbAstGrapher.zoomFadeLabels true 俯瞰時(zoom 低下時)に通常ノードのラベルを自動フェード

.venv を使う場合は sbAstGrapher.pythonCommand に .venv\Scripts\python.exe の絶対パスを設定します。

全設定一覧

全般

設定キー 既定値 説明
sbAstGrapher.pythonCommand python adapter を起動するインタープリタ。コマンド名または絶対パスを指定します
sbAstGrapher.pythonAdapterPath — adapter CLI のパス。相対パスは拡張ルートから解決されます
sbAstGrapher.adapterTimeoutMs 30000 adapter 実行のタイムアウト(ミリ秒)
sbAstGrapher.showExternalNodes false external ノードの初期表示。Webview のトグルは起動毎にこの値で初期化
sbAstGrapher.showModuleNodes false module(パッケージ)ノードの初期表示。__init__.py を持つディレクトリをまとめて表示
sbAstGrapher.excludeFolders [] 解析から除外するフォルダ名の配列。固定除外ディレクトリ(.venv, venv, __pycache__, node_modules, .git)はこの設定に関わらず常に除外されます
sbAstGrapher.fitToVisibleOnExternalToggle false external トグル切り替え時の auto-fit 対象。true のとき visible ノード集合へ fit

表示

設定キー 既定値 説明
sbAstGrapher.labelMode compact ラベル表示モード。compact は省略ラベル、hidden は hover 時のみ表示
sbAstGrapher.labelPosition under ラベル配置位置。under はノード真下、left-right は外向き配置
sbAstGrapher.zoomFadeLabels true 俯瞰時に通常ノードのラベルを自動フェード

レイアウト(d3-force パラメータ)

d3-force simulation の挙動を制御するパラメータです。値は Webview UI の初期値として使用され、起動毎に設定値で初期化されます。

設定キー 既定値 説明
sbAstGrapher.layout.linkDistance 120 リンクの目標距離 (px)。大きいほどノードが広がります
sbAstGrapher.layout.linkStrength 0.6 リンクの強度 (0–2)
sbAstGrapher.layout.linkIterations 1 リンク force の反復回数
sbAstGrapher.layout.repulsionStrength -300 反発強度(負値)。絶対値が大きいほど広がります
sbAstGrapher.layout.repulsionDistanceMax 800 反発の影響距離上限 (px)
sbAstGrapher.layout.collisionRadius 30 衝突判定半径 (px)
sbAstGrapher.layout.animationEnabled false true のときリアルタイムアニメーション表示

⚠️ 既知の制限

事項 詳細
Python 専用 MVP 現バージョンは Python ファイルのみ対応。他言語は未対応
ファイル単位解析 ノード粒度はファイル単位。クラス・関数レベルの解析は未実装
マルチルート非対応 アクティブまたは選択中のワークスペースフォルダのみ解析します
ローカル限定 Remote SSH / Dev Containers / WSL / Codespaces での動作は未検証
import 解決 AST ベースの簡易実装。名前空間パッケージや動的 import は非対応

ライセンス

MIT — 詳細は LICENSE を参照してください。


開発・コントリビューション: CONTRIBUTING.md

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft