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

Changed pre-commit formatter from Black to Ruff #1149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
repos:
# Using this mirror lets us use mypyc-compiled black, which is 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.4
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down
8 changes: 4 additions & 4 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Once you've forked the code and created a new branch for your work, you can run

After modifying the source code, you will need to do `poetry run interpreter` again.

**Note**: This project uses [`black`](https://black.readthedocs.io/en/stable/index.html) and [`isort`](https://pypi.org/project/isort/) via a [`pre-commit`](https://pre-commit.com/) hook to ensure consistent code style. If you need to bypass it for some reason, you can `git commit` with the `--no-verify` flag.
**Note**: This project uses [`ruff`](https://docs.astral.sh/ruff/) and [`isort`](https://pypi.org/project/isort/) via a [`pre-commit`](https://pre-commit.com/) hook to ensure consistent code style. If you need to bypass it for some reason, you can `git commit` with the `--no-verify` flag.

### Installing New Dependencies

Expand All @@ -57,7 +57,7 @@ Then run `poetry install` again. If this doesn't work, please join our [Discord

## Code Formatting and Linting

Our project uses `black` for code formatting and `isort` for import sorting. To ensure consistency across contributions, please adhere to the following guidelines:
Our project uses `ruff` for code formatting and `isort` for import sorting. To ensure consistency across contributions, please adhere to the following guidelines:

1. **Install Pre-commit Hooks**:

Expand All @@ -75,8 +75,8 @@ Our project uses `black` for code formatting and `isort` for import sorting. To
If you choose not to use the pre-commit hooks, you can manually format your code using:

```bash
black .
isort .
poetry run ruff format .
poetry run isort .
```

# Licensing
Expand Down
89 changes: 29 additions & 60 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ fastapi = "^0.110.0"
aifs = "^0.0.9"
platformdirs = "^4.2.0"
pydantic = "^2.6.4"
ruff = "^0.3.4"

[tool.poetry.extras]
os = ["opencv-python", "pyautogui", "plyer", "pywinctl", "pytesseract", "sentence-transformers", "ipywidgets", "torch", "timm"]
safe = ["semgrep", "yaspin"]

[tool.poetry.group.dev.dependencies]
black = "^23.10.1"
Comment on lines +53 to -59
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move ruff to dev.dependencies

isort = "^5.12.0"
pre-commit = "^3.5.0"
pytest = "^7.4.0"
Expand Down