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 with ruff and add pre-commit #110

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Black
- name: Install Ruff
run: |
python -m pip install --upgrade pip
pip install black
pip install ruff
- name: Check style
run: |
black --check *.py deepsensor tests
ruff check
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
# Ruff version.
rev: v0.4.2
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ That is, please do not use the [rebase](https://help.github.com/en/articles/abou
command to edit previous commit messages, combine multiple commits into one, or delete or revert
commits that are no longer necessary.

Make sure you're using the developer dependencies.
If you're working locally on the source code, *before* commiting, please run `pip install -r requirements/requirements.dev.txt` to install some useful dependencies just for development.
This includes `pre-commit` and `ruff` which are used to check and format your code style when you run `git commit`, so that you don't have to.
To make this work, just run `pre-commit install`.

You should also run `pytest` and check that your changes don't break any of the existing tests.
If you've made changes to the source code, you may need to add some tests to make sure that they don't get broken in the future.

#### 4. Open a Pull Request

We encourage you to open a pull request as early in your contributing process as possible.
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
no_implicit_reexport = true
no_implicit_reexport = true

[tool.ruff.lint]
select = ["D"]

[tool.ruff.lint.pydocstyle]
convention = "google"
7 changes: 4 additions & 3 deletions requirements/requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Additional requirements for development
coveralls
parameterized
pre-commit
pytest
pytest-cov
parameterized
ruff
tox
tox-gh-actions
coveralls
black
Loading