👌
Python開発者向け拡張機能&settings.json
プログラマーならほぼ全員が使っているであろうVS Codeのsettings.jsonを見れば、大体その人がどんな技術を持った人か、どんな価値観を持っているかが分かると思うんです。
今回は拡張機能の整理も兼ねて、実際に使っている設定を公開します!
「設定だけ見たい!」という方は目次から一番下の「完全版:拡張機能&settings.json」に飛んでください。
絶対に入れておきたい設定
1. Ruff(フォーマッター&リンター)
Ruffって何?
Pythonのコードを綺麗にしてくれるツールです。保存するだけで自動的にコードが整理されます。
実際の効果
- 保存時に自動でコードが綺麗になる(フォーマットだけ)
- チーム開発でコードのスタイルが統一される
- 職場でもコードが綺麗だと褒められました
settings.json
"ruff.lint.run": "onSave",
"ruff.organizeImports": true,
"ruff.fixAll": true,
"ruff.lint.args": [
"--line-length=150",
"--select=ALL",
"--ignore=EXE,E501,D400,N803,N812,S104,C901,UP030,PGH003,D415,G004,D100,BLE001,ANN401,INP001,TRY,EM,B,ANN204,PLR0913,PERF203,ASYNC109,FBT"
]
2. Pylance(型チェック)
**Pylanceって何?**
Microsoftが作ったPython用の言語サーバーです。型チェックやコード補完を強化してくれます。
**実際の効果**
- 変数の型が画面に表示される(下の画像参照)
- バグを書く前に教えてくれる
- コードの補完が爆速になる

*basicだけでも十分ありがたい*
「Pythonで型を気にするのってどうなの?」って気持ちは抑えてください。規模が大きくなってくると結構大切です。コード品質を保つためにはこういうところから変えていかないと、誰も自分自身のプログラムを理解することはできません。
#### settings.json
```json
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic",
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.inlayHints.functionReturnTypes": true
### 3. GitHub Copilot

これを使わないとやっていけない。最近色んな機能が増えていて追えていません。また別記事を書きます。でもとりあえずエージェントモードでコード書いてもらえるだけで嬉しい。
学割なくなって今はフリープランになっちゃったけど、入れないと効率悪すぎてストレスです。
```json
"github.copilot.enable": {
"*": false,
"plaintext": true,
"markdown": true,
"scminput": true
},
"github.copilot.nextEditSuggestions.enabled": true
なぜこの設定?
全部有効にするとAIに依存しすぎてしまうので、戦略的に使い分けています:
- Python開発時: 無効化→基本的なコーディング能力を維持
- ドキュメント作成: 有効化→マークダウンファイルの作成を効率化
- Git操作: 有効化→コミットメッセージの提案で品質向上
Next Edit Suggestionsって何?
一時期話題になったすごい機能です。コード編集時に次の変更候補が表示され、リファクタリングや機能追加の効率が向上します。地味にめちゃくちゃ便利。
4. Git関連
settings.json
"files.autoSave": "onWindowChange",
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true
実際の効果
- ウィンドウを切り替えると自動保存される
- Gitの操作が半自動化される
- 「保存し忘れた!」がなくなる
その他の便利設定
Jupyter Notebook関連
本当はもう少し付属の拡張機能があるけど省略
settings.json
"jupyter.languageServer": "Pylance",
"notebook.formatOnSave.enabled": true,
"notebook.lineNumbers": "on"
Jupyter NotebookでもPylanceを適用できるので、notebookでも綺麗にコードが書けます。
(jupyter notebookをそもそも使うべきではない、という意見もちらほら...)
導入手順(初心者向け)
1. 設定ファイルを編集
- VS Codeで
Ctrl+Shift+P
(macOS:Cmd+Shift+P
)を押す -
Preferences: Open User Settings (JSON)
を選択 - 下記の設定をコピー&ペースト
3. トラブルシューティング
動作が重い場合
"python.analysis.indexing": false
を追加してみてください。
Ruffが動かない場合
Ruff拡張機能がインストールされているか確認してください。
Before/After:設定導入の効果
導入前
- 手動でコードフォーマット
- 型エラーに気づかずデバッグに時間を消費
- コミットメッセージを毎回考える
- スタイル統一に時間を消費
導入後
- 保存時に自動フォーマット
- 型エラーを書く前に警告
- AIがコミットメッセージを提案
- チーム開発でのスタイル統一が自動化
完全版:拡張機能&settings.json
拡張機能
aaron-bond.better-comments
alefragnani.project-manager
amazonwebservices.aws-toolkit-vscode
anysphere.pyright
aslamanver.vsc-export
atian25.copy-syntax
charliermarsh.ruff
christian-kohler.path-intellisense
chrmarti.regex
davidanson.vscode-markdownlint
dbaeumer.vscode-eslint
donjayamanne.githistory
eamodio.gitlens
emeraldwalk.runonsave
fabiospampinato.vscode-todo-plus
github.copilot
github.copilot-chat
github.remotehub
google.geminicodeassist
gruntfuggly.todo-tree
hbenl.vscode-test-explorer
hediet.vscode-drawio
ionutvmi.path-autocomplete
julesmons.recline
kevinrose.vsc-python-indent
littlefoxteam.vscode-python-test-adapter
masakit.zenkaku-hankaku
mechatroner.rainbow-csv
mhutchie.git-graph
mosapride.zenkaku
ms-azuretools.vscode-docker
ms-ceintl.vscode-language-pack-ja
ms-python.debugpy
ms-python.mypy-type-checker
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remaaron-bond.better-comments
alefragnani.project-manager
amazonwebservices.aws-toolkit-vscode
anysphere.pyright
aslamanver.vsc-export
atian25.copy-syntax
charliermarsh.ruff
christian-kohler.path-intellisense
chrmarti.regex
davidanson.vscode-markdownlint
dbaeumer.vscode-eslint
donjayamanne.githistory
eamodio.gitlens
emeraldwalk.runonsave
fabiospampinato.vscode-todo-plus
github.copilot
github.copilot-chat
github.remotehub
google.geminicodeassist
gruntfuggly.todo-tree
hbenl.vscode-test-explorer
hediet.vscode-drawio
ionutvmi.path-autocomplete
julesmons.recline
kevinrose.vsc-python-indent
littlefoxteam.vscode-python-test-adapter
masakit.zenkaku-hankaku
mechatroner.rainbow-csv
mhutchie.git-graph
mosapride.zenkaku
ms-azuretools.vscode-docker
ms-ceintl.vscode-language-pack-ja
ms-python.debugpy
ms-python.mypy-type-checker
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode.azure-repos
ms-vscode.live-server
ms-vscode.remote-explorer
ms-vscode.remote-repositories
ms-vscode.remote-server
ms-vscode.test-adapter-converter
njpwerner.autodocstring
oderwat.indent-rainbow
redhat.vscode-yaml
richie5um2.vscode-sort-json
rooveterinaryinc.roo-cline
rssowl.copy-relative-path-posix
ryanluker.vscode-coverage-gutters
saoudrizwan.claude-dev
shardulm94.trailing-spaces
shd101wyy.markdown-preview-enhanced
sourcegraph.cody-ai
streetsidesoftware.code-spell-checker
tomoki1207.pdf
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vscode-icons-team.vscode-icons
wayou.vscode-todo-highlight
yzhang.markdown-all-in-one
ote-extensionpack
ms-vscode.azure-repos
ms-vscode.live-server
ms-vscode.remote-explorer
ms-vscode.remote-repositories
ms-vscode.remote-server
ms-vscode.test-adapter-converter
njpwerner.autodocstring
oderwat.indent-rainbow
redhat.vscode-yaml
richie5um2.vscode-sort-json
rooveterinaryinc.roo-cline
rssowl.copy-relative-path-posix
ryanluker.vscode-coverage-gutters
saoudrizwan.claude-dev
shardulm94.trailing-spaces
shd101wyy.markdown-preview-enhanced
sourcegraph.cody-ai
streetsidesoftware.code-spell-checker
tomoki1207.pdf
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vscode-icons-team.vscode-icons
wayou.vscode-todo-highlight
yzhang.markdown-all-in-one
settings.json
{
// === Git設定 ===
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"git.ignoreRebaseWarning": true,
"git.openRepositoryInParentFolders": "never",
// === ファイル・エクスプローラー設定 ===
"files.autoSave": "onWindowChange",
"files.insertFinalNewline": true,
"files.autoGuessEncoding": true,
"explorer.confirmDelete": true,
"files.exclude": {
"**/__pycache__": true,
"**/*.pyc": true,
"**/.Identifier": true
},
// === エディター基本設定 ===
"editor.fontFamily": "'Fira Code', Hasklig, Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.fontSize": 17,
"editor.minimap.enabled": false,
"editor.renderControlCharacters": true,
"editor.renderLineHighlight": "all",
"editor.suggestSelection": "first",
"editor.wordWrap": "off",
"editor.guides.indentation": false,
"editor.guides.bracketPairs": false,
"editor.bracketPairColorization": true,
"editor.unicodeHighlight.ambiguousCharacters": true,
"editor.inlayHints.enabled": "off",
"editor.inlineSuggest.suppressSuggestions": true,
// === カーソル設定 ===
"editor.cursorBlinking": "smooth",
"editor.cursorSmoothCaretAnimation": "on",
"editor.cursorStyle": "block",
// === フォーマット・保存時アクション ===
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit",
"source.fixAll.ruff": "explicit",
"source.fixAll": "explicit"
},
// === Python・Pylance設定 ===
"python.languageServer": "Pylance",
"python.analysis.packageIndexDepths": [
{
"name": "sklearn",
"depth": 2
},
{
"name": "matplotlib",
"depth": 2
},
{
"name": "scipy",
"depth": 2
},
{
"name": "pandas",
"depth": 1
}
],
// === Ruff設定 ===
"ruff.organizeImports": true,
"ruff.fixAll": true,
// "ruff.lintOnSave": true,
// "ruff.autoFixOnSave": true,
"ruff.path": ["ruff"],
"ruff.lint.args": [
"--line-length=150",
"--select=ALL",
"--ignore=EXE,E501,D400,N803,N812,S104,C901,UP030,PGH003,D415,G004,D100,BLE001,ANN401,INP001,TRY,EM,B,ANN204,PLR0913,PERF203,ASYNC109,FBT",
"--per-file-ignores=__init__.py:F401"
],
// === Jupyter・Notebook設定 ===
"notebook.experimental.remoteSave": true,
"notebook.formatOnSave.enabled": true,
"notebook.lineNumbers": "on",
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
// === 言語別フォーマッター設定 ===
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit",
"source.fixAll.ruff": "explicit"
}
},
"[notebook]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit",
"source.fixAll.ruff": "explicit"
}
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// // === GitHub Copilot設定 ===
// "github.copilot.enable": {
// "*": false,
// "plaintext": true,
// "markdown": true,
// "scminput": true
// },
// "github.copilot.nextEditSuggestions.enabled": true,
// === その他の設定 ===
"breadcrumbs.enabled": true,
"window.zoomLevel": 0,
"diffEditor.maxComputationTime": 0,
"diffEditor.wordWrap": "off",
"security.workspace.trust.untrustedFiles": "open",
"security.allowedUNCHosts": [
"wsl.localhost"
],
"update.showReleaseNotes": false,
"inlineChat.acceptedOrDiscardBeforeSave": false,
// === スペルチェック設定 ===
"cSpell.autoFormatConfigFile": true,
"cSpell.ignoreRegExpList": [
"[0-9A-Za-zぁ-んァ-ヶ亜-熙纊-黑]+",
"dotenv"
],
// === カスタマイゼーション ===
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#1073cf2d",
"editor.lineHighlightBorder": "#9fced11f"
},
"workbench.activityBar.orientation": "vertical"
}
Discussion