Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Black, isort and flake8 with Ruff #8

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

11 changes: 2 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@ jobs:
poetry run pip install --upgrade pip
poetry run pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
poetry run pip install lightning
- uses: isort/isort-action@master
with:
sort-paths: "./shimmer"
- uses: psf/black@stable
with:
src: "./shimmer"
- name: Analysing the code with flake8
run: |
poetry run flake8 .
- name: Ruff checks
uses: chartboost/ruff-action@v1
- name: Analysing the code with mypy
run: |
poetry run mypy --install-types --non-interactive .
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.ruff_cache/

docs/api/
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
19 changes: 11 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ With each commit, the github workflow is executed and will check for:

## Code quality workflow
This workflow makes sure that the provided code follows correct code formatting
(using [isort](https://github.com/PyCQA/isort) and [black](https://github.com/psf/black)),
[flake8](https://github.com/PyCQA/flake8), and type issues with [mypy](https://github.com/python/mypy).
and linting using [ruff](https://github.com/astral-sh/ruff),
and type issues with [mypy](https://github.com/python/mypy).

This project is fully typed, so any contribution should provide typing annotations.

Expand All @@ -26,16 +26,19 @@ poetry install --with=dev

Then you can run:
```sh
poetry run isort .
poetry run ruff check . --fix # lint the project (and fix errors if ruff can)
```
```sh
poetry run black .
```
```sh
poetry run flake8 .
poetry run ruff format . # reformat the project
```

> [!NOTE]
> There is a [pre-commit](https://pre-commit.com/) configuration set to lint and
> reformat usinf ruff. Set it up to everything with each commit.

To check type issues with mypy:
```sh
poetry run mypy .
poetry run mypy --install-types .
```

## Tests
Expand Down
Loading
Loading