mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
![]() ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Extends work in #7046 (some relevant discussion there) Changes: - All nursery rules are now referred to as preview rules - Documentation for the nursery is updated to describe preview - Adds a "PREVIEW" selector for preview rules - This is primarily to allow `--preview --ignore PREVIEW --extend-select FOO001,BAR200` - Using `--preview` enables preview rules that match selectors Notable decisions: - Preview rules are not selectable by their rule code without enabling preview - Retains the "NURSERY" selector for backwards compatibility - Nursery rules are selectable by their rule code for backwards compatiblity Additional work: - Selection of preview rules without the "--preview" flag should display a warning - Use of deprecated nursery selection behavior should display a warning - Nursery selection should be removed after some time ## Test Plan <!-- How was it tested? --> Manual confirmation (i.e. we don't have an preview rules yet just nursery rules so I added a preview rule for manual testing) New unit tests --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com> |
||
---|---|---|
.. | ||
examples | ||
src | ||
Cargo.toml | ||
pyproject.toml | ||
README.md |
flake8-to-ruff
Convert existing Flake8 configuration files (setup.cfg
, tox.ini
, or .flake8
) for use with
Ruff.
Generates a Ruff-compatible pyproject.toml
section.
Installation and Usage
Installation
Available as flake8-to-ruff
on PyPI:
pip install flake8-to-ruff
Usage
To run flake8-to-ruff
:
flake8-to-ruff path/to/setup.cfg
flake8-to-ruff path/to/tox.ini
flake8-to-ruff path/to/.flake8
flake8-to-ruff
will print the relevant pyproject.toml
sections to standard output, like so:
[tool.ruff]
exclude = [
'.svn',
'CVS',
'.bzr',
'.hg',
'.git',
'__pycache__',
'.tox',
'.idea',
'.mypy_cache',
'.venv',
'node_modules',
'_state_machine.py',
'test_fstring.py',
'bad_coding2.py',
'badsyntax_*.py',
]
select = [
'A',
'E',
'F',
'Q',
]
ignore = []
[tool.ruff.flake8-quotes]
inline-quotes = 'single'
[tool.ruff.pep8-naming]
ignore-names = [
'foo',
'bar',
]
Plugins
flake8-to-ruff
will attempt to infer any activated plugins based on the settings provided in your
configuration file.
For example, if your .flake8
file includes a docstring-convention
property, flake8-to-ruff
will enable the appropriate flake8-docstrings
checks.
Alternatively, you can manually specify plugins on the command-line:
flake8-to-ruff path/to/.flake8 --plugin flake8-builtins --plugin flake8-quotes
Limitations
- Ruff only supports a subset of the Flake configuration options.
flake8-to-ruff
will warn on and ignore unsupported options in the.flake8
file (or equivalent). (Similarly, Ruff has a few configuration options that don't exist in Flake8.) - Ruff will omit any rule codes that are unimplemented or unsupported by Ruff, including rule codes from unsupported plugins. (See the documentation for the complete list of supported plugins.)
License
MIT
Contributing
Contributions are welcome and hugely appreciated. To get started, check out the contributing guidelines.