From e521b281bf4ce1c2ab8652e09782578fb7a2f817 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 14:21:56 +0530 Subject: [PATCH 1/3] Add GitHub action file for pre-commit --- .github/workflows/pre-commit.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000000..dc5bc660833d --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,26 @@ +name: pre-commit + +on: [push, pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade pre-commit + + - name: Run pre-commit + run: pre-commit run --verbose --all-files --show-diff-on-failure From d6a7879ec8619fa3edf427b8e6f7688bf768c32e Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 15:06:28 +0530 Subject: [PATCH 2/3] 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 --- machine_learning/scoring_functions.py | 0 maths/sum_of_arithmetic_series.py | 0 scheduling/round_robin.py | 0 web_programming/instagram_crawler.py | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) 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/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 38e383648150..c81635bd3593 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"] From e8edce48bf82c1eadbe2b5a808cccdc1130affb1 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 30 Sep 2020 16:50:58 +0530 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Christian Clauss --- .github/workflows/pre-commit.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index dc5bc660833d..7002d2d0a21e 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -5,22 +5,11 @@ on: [push, pull_request] jobs: pre-commit: runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8] - steps: - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies + - uses: actions/setup-python@v2 + - name: Install pre-commit run: | python -m pip install --upgrade pip python -m pip install --upgrade pre-commit - - - name: Run pre-commit - run: pre-commit run --verbose --all-files --show-diff-on-failure + - run: pre-commit run --verbose --all-files --show-diff-on-failure