From 9e96220599fa614f0bdb655b689741464d9948cd Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 26 Nov 2019 00:13:00 +0100 Subject: [PATCH] [AIRFLOW-6066] Added pre-commit checks for accidental debug stmts --- .pre-commit-config.yaml | 7 +++++++ BREEZE.rst | 4 ++-- CONTRIBUTING.rst | 4 ++++ breeze-complete | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2051cd497ee1c..f445531c48fcf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -143,6 +143,7 @@ repos: rev: v2.4.0 hooks: - id: check-merge-conflict + - id: debug-statements - id: detect-private-key - id: end-of-file-fixer - id: mixed-line-ending @@ -190,6 +191,12 @@ repos: files: ^BREEZE.rst$|^breeze$|^breeze-complete$ pass_filenames: false require_serial: true + - id: pydevd + language: pygrep + name: Check for pydevd debug statements accidentally left + entry: "pydevd.*settrace\\(" + pass_filenames: true + files: \.py$ - id: build name: Check if image build is needed entry: ./scripts/ci/pre_commit_ci_build.sh diff --git a/BREEZE.rst b/BREEZE.rst index a6b4818e08b35..603a53c4c2a0f 100644 --- a/BREEZE.rst +++ b/BREEZE.rst @@ -872,7 +872,7 @@ This is the current syntax for `./breeze <./breeze>`_: -S, --static-check Run selected static checks for currently changed files. You should specify static check that you would like to run or 'all' to run all checks. One of - [ all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck]. + [ all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml debug-statements detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck]. You can pass extra arguments including options to to the pre-commit framework as passed after --. For example: @@ -886,7 +886,7 @@ This is the current syntax for `./breeze <./breeze>`_: -F, --static-check-all-files Run selected static checks for all applicable files. You should specify static check that you would like to run or 'all' to run all checks. One of - [ all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck]. + [ all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml debug-statements detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck]. You can pass extra arguments including options to the pre-commit framework as passed after --. For example: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 272e07a10c2ac..afc7ec27fd506 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -428,6 +428,8 @@ image built locally): ----------------------------------- ---------------------------------------------------------------- ------------ ``check-xml`` Checks XML files with xmllint. ----------------------------------- ---------------------------------------------------------------- ------------ +``debug-statements`` Detects accidenatally committed debug statements. +----------------------------------- ---------------------------------------------------------------- ------------ ``detect-private-key`` Detects if private key is added to the repository. ----------------------------------- ---------------------------------------------------------------- ------------ ``doctoc`` Refreshes the table of contents for md files. @@ -448,6 +450,8 @@ image built locally): ----------------------------------- ---------------------------------------------------------------- ------------ ``mypy`` Runs mypy. * ----------------------------------- ---------------------------------------------------------------- ------------ +``pydevd`` Check for accidentally commited pydevd statements. +----------------------------------- ---------------------------------------------------------------- ------------ ``pylint`` Runs pylint. * ----------------------------------- ---------------------------------------------------------------- ------------ ``python-no-log-warn`` Checks if there are no deprecate log warn. diff --git a/breeze-complete b/breeze-complete index 49f7babbe329f..e1fe93a452646 100644 --- a/breeze-complete +++ b/breeze-complete @@ -22,7 +22,7 @@ _BREEZE_ALLOWED_ENVS=" docker kubernetes " _BREEZE_ALLOWED_BACKENDS=" sqlite mysql postgres " _BREEZE_ALLOWED_KUBERNETES_VERSIONS=" v1.13.0 " _BREEZE_ALLOWED_KUBERNETES_MODES=" persistent_mode git_mode " -_BREEZE_ALLOWED_STATIC_CHECKS=" all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck" +_BREEZE_ALLOWED_STATIC_CHECKS=" all all-but-pylint check-hooks-apply check-merge-conflict check-executables-have-shebangs check-xml debug-statements detect-private-key doctoc end-of-file-fixer flake8 forbid-tabs insert-license check-apache-license lint-dockerfile mixed-line-ending mypy pylint shellcheck" _BREEZE_DEFAULT_DOCKERHUB_USER="apache" _BREEZE_DEFAULT_DOCKERHUB_REPO="airflow"