From 842609c0ff8feee7b17c8def89331d3363e64e34 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Mon, 20 Jan 2020 14:49:12 -0700 Subject: [PATCH] Added check to make sure that logging is used over print --- .gitlab-ci.yml | 1 + cicd/no_print.sh | 11 +++++++++++ sublime/__main__.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 cicd/no_print.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35f3221..df6e8fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ lint: - pipenv run python setup.py check -mrs - pipenv run flake8 - pipenv run mypy sublime + - ./cicd/no_print.sh test: stage: test diff --git a/cicd/no_print.sh b/cicd/no_print.sh new file mode 100755 index 0000000..b5aa71d --- /dev/null +++ b/cicd/no_print.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +grep -Inre "print(" sublime | while read line; do + if [[ $line =~ "# allowprint" ]]; then + continue + fi + echo "Found instance of print statement:" + echo $line + echo "Use logging instead or add '# allowprint' to the end of the line." + exit 1 +done diff --git a/sublime/__main__.py b/sublime/__main__.py index 2a1b436..f7b3c79 100644 --- a/sublime/__main__.py +++ b/sublime/__main__.py @@ -32,7 +32,7 @@ def main(): args, unknown_args = parser.parse_known_args() if args.version: - print(f'Sublime Music v{sublime.__version__}') + print(f'Sublime Music v{sublime.__version__}') # allowprint return min_log_level = getattr(logging, args.loglevel.upper(), None)