empa-scientific-it / python-tutorial

Material for a Jupyter-based Python tutorial
MIT License
31 stars 9 forks source link

Add Ruff as a pre-commit hook? #255

Open edoardob90 opened 2 days ago

edoardob90 commented 2 days ago

A suggestion: why not replacing flake8 and others pre-commit hooks (like isort, pyupgrade) with Ruff, which can do almost everything? Including a slightly better formatting than Black.

Resources:

edoardob90 commented 2 days ago

Just an example of the formatting where I think Ruff delivers a better final result:

Black

explain_button.on_click(
    lambda b, ipytest_result=self.ipytest_result, exc=result.exception, out=explanation_output, test_name=test_name: self.on_click_explain(
        ipytest_result, exc, out, test_name
    )
)

Ruff

explain_button.on_click(
    lambda b,
    ipytest_result=self.ipytest_result,
    exc=result.exception,
    out=explanation_output,
    test_name=test_name: self.on_click_explain(
        ipytest_result, exc, out, test_name
    )
)