Closed hamdanal closed 1 year ago
Thanks! Do you mind adding toml
too?
Thanks!
Hi @charliermarsh, does ruff lint toml files? Or did you ask for toml to be added so that ruff has access to the configuration in pyproject.toml
?
I tried this with one of my projects
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.277
hooks:
- id: ruff
types_or: [python, pyi, jupyter, toml]
args: [--fix, --exit-non-zero-on-fix]
And ruff started failing on the poetry.lock
file (which is recognized by pre-commit as a toml file). It thinks this file is a python file and fails with a syntax error.
I am not sure toml should be added here.
Thank you for ruff by the way, it is an amazing tool.
Yeah, Ruff lints pyproject.toml
files (but no other TOML files). Hmm, we may need to revert that for now since we won't have a reliable way to detect TOML files if they're not using the .toml
suffix.
I'll send a PR to revert it and see how can we add pyproject.toml
only.
Can you refresh my memory -- if we revert both of these, what happens if someone adds this to their configuration? Will Ruff still end up linting Jupyter notebooks?
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.277
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --exit-non-zero-on-fix]
We may actually want to revert Jupyter too for now -- it should be considered opt-in, not on-by-default.
Can you refresh my memory -- if we revert both of these, what happens if someone adds this to their configuration? Will Ruff still end up linting Jupyter notebooks?
- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.0.277 hooks: - id: ruff types_or: [python, pyi, jupyter] args: [--fix, --exit-non-zero-on-fix]
Yes, you can override types_or
locally in the user's repository
We may actually want to revert Jupyter too for now -- it should be considered opt-in, not on-by-default.
What about another hook like what black does. This way jupyter stays opt-in but also users don't have to learn about low level pre-commit configuration to make it work with notebooks.
I think my preference for now would be to revert, and add an example to the docs that users can copy-paste to add Jupyter support.
I think my preference for now would be to revert, and add an example to the docs that users can copy-paste to add Jupyter support.
Done in #45
Thank you, sorry for the churn!
Fixes #43
Summary
Add
jupyter
to the file types that ruff pre-commit hook runs onTest Plan
This is what pre-commit uses to identify ".ipynb" files. See https://github.com/pre-commit/identify/blob/dc75a76b7fd7093a7a1d4159d6741884343af694/identify/extensions.py#L100 Also black does this https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml