Commit Graph

91 Commits

Author SHA1 Message Date
Jonathan Plasse a32617911a
Use --filter=blob:none to clone CPython faster (#4156) 2023-04-30 13:39:22 +02:00
Micha Reiser cab65b25da
Replace row/column based `Location` with byte-offsets. (#3931) 2023-04-26 18:11:02 +00:00
konstin 19d8913e32
Use musl in ecosystem docker (#3998)
This prevents errors when the host glibc is newer than the one in the docker container
2023-04-26 05:54:53 +02:00
Charlie Marsh e160a52bfd
Raise percent-format upgrade rule (`UP031`) for hanging modulos (#3953) 2023-04-12 23:59:20 -04:00
Micha Reiser e8aebee3f6
Pretty print `Diagnostic`s in snapshot tests (#3906) 2023-04-11 09:03:00 +00:00
konstin 454c6d9c2f
Extended ecosystem check with scraped data (#3858) 2023-04-06 22:39:48 +00:00
Jonathan Plasse f3f9a9f297
Fix pre-commit CI job exit code (#3833) 2023-03-31 14:47:04 -04:00
Jonathan Plasse fec4fa39a7
Improve `add_rule.py` and `add_plugin.py` scripts (#3725) 2023-03-25 16:05:39 +00:00
Jonathan Plasse 7f3b748401
Fix Ruff pre-commit hook errors (#3706) 2023-03-23 22:52:24 -04:00
Zhengbo Wang b08326162b
Doc/CLN: pass pre-commit (#3604) 2023-03-19 19:20:11 +00:00
Henry Schreiner 4bdb2dd362
ci(check_ecosystem): add PyPa/build (#3569) 2023-03-18 19:09:22 -04:00
Henry Schreiner 53a4743631
ci: fix check_ecosystem (#3602) 2023-03-18 19:03:08 -04:00
Charlie Marsh 16a350c731
Reduce usage of ALL in ecosystem CI (#3590) 2023-03-18 13:13:09 -04:00
Henry Schreiner d9ed0aae69
ci(check_ecosystem): add cibuildwheel (#3567) 2023-03-16 22:34:56 -04:00
Henry Schreiner bbc87b7177
ci(check_ecosystem): add scikit-build-core (#3563) 2023-03-16 19:46:42 -04:00
Xuehai Pan e99e1fae2b
ci: add `python/typeshed` to ecosystem check (#3559) 2023-03-16 14:19:48 -04:00
Calum Young 6c576872d4
List changes for all ecosystem repos (#3461) 2023-03-12 14:30:38 -04:00
Charlie Marsh 7062d1db16
Run ecosystem CI checks without --isolated (#3445) 2023-03-10 19:03:51 -05:00
Samuel Cormier-Iijima cfa2924664
Setup ecosystem CI (#3390)
This PR sets up an "ecosystem" check as an optional part of the CI step for pull requests. The primary piece of this is a new script in `scripts/check_ecosystem.py` which takes two ruff binaries as input and compares their outputs against a corpus of open-source code in parallel. I used ruff's `text` reporting format and stdlib's `difflib` (rather than JSON output and jsondiffs) to avoid adding another dependency. There is a new ecosystem-comment workflow to add a comment to the PR (see [this link](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) which explains why it needs to be done as a new workflow for security reasons).
2023-03-10 17:39:07 -05:00
Charlie Marsh 024caca233
Introduce a `ruff_diagnostics` crate (#3409)
## Summary

This PR moves `Diagnostic`, `DiagnosticKind`, and `Fix` into their own crate, which will enable us to further split up Ruff, since sub-linter crates (which need to implement functions that return `Diagnostic`) can now depend on `ruff_diagnostics` rather than Ruff.
2023-03-09 20:48:57 +00:00
konstin 348a38d261
Deprecate define violation (#3358)
* Add `#[violation]` proc macro as a replacement for `define_violation!`

* Switch all rules to #[violation]
2023-03-06 10:59:06 +00:00
konstin 2168404fc2
flake8-pyi PYI006 bad version info comparison (#3291)
Implement PYI006 "bad version info comparison"

## What it does

Ensures that you only `<` and `>=` for version info comparisons with
`sys.version_info` in `.pyi` files. All other comparisons such as
`<`, `<=` and `==` are banned.

## Why is this bad?

```python
>>> import sys
>>> print(sys.version_info)
sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
>>> print(sys.version_info > (3, 8))
True
>>> print(sys.version_info == (3, 8))
False
>>> print(sys.version_info <= (3, 8))
False
>>> print(sys.version_info in (3, 8))
False
```

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2023-03-01 18:58:57 +01:00
Charlie Marsh 8066607ea3
Add a preliminary tutorial (#3281) 2023-02-28 20:31:27 +00:00
Jonathan Plasse d285f5c90a
Run automatically format code blocks with Black (#3191) 2023-02-27 10:14:05 -05:00
Carlos Gonçalves 1c01b3c934
fix(docs): broken links inside Configuration.md (#3205) 2023-02-24 18:55:33 +00:00
Jonathan Plasse 39b9a1637f
Fix Markdown errors in docs (#3187) 2023-02-24 13:06:48 -05:00
Jonathan Plasse 6e54cd8233
Normalize relative markdown links (#3190) 2023-02-23 16:24:31 -05:00
Jonathan Plasse a688a237d7
Add black to pre-commit (#3192) 2023-02-23 16:24:23 -05:00
Charlie Marsh 74e18b6cff
Split up some docs sections (#3154) 2023-02-22 20:18:10 -05:00
Charlie Marsh b9bfb81e36
Move configuration out of README and into permanent docs (#3150) 2023-02-22 19:25:53 -05:00
Micha Reiser f72ed255e5
chore: Use `LF` on all platforms (#3005)
I worked on #2993 and ran into issues that the formatter tests are failing on Windows because `writeln!` emits `\n` as line terminator on all platforms, but `git` on Windows converted the line endings in the snapshots to `\r\n`.

I then tried to replicate the issue on my Windows machine and was surprised that all linter snapshot tests are failing on my machine. I figured out after some time that it is due to my global git config keeping the input line endings rather than converting to `\r\n`. 

Luckily, I've been made aware of #2033 which introduced an "override" for the `assert_yaml_snapshot` macro that normalizes new lines, by splitting the formatted string using the platform-specific newline character. This is a clever approach and gives nice diffs for multiline fixes but makes assumptions about the setup contributors use and requires special care whenever we use line endings inside of tests. 

I recommend that we remove the special new line handling and use `.gitattributes` to enforce the use of `LF` on all platforms [guide](https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings). This gives us platform agnostic tests without having to worry about line endings in our tests or different git configurations.

## Note

It may be necessary for Windows contributors to run the following command to update the line endings of their files

```bash
git rm --cached -r .
git reset --hard
```
2023-02-20 20:13:37 +00:00
Charlie Marsh c25be31eb1
Fix documentation-link detection in generate_mkdocs.py (#3030) 2023-02-19 12:20:44 +00:00
Charlie Marsh cd1f57b713
Move FAQ into MkDocs (#2984) 2023-02-17 13:15:53 +00:00
Charlie Marsh a0912deb2b
Move editor integrations into MkDocs (#2983) 2023-02-17 13:12:20 +00:00
Martin Fischer d658bfc024 Remove options from README 2023-02-17 07:55:50 -05:00
Martin Fischer 8195873cdf Remove rule tables from README 2023-02-17 07:55:50 -05:00
Charlie Marsh 298498e934
Add an Acknowledgements section to the README (#2907) 2023-02-15 00:25:07 +00:00
Martin Fischer 860993187e Fix link relativization in generate_mkdocs.py 2023-02-14 17:56:21 -05:00
Martin Fischer c314e10e54 many-to-one 6/9: Implement ruff_macros::map_codes 2023-02-14 16:16:12 -05:00
Martin Fischer 65a3461519 many-to-one 4/9: Rename define_rule_mapping! to register_rules!
Currently the define_rule_mapping! macro generates both the Rule enum as
well as the RuleCodePrefix enum and the mapping between the two.  After
this commit series the macro will only generate the Rule enum and the
RuleCodePrefix enum and the mapping will be generated by a new map_codes
proc macro, so we rename the macro now to fit its new purpose.
2023-02-14 16:16:12 -05:00
Martin Fischer 02285c18d1 Remove autogenerated docs/rules/*.md files 2023-02-13 19:34:06 -05:00
Simon Brugman f8ac6d7bf0
fix: script `add_plugin.py` test import (#2807) 2023-02-12 09:58:23 -05:00
Charlie Marsh 271e4fda8c
Create per-rule pages and link from README (#2644) 2023-02-07 18:15:05 -05:00
Charlie Marsh f1cdd108e6
Derive `explanation` method on Rule struct via rustdoc (#2642)
```console
❯ cargo run rule B017
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/ruff rule B017`
no-assert-raises-exception

Code: B017 (flake8-bugbear)

### What it does
Checks for `self.assertRaises(Exception)`.

## Why is this bad?
`assertRaises(Exception)` can lead to your test passing even if the
code being tested is never executed due to a typo.

Either assert for a more specific exception (builtin or custom), use
`assertRaisesRegex` or the context manager form of `assertRaises`.
```
2023-02-07 17:23:29 -05:00
Charlie Marsh 87d0aa5561
Move `python` into its own `ruff_python` crate (#2593) 2023-02-05 17:53:58 -05:00
Micha Reiser cd8be8c0be
refactor: Introduce crates folder (#2088)
This PR introduces a new `crates` directory and moves all "product" crates into that folder. 

Part of #2059.
2023-02-05 16:47:48 -05:00
Jonathan Plasse bdcab87d2f
Add `markdownlint` and dev Ruff to `pre-commit` (#2303) 2023-02-02 16:29:07 -05:00
Jonathan Plasse ec8b827d26
Add known-standard-library for each Python version (#2491) 2023-02-02 16:22:47 -05:00
Jonathan Plasse b232c43824
Fix an error in scripts/add_rule.py (#2497) 2023-02-02 15:58:11 -05:00
Jonathan Plasse e89b4a5de5
Fix hardcoded url in transform_readme.py (#2487) 2023-02-02 13:59:22 -05:00