-
Notifications
You must be signed in to change notification settings - Fork 0
VSCode set up
Install Poetry and familiarize yourself with the commands. Poetry makes it easier to manage dependencies and keep them synchronized with everyone else.
Fork and clone the commanderbot-dev repo:
git clone [email protected]:CommanderBot-Dev/commanderbot-dev.git
In the root of the repo, create a Python virtual environment:
python -m venv venv/commanderbot-dev
You can use any path for the venv, but it is recommended to use venv/commanderbot-dev
because:
- everything under
venv
is already git-ignored; and - the sub-folder
commanderbot-dev
labels the venv to help distinguish it from others.
Activate the venv you just created (such as by opening a new integrated terminal) and install dependencies:
poetry install
Once the packages are installed, you can verify the results:
poetry show
Create .vscode/settings.json
and set python.pythonPath
to the venv you just created. The path differs based on the name you chose, and whether you're on Windows or Linux. Here's what it might look like on Linux for the commanderbot-dev
repo:
{
"python.pythonPath": "venv/commanderbot-dev/bin/python"
}
It is important to configure certain project-level settings such as which code formatter to use. All Python projects use the black
formatter. You can do this either in the folder settings at .vscode/settings.json
or your workspace settings, by adding these options:
{
"python.formatting.provider": "black"
}
Note that black
itself is configured separately in pyproject.toml
as part of version control.
Here are some additional recommend settings to help streamline the development process:
{
"editor.rulers": [88],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"files.exclude": {
".pytest_cache/**": true,
"**/__pycache__": true,
"venv/**": true,
"*.egg-info/**": true
}
}
Placing these options in your workspace settings will apply them to all folders in the current workspace, which is useful if you have multiple repos present.
You can access your workspace settings by opening the command palette with ctrl + shift + p
and searching for Preferences: Open Workspace Settings (JSON)
. Make sure to place settings under the settings
field, separate from folders
.
See the CommanderBot readme for how to configure and run an instance of the bot.
Note that the two files bot.json
and bot.token
as well as the entire data
folder are already git-ignored, however you may choose to maintain your bot's state elsewhere.
Create .vscode/launch.json
to define launch/debug configuration for the bot. Here's a startign template that uses the git-ignored bot.json
and bot.token
files:
{
"version": "0.2.0",
"configurations": [
{
"name": "CommanderBot",
"type": "python",
"request": "launch",
"module": "commanderbot",
"console": "integratedTerminal",
"args": ["bot.json", "--tokenfile", "bot.token", "--log", "INFO"]
}
]
}