-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathsetup_vscode.py
More file actions
93 lines (72 loc) · 2.23 KB
/
setup_vscode.py
File metadata and controls
93 lines (72 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import pathlib
import json
# Define base directory
BASE_DIR = pathlib.Path(__file__).parent
def create_settings_json():
# Define settings dict
od = {}
# Editor and coding settings
od["editor.rulers"] = [
120,
]
od["editor.defaultFormatter"] = "ms-python.black-formatter"
od["python.languageServer"] = "Pylance"
od["python.analysis.diagnosticSeverityOverrides"] = {"reportShadowedImports": "none"}
# Linter settings
od["black-formatter.args"] = ["--line-length", "120"]
od["flake8.args"] = ["--max-line-length", "120", "--per-file-ignores", "__init__.py:F401,F403"]
# Create .vscode folder
vsc_dir = BASE_DIR / ".vscode"
vsc_dir.mkdir(exist_ok=True)
# Write file
vsc_file = vsc_dir / "settings.json"
with open(vsc_file, "w") as fp:
json.dump(od, fp, indent=4)
fp.write("\n")
def create_extensions_json():
# Define settings dict
od = dict()
# Recommended VSCode extensions
od["recommendations"] = [
"ms-python.python", # Python support
"ms-python.debugpy", # Python debugger
"ms-python.black-formatter", # Code formatter
"ms-python.flake8", # Code style formatter
"ms-python.vscode-pylance", # Language server
]
# Create .vscode folder
vsc_dir = BASE_DIR / ".vscode"
vsc_dir.mkdir(exist_ok=True)
# Write file
vsc_file = vsc_dir / "extensions.json"
with open(vsc_file, "w") as fp:
json.dump(od, fp, indent=4)
fp.write("\n")
def create_launch_json():
# Define settings dict
od = dict()
# VScode specific settings
od["version"] = "0.2.0"
# Debug configurations
od["configurations"] = [
# Debug current file
{
"name": "python: current file",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
},
]
# Create .vscode folder
vsc_dir = BASE_DIR / ".vscode"
vsc_dir.mkdir(exist_ok=True)
# Write file
vsc_file = vsc_dir / "launch.json"
with open(vsc_file, "w") as fp:
json.dump(od, fp, indent=4)
fp.write("\n")
# Run
create_extensions_json()
create_settings_json()
create_launch_json()