Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Last active September 12, 2022 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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