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

🔧 Switch to ruff instead of black + isort + flake8 #64

Merged
merged 2 commits into from
Oct 27, 2023
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
9 changes: 4 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tests

on:
on:
push:
branches:
- main
Expand Down Expand Up @@ -67,11 +67,10 @@ jobs:
poetry run pip3 uninstall torch torchvision -y
poetry run pip3 install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu

- name: Style checking
- name: Check style & format
run: |
poetry run flake8 torch_uncertainty tests
poetry run isort --check-only torch_uncertainty tests
poetry run black --check torch_uncertainty tests
poetry run ruff check torch_uncertainty tests --no-fix --exit-non-zero-on-fix
poetry run ruff format torch_uncertainty tests --check

- name: Test with pytest and compute coverage
run: |
Expand Down
31 changes: 14 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ repos:
hooks:
- id: end-of-file-fixer
name: end-of-file-fixer
language: system
entry: end-of-file-fixer
language: system
types: [text]
- id: check-toml
name: check-toml
language: system
entry: check-toml
language: system
types: [toml]
- id: check-yaml
name: check-yaml
Expand All @@ -24,22 +24,19 @@ repos:
name: check-added-large-files
entry: check-added-large-files
language: system
- id: black
name: black
language: system
entry: black
types: [python]
- id: ruff-check
name: ruff-check
entry: ruff check
language: python
types_or: [python, pyi]
require_serial: true
args: [--force-exclude, --fix, --exit-non-zero-on-fix]
exclude: ^auto_tutorials_source/
- id: flake8
name: flake8
language: system
entry: flake8
types: [python]
- id: isort
name: isort
language: system
entry: isort
types: [python]
- id: ruff-format
name: ruff-format
entry: ruff format
language: python
types_or: [python, pyi]
exclude: ^auto_tutorials_source/
- id: pytest-check
name: pytest-check
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Optionally, specify `html-noplot` instead of `html` to avoid running the tutoria

### Guidelines

We are using `black` for code formatting, `flake8` for linting, and `isort` for the
imports. The `pre-commit` hooks will ensure that your code is properly formatted
We are using `ruff` for code formatting, linting, and
imports (as a drop-in replacement for `black`, `isort`, and `flake8`). The `pre-commit` hooks will ensure that your code is properly formatted
and linted before committing.

Before submitting a final pull request, that we will review, please try your
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![pypi](https://img.shields.io/pypi/v/torch_uncertainty.svg)](https://pypi.python.org/pypi/torch_uncertainty)
[![tests](https://github.com/ENSTA-U2IS/torch-uncertainty/actions/workflows/run-tests.yml/badge.svg?branch=main&event=push)](https://github.com/ENSTA-U2IS/torch-uncertainty/actions/workflows/run-tests.yml)
[![Docs](https://github.com/ENSTA-U2IS/torch-uncertainty/actions/workflows/build-docs.yml/badge.svg)](https://torch-uncertainty.github.io/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Code Coverage](https://codecov.io/github/ENSTA-U2IS/torch-uncertainty/coverage.svg?branch=master)](https://codecov.io/gh/ENSTA-U2IS/torch-uncertainty)
[![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)](https://github.com/psf/black)
[![Discord Badge](https://dcbadge.vercel.app/api/server/HMCawt5MJu?compact=true&style=flat)](https://discord.gg/HMCawt5MJu)
</div>

Expand Down
4 changes: 2 additions & 2 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Optionally, specify :bash:`html-noplot` instead of :bash:`html` to avoid running
Guidelines
^^^^^^^^^^

We are using black for code formatting, flake8 for linting, and isort for the
imports. The pre-commit hooks will ensure that your code is properly formatted
We are using ruff for code formatting, linting, and
imports (as a drop-in replacement for black, isort, and flake8). The pre-commit hooks will ensure that your code is properly formatted
and linted before committing.

Before submitting a final pull request, that we will review, please try your
Expand Down
172 changes: 27 additions & 145 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading