FIRST, get the following set up:
- https://brew.sh/ (if you don't have it)
- https://github.com/pyenv/pyenv - for Python versions
- https://github.com/pypa/pipenv - for Python packages
- https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring - for docstrings
These should be the full commands to install (assuming you're using bash and not ZSH):
pyenv
brew install pyenv
mkdir -p ~/.pyenv && pyenv init - > ~/.pyenv/pyenv.sh
echo "source ~/.pyenv/pyenv.sh" >> ~/.bash_profile && source ~/.bash_profile
pyenv install 3.7.1
pyenv global 3.7.1
If you get an install error on 3.7.1, I have the fix.
pipenv
brew install pipenv
echo "export PIPENV_VENV_IN_PROJECT=1" >> ~/.bash_profile
autodocstring
code --install-extensions njpwerner.autodocstring
Once that's done, create a git repo with the standard Python ignore and run these commands inside the repo directory:
pipenv install flask requests
pipenv install --dev flake8 yapf pylint pytest
And add this to .vscode/settings.json in the repo directory
{
"editor.formatOnSave": true,
"python.formatting.provider": "yapf",
"python.formatting.yapfPath": "${workspaceFolder}/.venv/bin/yapf",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "${workspaceFolder}/.venv/bin/flake8",
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "${workspaceFolder}/.venv/bin/pylint",
"python.pythonPath": "${workspaceFolder}/.venv/bin/python"
}
Make a pylint.ini file in the repo directory with the following contents:
- [pytest]
- testpaths = tests
Make a file in tests/test_hello.py with the following contents:
"""Hello World Flask Test"""
import pytest
def test_that_true_is_true:
assert true == true
And that should get you a bare-bones setup ready to make a flask app inside. LMK when you've done it and I'll send you next steps, which involves creating a controller and view templates and stuff, as well automated testing.