-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from andreped:linting
Implemented linting shell scripts and CI workflow
- Loading branch information
Showing
9 changed files
with
153 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Check linting | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-linting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install lint dependencies | ||
run: pip install black==22.3.0 isort==5.10.1 flake8==4.0.1 | ||
|
||
- name: Lint the code | ||
run: sh shell/lint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[metadata] | ||
description-file = README.md | ||
|
||
[isort] | ||
force_single_line=True | ||
known_first_party=vsi2tif | ||
line_length=120 | ||
profile=black | ||
|
||
[flake8] | ||
# imported but unused in __init__.py, that's ok. | ||
per-file-ignores=*__init__.py:F401 | ||
ignore=E203,W503,W605,F632,E266,E731,E712,E741 | ||
max-line-length=120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
isort --sl vsi2tif | ||
black --line-length 120 vsi2tif | ||
flake8 vsi2tif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
isort --check --sl -c vsi2tif | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please run \"sh shell/format.sh\" to format the code." | ||
exit 1 | ||
fi | ||
echo "no issues with isort" | ||
flake8 vsi2tif | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please fix the code style issue." | ||
exit 1 | ||
fi | ||
echo "no issues with flake8" | ||
black --check --line-length 120 vsi2tif | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please run \"sh shell/format.sh\" to format the code." | ||
exit 1 | ||
fi | ||
echo "no issues with black" | ||
echo "linting success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
from time import perf_counter | ||
from functools import wraps | ||
from time import perf_counter | ||
|
||
|
||
def benchmark(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
time_start = perf_counter() | ||
result = func(*args, **kwargs) | ||
time_duration = perf_counter() - time_start | ||
print(f'Processing took {time_duration:.3f} seconds') | ||
print(f"Processing took {time_duration:.3f} seconds") | ||
return result | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters