From acaeb22bbd51f8218cad42df78d99d001f396ba1 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 30 Sep 2020 18:53:34 +0530 Subject: [PATCH] Add GitHub action for pre-commit (#2515) * Add GitHub action file for pre-commit * Fix errors exposed by pre-commit hook: - Remove executable bit from files without shebang. I checked those file and it was not needed. - Fix with black * Apply suggestions from code review Co-authored-by: Christian Clauss Co-authored-by: Christian Clauss --- .github/workflows/pre-commit.yml | 15 +++++++++++++++ machine_learning/scoring_functions.py | 0 maths/sum_of_arithmetic_series.py | 0 scheduling/round_robin.py | 0 web_programming/instagram_crawler.py | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pre-commit.yml mode change 100755 => 100644 machine_learning/scoring_functions.py mode change 100755 => 100644 maths/sum_of_arithmetic_series.py mode change 100755 => 100644 scheduling/round_robin.py diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..7002d2d0a --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,15 @@ +name: pre-commit + +on: [push, pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install pre-commit + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade pre-commit + - run: pre-commit run --verbose --all-files --show-diff-on-failure diff --git a/machine_learning/scoring_functions.py b/machine_learning/scoring_functions.py old mode 100755 new mode 100644 diff --git a/maths/sum_of_arithmetic_series.py b/maths/sum_of_arithmetic_series.py old mode 100755 new mode 100644 diff --git a/scheduling/round_robin.py b/scheduling/round_robin.py old mode 100755 new mode 100644 diff --git a/web_programming/instagram_crawler.py b/web_programming/instagram_crawler.py index 38e383648..c81635bd3 100644 --- a/web_programming/instagram_crawler.py +++ b/web_programming/instagram_crawler.py @@ -15,7 +15,7 @@ def extract_user_profile(script) -> dict: May raise json.decoder.JSONDecodeError """ data = script.contents[0] - info = json.loads(data[data.find('{"config"'): -1]) + info = json.loads(data[data.find('{"config"') : -1]) return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]