From e39d297bffe66e19d30ad80d6c32a2e8d8529ed7 Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:44:18 -0700 Subject: [PATCH 1/7] add flake8, black, isort and precommit for autoformatting --- .coveragerc | 17 +++++++++++++++++ .flake8 | 10 ++++++++++ .isort.cfg | 7 +++++++ .pre-commit-config.yaml | 18 ++++++++++++++++++ requirements-dev.txt | 7 +++++++ 5 files changed, 59 insertions(+) create mode 100644 .coveragerc create mode 100644 .flake8 create mode 100644 .isort.cfg create mode 100644 .pre-commit-config.yaml create mode 100644 requirements-dev.txt diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..551da93 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True +source = src + +[report] +exclude_lines = + if self.debug: + pragma: no cover + raise NotImplementedError + raise NotImplemented + if __name__ == .__main__.: +ignore_errors = True +omit = + tests/* + meerkat/datasets/* + meerkat/ml/* + setup.py \ No newline at end of file diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..7829f5b --- /dev/null +++ b/.flake8 @@ -0,0 +1,10 @@ +# This is our code-style check. We currently allow the following exceptions: +# - E731: do not assign a lambda expression, use a def +# - W503: line break before binary operator +# - E741: do not use variables named 'l', 'O', or 'I' +# - E203: whitespace before ':' +[flake8] +count = True +max-line-length = 88 +statistics = True +ignore = E731,W503,E741,E203 \ No newline at end of file diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..8584edd --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,7 @@ +[settings] +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True +line_length = 88 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..494c4de --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/timothycrosley/isort + rev: 5.12.0 + hooks: + - id: isort +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + language_version: python3 + additional_dependencies: ['click==8.0.4'] + exclude: 'scratch/.*' + +- repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + exclude: 'scratch/.*' \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..eb6a631 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,7 @@ +coverage +flake8 +isort +black==23.7.0 # pin black because changes can result in large diffs in PRs +flake8-bugbear +flake8-comprehensions +pre-commit>=2.9.3 \ No newline at end of file From b11928896442893fa293045e6470b00186d0df34 Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:48:41 -0700 Subject: [PATCH 2/7] add Makefile --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..20805d9 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +autoformat: + black src/ checkpoints/ models/ + isort --atomic src/ checkpoints/ models/ + docformatter --in-place --recursive src checkpoints models + +lint: + isort -c src/ checkpoints/ models/ + black src/ checkpoints/ models/ --check + flake8 src/ checkpoints/ models/ + +dev: + pip install -r requirements-dev.txt From b52747de7c08302a27df661010c01172a6a7d26b Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:49:05 -0700 Subject: [PATCH 3/7] add docformatter for dev requirements --- requirements-dev.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index eb6a631..f76009e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,4 +4,5 @@ isort black==23.7.0 # pin black because changes can result in large diffs in PRs flake8-bugbear flake8-comprehensions -pre-commit>=2.9.3 \ No newline at end of file +pre-commit>=2.9.3 +docformatter \ No newline at end of file From abd063196cced88745e47d3defb0c98e54272269 Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:49:29 -0700 Subject: [PATCH 4/7] add ci --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3d67332 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + + Linting: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements-dev.txt + + - name: Lint with isort, black, docformatter, flake8 + run: | + make lint From 3727f5114f858666ea305c4cfc6354a1d2e65046 Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:56:17 -0700 Subject: [PATCH 5/7] increase line length to 100 --- .flake8 | 2 +- .isort.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 7829f5b..43621c3 100644 --- a/.flake8 +++ b/.flake8 @@ -5,6 +5,6 @@ # - E203: whitespace before ':' [flake8] count = True -max-line-length = 88 +max-line-length = 100 statistics = True ignore = E731,W503,E741,E203 \ No newline at end of file diff --git a/.isort.cfg b/.isort.cfg index 8584edd..2923839 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -4,4 +4,4 @@ include_trailing_comma = True force_grid_wrap = 0 use_parentheses = True ensure_newline_before_comments = True -line_length = 88 \ No newline at end of file +line_length = 100 \ No newline at end of file From d1ffadefc2ac5ed2cee920104f0ada4b93d10ac4 Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 11:58:26 -0700 Subject: [PATCH 6/7] delete coverage file --- .coveragerc | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 551da93..0000000 --- a/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True -source = src - -[report] -exclude_lines = - if self.debug: - pragma: no cover - raise NotImplementedError - raise NotImplemented - if __name__ == .__main__.: -ignore_errors = True -omit = - tests/* - meerkat/datasets/* - meerkat/ml/* - setup.py \ No newline at end of file From c7ddc0351e90fc3b75c02500aaab13e043a6726a Mon Sep 17 00:00:00 2001 From: Arjun Desai Date: Tue, 11 Jul 2023 12:01:55 -0700 Subject: [PATCH 7/7] remove requirements.txt from Linting CI - it is not required to run the lint check --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d67332..7c1775f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,6 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt pip install -r requirements-dev.txt - name: Lint with isort, black, docformatter, flake8