From 9fa992b3d53730e2f5f9edaf44c8f5facfd406ce Mon Sep 17 00:00:00 2001 From: Erik Jochman <34144949+ejochman@users.noreply.github.com> Date: Wed, 22 Apr 2020 10:13:44 -0700 Subject: [PATCH] Add pre-commit config for formatting and linting Adds a pre-commit config for development that runs several fixers, including YAPF with "google" style and pylint for static analysis. Use of `requirements-dev.txt` appears to be a common pattern for this type of work: https://pypi.org/project/requirements-dev.txt/ --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ src/requirements-dev.txt | 7 +++++++ src/requirements.txt | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 src/requirements-dev.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..da45a317f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_language_version: + python: python3.7 + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-docstring-first + - id: name-tests-test + - id: requirements-txt-fixer + +- repo: https://github.com/pre-commit/mirrors-yapf + rev: v0.29.0 + hooks: + - id: yapf + args: [--style=google, --in-place] + +- repo: https://github.com/PyCQA/pylint + rev: pylint-2.4.4 + hooks: + - id: pylint + args: [--output-format=colorized] diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt new file mode 100644 index 000000000..0ca0002bc --- /dev/null +++ b/src/requirements-dev.txt @@ -0,0 +1,7 @@ +# This file contains all requirements needed for GAM development work + +# Include all build requirements +-r requirements.txt + +# Dev-specific requirements +pre-commit diff --git a/src/requirements.txt b/src/requirements.txt index ff333bf3c..af91a4304 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,10 +1,10 @@ cryptography -python-dateutil distro; sys_platform == 'linux' filelock google-api-python-client>=1.7.10 -google-auth>=1.11.2 google-auth-httplib2 google-auth-oauthlib>=0.4.1 +google-auth>=1.11.2 httplib2>=0.17.0 passlib>=1.7.2; sys_platform == 'win32' +python-dateutil