/learn-python

Learning Python, folder structure, test tools, examples and more

Primary LanguagePythonMIT LicenseMIT

Learn Python

This project consists of different examples I used for learning python. It also has pointers to folder structure, tools for testing , project setup etc.

Setup

Python

For Mac, install python 3.8 using:

brew install python@3.8

Virtualenv

  • Install virtualenv
pip3 install virtualenv --user
  • Setup virtual environment for the project
virtualenv -p /usr/local/opt/python@3.8/bin/python3  venv
  • Activate virtualenv
source venv/bin/activate

Install Dependencies

echo 'Installing dev dependencies...'
pip install -r requirements-dev.txt

echo 'Installing test dependencies...'
pip install -r tests/requirements.txt

echo 'Installing test dependencies...'
pip install -r basics/requirements.txt

Pre-Commit Hools

Setup

pre-commit install

Code Style

Linting

In order to check for conventions using flake8 run command:

flake8 .

The flake8 configuration can be found in setup.cfg in section flake8.

Fix

black .

Tests

Unit Tests

pytest tests

Security

Safety Check

safety

Static Code Analysis

bandit -r .

Tools List

https://github.com/vintasoftware/python-linters-and-code-analysis

Suggested Tools

  • Code Style: flake8