Skip to content

Commit

Permalink
Update pre-commit hooks (#964)
Browse files Browse the repository at this point in the history
* Updates pre-commit hooks to align with scverse packages.

* Updates and fixes docstrings to pass pre-commit hooks. If the fix is not permanent, a corresponding TODO comment is added.

* Updates spacing if needed.

* Update exception handling to not rely on bare excepts.

* Update arguments to non-mutable objects.

* Avoid redundant list comprehension.

* Update for loops to remove redundant operations and variables.
  • Loading branch information
WeilerP committed Dec 8, 2022
1 parent 738e45e commit 60e8e16
Show file tree
Hide file tree
Showing 68 changed files with 1,329 additions and 589 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 88

[*.py]
indent_size = 4
indent_style = space
indent_size = 4
72 changes: 62 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
[flake8]
max-line-length = 88
filename = *.py
exclude =
.git,
__pycache__,
docs/*
# F403: unable to detect undefined names
# F405: undefined, or defined from star imports
# W503: Linebreak before binary operator
ignore = F403, F405, W503
max-line-length = 119
ignore =
# Unnecessary dict call - rewrite as a literal.
C408
# line break before a binary operator -> black does not adhere to PEP8
W503
# line break occured after a binary operator -> black does not adhere to PEP8
W504
# line too long -> we accept long comment lines; black gets rid of long code lines
E501
# whitespace before : -> black does not adhere to PEP8
E203
# missing whitespace after ,', ';', or ':' -> black does not adhere to PEP8
E231
# continuation line over-indented for hanging indent -> black does not adhere to PEP8
E126
# too many leading '#' for block comment -> this is fine for indicating sections
E262
# Do not assign a lambda expression, use a def -> lambda expression assignments are convenient
E731
# allow I, O, l as variable names -> I is the identity matrix
E741
# Missing docstring in public package
D104
# Missing docstring in public module
D100
# Missing docstring in __init__
D107
# Missing docstring in magic method
D105
# format string does contain unindexed parameters
P101
# first line should end with a period [Bug: doesn't work with single-line docstrings]
D400
# First line should be in imperative mood; try rephrasing
D401
exclude = .git,__pycache__,build,docs/_build,dist,scvi/__init__.py
per-file-ignores =
tests/*: D
*/__init__.py: F401
extend-immutable-calls =
# Add functions returning immutable values here to avoid B008
pathlib.Path
Path
rst-roles =
class,
func,
ref,
meth,
doc,
py:class,
method,
attr,
cite:p,
cite:t,
rst-directives =
envvar,
exception,
rst-substitutions =
version,
extend-ignore =
RST307,RST210,RST201,RST203,RST301
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
name: Bug report
about: scVelo doesn’t do what it should? Please help us fix it!
title: ''
title: ""
labels: bug
assignees: ''
assignees: ""
---

<!-- Description of the bug -->
...

...

<!-- Reproducible example -->

```python
# paste your code here, if applicable
```


<!-- Error Output -->
<details>

Expand All @@ -24,13 +24,14 @@ assignees: ''
```pytb
# paste the error output here, if applicable
```
</details>

</details>

<!-- Versions -->
<details> <summary> Versions </summary>

```pytb
# paste the ouput of scv.logging.print_versions() here
```

</details>
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/enhancement_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Enhancement request
about: Anything you’d like to see in scVelo?
title: ''
title: ""
labels: enhancement
assignees: ''
assignees: ""
---

<!-- What kind of feature would you like to request? -->

10 changes: 7 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
## Changes

<!-- Please remove section if this PR does change an existing feature -->

* ...
- ...

## Bug fixes

<!-- Please give section if this PR does not fix any bugs -->

* ...
- ...

## New

<!-- Please give section if this PR does not implement a new feature -->

* ...
- ...

## Related issues

<!-- Please list related issues. If none exist, open one and reference it here. -->

Closes #
140 changes: 70 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
name: CI

on:
push:
branches: [master, develop, 'release/**']
pull_request:
branches: [master, develop, 'release/**']
push:
branches: [master, develop, "release/**"]
pull_request:
branches: [master, develop, "release/**"]

jobs:
# Skip CI if commit message contains `[ci skip]` in the subject
init:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: ci-skip-step
uses: mstachniuk/ci-skip@master
# Skip CI if commit message contains `[ci skip]` in the subject
init:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: ci-skip-step
uses: mstachniuk/ci-skip@master

# Check if pre-commit hooks pass and if README.rst can be converted to HTML
linting:
needs: init
if: ${{ needs.init.outputs.skip == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit docutils
- name: Check pre-commit compatibility
run: pre-commit run --all-files --show-diff-on-failure
- name: Run rst2html.py
run: rst2html.py --halt=2 README.rst >/dev/null
# Check if pre-commit hooks pass and if README.rst can be converted to HTML
linting:
needs: init
if: ${{ needs.init.outputs.skip == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit docutils
- name: Check pre-commit compatibility
run: pre-commit run --all-files --show-diff-on-failure
- name: Run rst2html.py
run: rst2html.py --halt=2 README.rst >/dev/null

# Run unit tests
test:
needs: linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9]
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: pip install -e '.[dev]'
- name: Unit tests
timeout-minutes: 60
run: python -m pytest --durations=25 --ignore=tests/datasets/test_datasets.py --hypothesis-profile=ci --cov=scvelo -vv
# Run unit tests
test:
needs: linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9]
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: pip install -e '.[dev]'
- name: Unit tests
timeout-minutes: 60
run: python -m pytest --durations=25 --ignore=tests/datasets/test_datasets.py --hypothesis-profile=ci --cov=scvelo -vv

test-dataset-downloads:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install -e .
pip install hypothesis pytest pytest-cov
- name: Test dataset downloads
timeout-minutes: 60
run: python -m pytest tests/datasets/test_datasets.py -vv
test-dataset-downloads:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install -e .
pip install hypothesis pytest pytest-cov
- name: Test dataset downloads
timeout-minutes: 60
run: python -m pytest tests/datasets/test_datasets.py -vv

0 comments on commit 60e8e16

Please sign in to comment.