Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Last active September 12, 2022 05:46
Show Gist options
  • Save shiumachi/3372de6ed64a156652c01cf69749acf2 to your computer and use it in GitHub Desktop.
Save shiumachi/3372de6ed64a156652c01cf69749acf2 to your computer and use it in GitHub Desktop.
Config files for a new python project
[flake8]
max-line-length = 88
select = C,E,F,W,B,B950
extend-ignore = E203, E501
# run `pre-commit autoupdate` before use this
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.971'
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
- repo: https://github.com/pycqa/flake8
rev: '5.0.4'
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)

Config files for a new Python project

just copy them into root directory of your new project.

Python and packages installation

Linux

git init
curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore -o .gitignore
python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip setuptools wheel poetry
poetry init -n
poetry add -D black flake8 isort mypy pre-commit pytest pytest-cov pytest-mock pytest-randomly
curl https://gist.githubusercontent.com/shiumachi/3372de6ed64a156652c01cf69749acf2/raw/.pre-commit-config.yaml -o .pre-commit-config.yaml
curl https://gist.githubusercontent.com/shiumachi/3372de6ed64a156652c01cf69749acf2/raw/.flake8 -o .flake8
pre-commit autoupdate

Windows PowerShell

git init
curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore -o .gitignore
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -U pip setuptools wheel poetry
poetry init -n
poetry add -D black flake8 isort mypy pre-commit pytest pytest-cov pytest-mock pytest-randomly
curl https://gist.githubusercontent.com/shiumachi/3372de6ed64a156652c01cf69749acf2/raw/.pre-commit-config.yaml -o .pre-commit-config.yaml
curl https://gist.githubusercontent.com/shiumachi/3372de6ed64a156652c01cf69749acf2/raw/.flake8 -o .flake8
pre-commit autoupdate

Usage specific installation

Notebook

poetry add pandas jupyter

CLI

poetry add click
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment