Add ruff as default linting + formatting option#387
Conversation
|
I'm in favor of having the default to be Ruff. It's clear that Ruff is the emerging standard, and they describe themselves as production-ready. There are major projects that are fully using Ruff for linting and formatting. Lots of other major projects (e.g., pip, matplotlib, PyTorch) are using Ruff for linting over flake8, though are still using black for now. |
|
It seems that slight adjustments to the linter rules are necessary to ensure similar behavior as the flake8/black/isort alternative. Most of the rules that flake8 ignores in the If I am not wrong, these additional lines in [tool.ruff.lint]
ignore = [
"E731" # lambda-assignment: Do not assign a lambda expression, use a def
]Update: Additionally, the [tool.ruff.lint]
ignore = ["E731"] # Ignore lambda-assignment
extend-select = ["I"] # Add sorting imports (isort ruleset) to defaults |
|
@szapp thanks for catching the isort fix! I've opted to keep the default selections in ruff for now - I don't know that we're necessarily aiming for exact parity with black, as opposed to just a good starting point for a project. |
…oject.toml config and not command line args
…toml instead of specifying module in m akefile command
Co-authored-by: Jay Qi <2721979+jayqi@users.noreply.github.com>
…ssing options [skip ci]
* Added light compatibility with my own repository * Copied over uv harness * Added uv to ccds.json and ccds-help.json as well as added it to the makefile. Is untested. * Simplified harness and added it to valid environment managers * Minor simplifications to harness and virtualenv + Makefile * Updated uv and requirements.txt to use uv instead of default pip * Made uv install requested python version * Added uv to dev-requirements.txt and removed redundant pip install from makefile * revert gitignore and pyproject.toml changes * add newline at end of venv harness * remove uv pip install pip (unnecessary) * add newline to uv_harness * add lint and format makefile test commands per #387 --------- Co-authored-by: Chris Kucharczyk <chris.kucharczyk@gmail.com>
* upstream/master: (24 commits) Add poetry as an env manager (drivendataorg#460) Support pixi as environment manager (drivendataorg#459) Docs: Add guidelines for contributing and requesting tools (drivendataorg#456) Fix terminal animation generation in docs build (drivendataorg#451) Fix failing pipenv installation on Windows GH actions runners (drivendataorg#453) Fix typo in using-the-template.md (drivendataorg#448) Bump to v2.2.0 [skip ci] Update HISTORY.md [skip ci] Add option for tests (drivendataorg#447) Resolve python version to work with compatible operator (drivendataorg#446) Add pyproject.toml as a dependencies file option (drivendataorg#436) Make PyPI badges links to PyPI (drivendataorg#440) Update to version v2.1.0 (drivendataorg#438) Add back isort configuration that was removed in drivendataorg#387 (drivendataorg#439) add badges to readme and docs homepage (drivendataorg#434) Added support for the uv package and project manager (drivendataorg#408) Add ruff as default linting + formatting option (drivendataorg#387) Add PyTest IDs for better readability and filtering (drivendataorg#409) prepare for 2.0.1 release by bumping version in pyproject.toml and updating change log (drivendataorg#422) Fix pre-prompt ccds version error (drivendataorg#426) ...
Closes #374
Closes #388
This PR adds ruff as the default linting and formatting option for new ccds projects.
Implementation notes
pyproject.tomland removedsetup.cfgif using ruff since it's no longer needed.Discussion
As mentioned, this PR makes ruff the default option. I think there's good arguments for this that mostly boil down to "it's simpler + faster":
setup.cfgfile so everything can live inpyproject.tomlHowever, ruff is still (relatively) new, whereas flake8/black/isort is more mature, and most projects won't notice the speed difference until they get quite large. I could be persuaded that we should introduce ruff without making it the default option.