mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 15:44:22 -05:00
(Supersedes #9152, authored by @LaBatata101) ## Summary This PR replaces the current parser generated from LALRPOP to a hand-written recursive descent parser. It also updates the grammar for [PEP 646](https://peps.python.org/pep-0646/) so that the parser outputs the correct AST. For example, in `data[*x]`, the index expression is now a tuple with a single starred expression instead of just a starred expression. Beyond the performance improvements, the parser is also error resilient and can provide better error messages. The behavior as seen by any downstream tools isn't changed. That is, the linter and formatter can still assume that the parser will _stop_ at the first syntax error. This will be updated in the following months. For more details about the change here, refer to the PR corresponding to the individual commits and the release blog post. ## Test Plan Write _lots_ and _lots_ of tests for both valid and invalid syntax and verify the output. ## Acknowledgements - @MichaReiser for reviewing 100+ parser PRs and continuously providing guidance throughout the project - @LaBatata101 for initiating the transition to a hand-written parser in #9152 - @addisoncrump for implementing the fuzzer which helped [catch](https://github.com/astral-sh/ruff/pull/10903) [a](https://github.com/astral-sh/ruff/pull/10910) [lot](https://github.com/astral-sh/ruff/pull/10966) [of](https://github.com/astral-sh/ruff/pull/10896) [bugs](https://github.com/astral-sh/ruff/pull/10877) --------- Co-authored-by: Victor Hugo Gomes <labatata101@linuxmail.org> Co-authored-by: Micha Reiser <micha@reiser.io>
112 lines
3.0 KiB
TOML
112 lines
3.0 KiB
TOML
[build-system]
|
|
requires = ["maturin>=1.0,<2.0"]
|
|
build-backend = "maturin"
|
|
|
|
[project]
|
|
name = "ruff"
|
|
version = "0.3.7"
|
|
description = "An extremely fast Python linter and code formatter, written in Rust."
|
|
authors = [{ name = "Astral Software Inc.", email = "hey@astral.sh" }]
|
|
readme = "README.md"
|
|
requires-python = ">=3.7"
|
|
license = { file = "LICENSE" }
|
|
keywords = [
|
|
"automation",
|
|
"flake8",
|
|
"pycodestyle",
|
|
"pyflakes",
|
|
"pylint",
|
|
"clippy",
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 5 - Production/Stable",
|
|
"Environment :: Console",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Operating System :: OS Independent",
|
|
"Programming Language :: Python",
|
|
"Programming Language :: Python :: 3.7",
|
|
"Programming Language :: Python :: 3.8",
|
|
"Programming Language :: Python :: 3.9",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3 :: Only",
|
|
"Programming Language :: Rust",
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
"Topic :: Software Development :: Quality Assurance",
|
|
]
|
|
|
|
[project.urls]
|
|
Repository = "https://github.com/astral-sh/ruff"
|
|
Documentation = "https://docs.astral.sh/ruff/"
|
|
Changelog = "https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md"
|
|
|
|
[tool.maturin]
|
|
bindings = "bin"
|
|
manifest-path = "crates/ruff/Cargo.toml"
|
|
module-name = "ruff"
|
|
python-source = "python"
|
|
strip = true
|
|
exclude = [
|
|
"crates/ruff_linter/resources/test/fixtures/**/*",
|
|
"crates/ruff_linter/src/rules/*/snapshots/**/*"
|
|
]
|
|
include = [
|
|
"rust-toolchain.toml"
|
|
]
|
|
|
|
[tool.ruff]
|
|
extend-exclude = [
|
|
"crates/ruff/resources/",
|
|
"crates/ruff_linter/resources/",
|
|
"crates/ruff_python_formatter/resources/",
|
|
"crates/ruff_python_parser/resources/"
|
|
]
|
|
|
|
[tool.ruff.lint]
|
|
ignore = [
|
|
# Conflicts with the formatter
|
|
"COM812", "ISC001"
|
|
]
|
|
|
|
[tool.black]
|
|
force-exclude = '''
|
|
/(
|
|
| crates/ruff_linter/resources
|
|
| crates/ruff_python_formatter/resources
|
|
| crates/ruff_python_parser/resources
|
|
)/
|
|
'''
|
|
|
|
[tool.rooster]
|
|
major_labels = [] # Ruff never uses the major version number
|
|
minor_labels = ["breaking"] # Bump the minor version on breaking changes
|
|
version_tag_prefix = "v"
|
|
|
|
changelog_ignore_labels = ["internal", "ci"]
|
|
|
|
changelog_sections.breaking = "Breaking changes"
|
|
changelog_sections.preview = "Preview features"
|
|
changelog_sections.rule = "Rule changes"
|
|
changelog_sections.formatter = "Formatter"
|
|
changelog_sections.server = "Server"
|
|
changelog_sections.cli = "CLI"
|
|
changelog_sections.configuration = "Configuration"
|
|
changelog_sections.bug = "Bug fixes"
|
|
changelog_sections.documentation = "Documentation"
|
|
changelog_sections.__unknown__ = "Other changes"
|
|
|
|
# We exclude contributors from the CHANGELOG file
|
|
# Generate separately with `rooster contributors` for the GitHub release page
|
|
changelog_contributors = false
|
|
|
|
version_files = [
|
|
"README.md",
|
|
"docs/integrations.md",
|
|
"crates/ruff/Cargo.toml",
|
|
"crates/ruff_linter/Cargo.toml",
|
|
"crates/ruff_shrinking/Cargo.toml",
|
|
"scripts/benchmarks/pyproject.toml",
|
|
]
|