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

Dev migration from black to ruff #1116

Merged
merged 10 commits into from
Oct 17, 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
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
run: |
pip install pytest
pytest ross --cov=ross
- name: Code Lint
- name: Run Ruff
run: |
black --check ross
ruff check ross
if: success()
- name: Coverage and Deployment
run: codecov
Expand Down
11 changes: 7 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.8
hooks:
- id: black
language_version: python3
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
9 changes: 4 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ These include bug reports, problems on the documentation, feedback, enhancement
You can use the repository [Discussions](https://github.com/petrobras/ross/discussions)
section for questions and further information.

## Code style: Black
## Code style: Ruff

To format our code we use [Black](https://black.readthedocs.io/en/stable/), which is the *"uncompromising Python
code formatter"*. You can configure your development environment to use Black before a commit. More information on how
to set this is given at [Black's documentation](https://black.readthedocs.io/en/stable/integrations/index.html).
To format our code we use [Ruff](https://docs.astral.sh/ruff/), which is the *"An extremely fast Python linter and code formatter"*. You can configure your development environment to use Ruff before a commit. More information on how
to set this is given at [Ruff's documentation](https://docs.astral.sh/ruff/integrations/).

We also recommend using the [pre-commit](https://pre-commit.com/) tool so that black is automatically run when doing a commit.
We also recommend using the [pre-commit](https://docs.astral.sh/ruff/integrations/#pre-commit) tool so that Ruff is automatically run when doing a commit.

(git-configuration)=

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="https://codecov.io/gh/petrobras/ross">
<img src="https://codecov.io/gh/petrobras/ross/branch/main/graph/badge.svg">
</a>
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Code style: 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)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02120/status.svg)](https://doi.org/10.21105/joss.02120)

ROSS is a Python library for rotordynamic analysis, which allows the construction of rotor models and their numerical
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tool.ruff.lint]
# 1. Enable flake8-bugbear (`B`) rules, in addition to the defaults.
select = ["B", "C", "E", "F", "Q", "W"]

# 2. Avoid enforcing line-length violations (`E501`)
ignore = [
"B006","B007", "B017", "B023", "B024", "B027", "B028", "B904",
"C403", "C408", "C416", "C419", "C901",
"E203", "E266", "E501", "E711", "E721", "E722", "E731", "E741",
"F401", "F403", "F405", "F541", "F811", "F841",
"W291", "W293",
]

# 3. Avoid trying to fix flake8-bugbear (`B`) violations.
unfixable = ["B"]

# 4. Ignore `E402` (import violations) in all `__init__.py` files, and in selected subdirectories.
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402"]
"**/{tests}/*" = ["E402"]

[tool.ruff.format]
# 5. Use single quotes in `ruff format`.
quote-style = "single"

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def version(path):
"linkify-it-py",
"numpydoc",
"sphinxcontrib-bibtex>=2.2",
"black",
"isort",
"ruff",
"sphinx-design",
]
}
Expand Down
Loading