Commit Graph

36 Commits

Author SHA1 Message Date
dependabot[bot] 4e2769a16c
Bump mimalloc from 0.1.38 to 0.1.39 (#7402)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-15 08:46:55 +00:00
Zanie Blue 24b848a4ea
Enable preview mode during benchmarks (#7208)
Split out of https://github.com/astral-sh/ruff/pull/7195 so benchmark
changes from enabling additional rules can be reviewed separately.
2023-09-11 14:09:33 -05:00
Zanie Blue 6566d00295
Update rule selection to respect preview mode (#7195)
## 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>
2023-09-11 12:28:39 -05:00
Micha Reiser 9cb5ce750e
Remove IO based lints from linter benchmark (#7240) 2023-09-08 13:39:50 +02:00
Micha Reiser d9544a2d37
Disable default criterion features (#7241) 2023-09-08 10:03:14 +00:00
Dhruv Manilawala 154fe7bdcc
Add lexer benchmark (#7132) 2023-09-04 13:18:36 +00:00
Micha Reiser edfd888bd6
Add unicode benchmark (#7002) 2023-08-30 09:57:57 +02:00
Micha Reiser ed1b4122d0
Use Codspeed for continous benchmarking (#6896) 2023-08-26 16:34:35 +02:00
Micha Reiser 34b2ae73b4
Extend `BestFitting` with `mode` (#6814) 2023-08-23 17:23:45 +02:00
Micha Reiser ea72d5feba
Refactor `SourceKind` to store file content (#6640) 2023-08-18 13:45:38 +00:00
Charlie Marsh 7f7df852e8
Remove some extraneous newlines in Cargo.toml (#6577) 2023-08-14 23:39:41 +00:00
Micha Reiser 51ae47ad56
Remove lex and parsing from formatter benchmark (#6547) 2023-08-14 10:25:37 +02:00
Dhruv Manilawala 32fa05765a
Use `Jupyter` mode while parsing Notebook files (#5552)
## Summary

Enable using the new `Mode::Jupyter` for the tokenizer/parser to parse
Jupyter line magic tokens.

The individual call to the lexer i.e., `lex_starts_at` done by various
rules should consider the context of the source code (is this content
from a Jupyter Notebook?). Thus, a new field `source_type` (of type
`PySourceType`) is added to `Checker` which is being passed around as an
argument to the relevant functions. This is then used to determine the
`Mode` for the lexer.

## Test Plan

Add new test cases to make sure that the magic statement is considered
while generating the diagnostic and autofix:
* For `I001`, if there's a magic statement in between two import blocks,
they should be sorted independently

fixes: #6090
2023-08-05 00:32:07 +00:00
konsti 1031bb6550
Formatter: Add SourceType to context to enable special formatting for stub files (#6331)
**Summary** This adds the information whether we're in a .py python
source file or in a .pyi stub file to enable people working on #5822 and
related issues.

I'm not completely happy with `Default` for something that depends on
the input.

**Test Plan** None, this is currently unused, i'm leaving this to first
implementation of stub file specific formatting.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2023-08-04 11:52:26 +00:00
Micha Reiser debfca3a11
Remove `Parse` trait (#6235) 2023-08-01 18:35:03 +02:00
Micha Reiser 40f54375cb
Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
Micha Reiser 2cf00fee96
Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
Dhruv Manilawala 7e6b472c5b
Make `lint_only` aware of the source kind (#5876) 2023-07-19 09:29:35 +05:30
Micha Reiser dd0d1afb66
Create `PyFormatOptions`
<!--
Thank you for contributing to Ruff! To help us out with reviewing, please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

This PR adds a new `PyFormatOptions` struct that stores the python formatter options. 
The new options aren't used yet, with the exception of magical trailing commas and the options passed to the printer. 
I'll follow up with more PRs that use the new options (e.g. `QuoteStyle`).

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

`cargo test` I'll follow up with a new PR that adds support for overriding the options in our fixture tests.
2023-06-26 14:02:17 +02:00
konstin f551c9aad2
Unify benchmarking and profiling docs (#5145)
This moves all docs about benchmarking and profiling into
CONTRIBUTING.md by moving the readme of `ruff_benchmark` and adding more
information on profiling.

We need to somehow consolidate that documentation, but i'm not convinced
that this is the best way (i tried subpages in mkdocs, but that didn't
seem good either), so i'm happy to take suggestions.
2023-06-21 09:39:56 +00:00
Charlie Marsh 68b6d30c46
Use consistent `Cargo.toml` metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
Micha Reiser 33434fcb9c
Add Formatter benchmark (#4860) 2023-06-05 21:05:42 +02:00
Zanie Adkins 5ae4667fd5
Upgrade `criterion` to `0.5.1` (#4838) 2023-06-03 21:33:44 +01:00
Micha Reiser 6c1ff6a85f
Upgrade RustPython (#4747) 2023-05-31 08:26:35 +00:00
Julian LaNeve 5756829344
markdownlint: enforce 100 char max length (#4698) 2023-05-28 22:45:56 -04:00
Charlie Marsh 19c4b7bee6
Rename ruff_python_semantic's `Context` struct to `SemanticModel` (#4565) 2023-05-22 02:35:03 +00:00
Charlie Marsh 39fa38cb35
Enable `pycodestyle` rules (#3689) 2023-05-16 20:39:43 +00:00
Charlie Marsh fd34797d0f
Add a specialized `StatementVisitor` (#4349) 2023-05-10 12:42:20 -04:00
Micha Reiser 8969ad5879
Always generate fixes (#4239) 2023-05-10 07:06:14 +00:00
Micha Reiser 280dffb5e1
Add parser benchmark (#3990) 2023-04-17 16:43:59 +02:00
Micha Reiser 7af83460ce
Use unicode-width to determine line-length instead of character count (#3714) 2023-03-24 17:17:05 -04:00
Micha Reiser f59a22b6e5
Remove unused dependencies (#3644) 2023-03-21 11:02:41 +01:00
Zhengbo Wang b08326162b
Doc/CLN: pass pre-commit (#3604) 2023-03-19 19:20:11 +00:00
Micha Reiser a5494b8541
Bitflag based RuleSet (#3606) 2023-03-19 17:09:06 +01:00
Micha Reiser 87fab4a2e1
Benchmark all rules (#3570) 2023-03-17 19:29:39 +01:00
Micha Reiser d5700d7c69
Add Micro Benchmark (#3466) 2023-03-14 08:35:07 +01:00