Skip to content

Commit f115a3c

Browse files
authored
Offer sensible default VSCode settings (#9436)
1 parent 4d6fda9 commit f115a3c

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
tests/stubtest_allowlists/*.txt linguist-language=ini
44
tests/pytype_exclude_list.txt linguist-language=ini
55
pyrightconfig*.json linguist-language=jsonc
6+
.vscode/*.json linguist-language=jsonc

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ analyze.py
6060
# Editor backup files
6161
*~
6262
.*.sw?
63-
.vscode/
63+
.vscode/*
64+
!.vscode/settings.default.json
65+
!.vscode/extensions.json
6466
.idea/
6567
.venv*/
6668

.vscode/extensions.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for your ease of use.
2+
3+
// Keep in alphabetical order
4+
{
5+
"recommendations": [
6+
"bierner.github-markdown-preview",
7+
"bungcip.better-toml",
8+
"editorconfig.editorconfig",
9+
"ms-python.black-formatter",
10+
"ms-python.flake8",
11+
"ms-python.isort",
12+
"ms-python.python",
13+
"ms-python.vscode-pylance",
14+
"redhat.vscode-yaml",
15+
],
16+
"unwantedRecommendations": [
17+
/*
18+
* Don't recommend by default for this workspace
19+
*/
20+
"christian-kohler.npm-intellisense",
21+
/*
22+
* Must disable in this workspace
23+
* https://github.com/microsoft/vscode/issues/40239
24+
*/
25+
// We use black
26+
"ms-python.autopep8",
27+
// Not using pylint
28+
"ms-python.pylint",
29+
// VSCode has implemented an optimized version
30+
"coenraads.bracket-pair-colorizer",
31+
"coenraads.bracket-pair-colorizer-2",
32+
// Obsoleted by Pylance
33+
"ms-pyright.pyright",
34+
],
35+
}

.vscode/settings.default.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copy this file as `.vscode/settings.json` to configure VSCode for this workspace.
3+
* Unfortunately, VSCode doesn't (yet) offer any way to have "workspace defaults" or "user-worspace settings",
4+
* so offering defaults to copy is the best we can do at the moment.
5+
*
6+
* ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for your ease of use.
7+
*/
8+
{
9+
// Don't format on save for formatters we don't explicitely control
10+
"editor.formatOnSave": false,
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll": false
13+
},
14+
// Set file associations to support comments syntax highlight
15+
"files.associations": {
16+
"settings.default.json": "jsonc",
17+
"pyrightconfig*.json": "jsonc",
18+
".flake8": "properties",
19+
"stubtest_allowlist*.txt": "properties",
20+
"**/stubtest_allowlists/*.txt": "properties",
21+
"pytype_exclude_list.txt": "properties"
22+
},
23+
"files.exclude": {
24+
"**/.mypy_cache": true
25+
},
26+
"files.insertFinalNewline": true,
27+
"files.trimFinalNewlines": true,
28+
"files.trimTrailingWhitespace": true,
29+
"editor.comments.insertSpace": true,
30+
"editor.insertSpaces": true,
31+
"editor.detectIndentation": false,
32+
"editor.tabSize": 2,
33+
"[json][jsonc][python]": {
34+
"editor.tabSize": 4
35+
},
36+
"[markdown]": {
37+
"editor.rulers": [
38+
90,
39+
130
40+
]
41+
},
42+
"[git-commit]": {
43+
"editor.rulers": [
44+
72
45+
]
46+
},
47+
"[yaml]": {
48+
"editor.defaultFormatter": "redhat.vscode-yaml",
49+
"editor.formatOnSave": true,
50+
"editor.codeActionsOnSave": {
51+
"source.fixAll": true
52+
}
53+
},
54+
"[python]": {
55+
"editor.defaultFormatter": "ms-python.black-formatter",
56+
"editor.rulers": [
57+
130
58+
],
59+
"editor.formatOnSave": true,
60+
"editor.codeActionsOnSave": {
61+
"source.fixAll": true,
62+
"source.fixAll.unusedImports": true,
63+
"source.fixAll.convertImportFormat": true,
64+
"source.organizeImports": true
65+
}
66+
},
67+
"isort.check": true,
68+
// Using the dedicated black extension
69+
"black-formatter.importStrategy": "fromEnvironment",
70+
"python.formatting.provider": "none",
71+
// Important to follow the config in pyrightconfig.json
72+
"python.analysis.useLibraryCodeForTypes": false,
73+
"python.analysis.extraPaths": [
74+
"tests"
75+
],
76+
"python.linting.enabled": true,
77+
"python.linting.mypyEnabled": true,
78+
"python.linting.mypyArgs": [
79+
"--show-column-numbers",
80+
"--no-pretty",
81+
"--custom-typeshed-dir=${workspaceFolder}",
82+
"--python-version=3.7"
83+
],
84+
"isort.importStrategy": "fromEnvironment",
85+
// Not using bandit
86+
"python.linting.banditEnabled": false,
87+
// Using dedicated Flake8 extension
88+
"python.linting.flake8Enabled": false,
89+
"python.linting.pycodestyleEnabled": false,
90+
"python.linting.prospectorEnabled": false,
91+
"python.linting.pylamaEnabled": false,
92+
// Use the new dedicated extensions instead (and we're not using pylint)
93+
"python.linting.pylintEnabled": false
94+
}

0 commit comments

Comments
 (0)