Charlie Marsh
6e97c9438a
Merge branch 'main' into github-2923
2023-03-02 15:55:55 -05:00
Charlie Marsh
187104e396
Flag out-of-date docs on CI ( #3309 )
2023-03-02 15:55:39 -05:00
Charlie Marsh
ea86edf12e
Rename, etc.
2023-03-02 15:50:10 -05:00
Martin Kagamino Lehoux
2558384817
Replace tuples with type union in isinstance or issubclass calls ( #2923 )
2023-03-02 21:07:00 +01:00
Charlie Marsh
3ed539d50e
Add a CLI flag to force-ignore noqa directives ( #3296 )
2023-03-01 22:28:13 -05:00
Charlie Marsh
4a70a4c323
Ignore unused imports in ModuleNotFoundError blocks ( #3288 )
2023-03-01 18:08:37 -05:00
Charlie Marsh
310f13c7db
Redirect RUF004 to B026 ( #3293 )
2023-03-01 13:00:02 -05: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
a032b66c2e
Avoid PEP 585 rewrites when builtins are shadowed ( #3286 )
2023-02-28 23:25:42 +00:00
Charlie Marsh
af5f7dbd83
Avoid pluralization for single --add-noqa result ( #3282 )
2023-02-28 15:41:18 -05:00
Charlie Marsh
8066607ea3
Add a preliminary tutorial ( #3281 )
2023-02-28 20:31:27 +00:00
Andy Freeland
0ed9fccce9
Upgrade RustPython ( #3277 )
...
Fixes #3207 .
2023-02-28 12:21:28 -05:00
Carlos Gonçalves
074a343a63
feat(E251,E252): add rules ( #3274 )
2023-02-28 12:02:36 -05:00
Charlie Marsh
c7e09b54b0
Use expression span for yoda-conditions fixes ( #3276 )
2023-02-28 16:59:02 +00:00
Charlie Marsh
67d1f74587
Avoid raising TRY200 violations within new scopes ( #3275 )
2023-02-28 11:56:29 -05:00
Matthew Lloyd
1c79dff3bd
Improve the message for PLW2901: use "outer" and "inner" judiciously ( #3263 )
2023-02-28 16:33:01 +00:00
Charlie Marsh
f5f09b489b
Introduce dedicated CST tokens for other operator kinds ( #3267 )
2023-02-27 23:54:57 -05:00
Charlie Marsh
061495a9eb
Make BoolOp its own located token ( #3265 )
2023-02-28 03:43:28 +00:00
Charlie Marsh
470e1c1754
Preserve comments on non-defaulted arguments ( #3264 )
2023-02-27 23:41:40 +00:00
Charlie Marsh
16be691712
Enable more non-panicking formatter tests ( #3262 )
2023-02-27 18:21:53 -05:00
Charlie Marsh
270015865b
Don't flag keyword-based logging format strings ( #3261 )
2023-02-27 23:11:13 +00:00
Charlie Marsh
ccfa9d5b20
Deduplicate SIM116 errors ( #3260 )
2023-02-27 18:08:45 -05:00
Charlie Marsh
2261e194a0
Create dedicated Body nodes in the formatter CST ( #3223 )
2023-02-27 22:55:05 +00:00
Ville Skyttä
cd6413ca09
Match non-lowercase with S105 again ( #3258 )
2023-02-27 16:38:23 -05:00
Charlie Marsh
c65585e14a
Use identifier_range for a few more rules ( #3254 )
2023-02-27 18:23:33 +00:00
Charlie Marsh
d2a6ed7be6
Upgrade RustPython ( #3252 )
2023-02-27 18:21:06 +00:00
Charlie Marsh
16e2dae0c2
Handle empty NamedTuple and TypedDict conversions ( #3251 )
2023-02-27 11:18:34 -05:00
Carlos Gonçalves
e8ba9c9e21
feat(W191): add indentation_contains_tabs ( #3249 )
2023-02-27 10:36:03 -05:00
Jonathan Plasse
d285f5c90a
Run automatically format code blocks with Black ( #3191 )
2023-02-27 10:14:05 -05:00
Charlie Marsh
386ca7c9a1
Bump version to 0.0.253 ( #3245 )
2023-02-26 23:10:04 -05:00
Charlie Marsh
40c5abf16e
Avoid flagging Pylint logging rules with starred arguments ( #3244 )
2023-02-26 22:58:24 -05:00
Matthew Lloyd
7e7aec7d74
Expand the range of the COM812 autofix to include the preceding token ( #3241 )
...
This prevents the UP034 autofix simultaneously stripping the
parentheses from generators in the same linter pass, which causes
a SyntaxError.
Closes #3234 .
With this fix:
```python
$ cat test.py
the_first_one = next(
(i for i in range(10) if i // 2 == 0)
)
$ cargo run --bin ruff check test.py --no-cache --select UP034,COM812 --fix
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/ruff check test.py --no-cache --select UP034,COM812 --fix`
Found 1 error (1 fixed, 0 remaining).
$ cat test.py
the_first_one = next(
i for i in range(10) if i // 2 == 0
)
```
* Use format
---------
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-02-27 03:47:07 +00:00
Ivan Gozali
4b5538f74e
[pylint] W0603: global-statement ( #3227 )
...
Implements pylint rule [W0603: global-statement](https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/global-statement.html ).
Currently checks for global statement usage in a few StmtKinds (as tested in the `pylint` `global-statement` test case [here](b70d2abd7f/tests/functional/g/globals.py )):
* Assign
* AugAssign
* ClassDef
* FunctionDef | AsyncFunctionDef
* Import
* ImportFrom
* Delete
2023-02-26 23:40:24 +00:00
Charlie Marsh
36d134fd41
Bump lint rule count to 500+ ( #3240 )
2023-02-26 18:10:09 -05:00
Chris Chan
0b7d6b9097
Implement pylint's else-if-used rule (PLR5501) ( #3231 )
...
Attempt to implement else-if-used
https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/else-if-used.html
Issue #970
2023-02-26 22:42:33 +00:00
Nick Pope
994e2e0903
Rename some flake8-simplify rules ( #2915 )
...
Renames the following rules that stood out to me at a glance as needing better names:
- `or-true` to `expr-or-true`
- `and-false` to `expr-and-false`
- `a-or-not-a` to `expr-or-not-expr`
- `a-and-not-a` to `expr-and-not-expr`
Related to #2902 .
2023-02-26 22:35:15 +00:00
Luc Khai Hai
bc79f540e4
[flake8-django] DJ003, DJ006, DJ007 ( #3236 )
...
Implements [flake8-django](https://github.com/rocioar/flake8-django ) rules:
- DJ03
- DJ06
- DJ07
2023-02-26 22:29:42 +00:00
Steve Dignam
3a78b59314
[flake8-pyi]: PYI011, PYI014 ( #3238 )
...
Implement PYI011 and PYI014 with the latest changes:
https://github.com/PyCQA/flake8-pyi/pull/326
https://github.com/PyCQA/flake8-pyi/issues/316
rel: https://github.com/charliermarsh/ruff/issues/848
rel: 4212bec43d/pyi.py (L718)
2023-02-26 22:11:58 +00:00
Edgar R. M
5f83851329
[pydocstyle]: Implement ignore-decorators ( #3229 )
2023-02-26 21:40:01 +00:00
Carlos Gonçalves
484ce7b8fc
feat(E275): add Missing whitespace after keyword ( #3225 )
2023-02-26 21:36:05 +00:00
Charlie Marsh
1c75071136
Implement basic rendering of remaining AST nodes ( #3233 )
2023-02-26 05:05:56 +00:00
Charlie Marsh
51bca19c1d
Add builders for common comment rendering ( #3232 )
2023-02-26 04:16:24 +00:00
Steve Dignam
a8a312e862
[flake8-pyi]: PYI009, PYI010, PYI021 ( #3230 )
...
PYI009 and PYI010 are very similar, always use `...` in function and class bodies in stubs.
PYI021 bans doc strings in stubs.
I think all of these rules should be relatively straightforward to implement auto fixes for but can do that later once we get all the other rules added.
rel: https://github.com/charliermarsh/ruff/issues/848
2023-02-25 22:29:04 -05:00
Ran Benita
33c31cda27
Add noqa_row to diagnostics JSON format ( #3228 )
...
In ruff-lsp (https://github.com/charliermarsh/ruff-lsp/pull/76 ) we want to add a "Disable \<rule\> for this line" quickfix. However, finding the correct line into which the `noqa` comment should be inserted is non-trivial (multi-line strings for example).
Ruff already has this info, so expose it in the JSON output for use by ruff-lsp.
2023-02-25 18:13:16 -05:00
Edgar R. M
cd9fbeb560
[bandit]: Do not treat "passed" as "password" for S105/S106/S107 ( #3222 )
2023-02-25 15:32:53 -05:00
Jeong YunWon
84e96cdcd9
More enum work ( #3212 )
2023-02-25 11:40:16 -05:00
Charlie Marsh
248590224a
Avoid flagging logging-too-few-args with no arguments ( #3220 )
2023-02-24 21:57:49 -05:00
Charlie Marsh
bbc55cdb04
Allow ruff.toml file to be dot-prefixed (as .ruff.toml) ( #3221 )
2023-02-24 23:14:26 +00:00
Charlie Marsh
2792439eac
Add TextMate to editor-integrations.md ( #3219 )
2023-02-24 22:57:33 +00:00
Charlie Marsh
0694aee1b6
Avoid EXE001 and EXE002 errors from stdin input ( #3218 )
2023-02-24 22:55:32 +00:00
Charlie Marsh
a17b5c134a
Avoid rewriting any PEP 604 runtime annotations ( #3217 )
...
Following `pyupgrade`, we'll just _never_ touch these.
Closes #2981 .
Closes #3215 .
2023-02-24 22:39:58 +00:00
Charlie Marsh
42f61535b5
Normalize treatment of aliased and unaliased imports ( #3216 )
2023-02-24 22:11:03 +00: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
2c692e3acf
Remove --all from cargo fmt|test ( #3208 )
2023-02-24 12:52:59 -05:00
monosans
24add5f56c
Avoid boolean-trap rules for ConfigParser get() methods ( #3209 )
2023-02-24 12:52:33 -05:00
Samuel Cormier-Iijima
0b7736ad79
[flake8-tidy-imports] fix autofix for relative imports ( #3197 )
2023-02-23 23:40:28 -05:00
Charlie Marsh
eef85067c8
Exclude globsets for --show-settings ( #3201 )
2023-02-24 04:23:00 +00:00
Jeong YunWon
da98fab4ae
Adapt is-macro for a few enums ( #3182 )
2023-02-24 04:06:56 +00:00
Charlie Marsh
0f37a98d91
Use then-some pattern for sometimes-fixable rules ( #3199 )
2023-02-24 03:57:14 +00:00
Charlie Marsh
f38624824d
Avoid autofixing some PT violations when comments are present ( #3198 )
2023-02-24 03:48:41 +00:00
Charlie Marsh
159422071e
Handle end-of-line comments on excepthandler and alias ( #3196 )
2023-02-23 22:35:39 -05:00
Charlie Marsh
6eaacf96be
Introduce a new CST element for slice segments ( #3195 )
2023-02-24 00:49:41 +00:00
Charlie Marsh
eb15371453
Make Locator available in AST-to-CST conversion pass ( #3194 )
2023-02-23 19:43:03 -05:00
Matt Nawara
198b301baf
[pycodestyle] trailing-whitespace, blank-line-contains-whitespace (W291, W293) ( #3122 )
2023-02-23 19:04:45 -05:00
Jeong YunWon
c8c575dd43
Adapt BoolLike to flags ( #3175 )
2023-02-23 16:31:46 -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
bda2a0007a
Parenthesize numbers during attribute accesses ( #3189 )
2023-02-23 14:57:23 -05:00
Charlie Marsh
32d165b7ad
Implement complex literal formatting ( #3186 )
2023-02-23 19:09:33 +00:00
Charlie Marsh
ac79bf4ee9
Implement float literal formatting ( #3184 )
2023-02-23 14:02:23 -05:00
Charlie Marsh
376eab3a53
Implement integer literal formatting ( #3183 )
2023-02-23 18:31:56 +00:00
Charlie Marsh
08be7bd285
Add a TODO to string_literal ( #3181 )
2023-02-23 12:46:20 -05:00
Charlie Marsh
f5241451d8
Use writeln with --show-settings ( #3180 )
2023-02-23 17:23:31 +00:00
Charlie Marsh
c9fe0708cb
Run cargo update ( #3179 )
2023-02-23 12:09:36 -05:00
Charlie Marsh
09f8c487ea
Update RustPython to support *tuple annotations ( #3178 )
2023-02-23 16:58:38 +00:00
Charlie Marsh
1e7233a8eb
Add support for reformatting byte strings ( #3176 )
2023-02-23 16:50:24 +00:00
Charlie Marsh
f967f344fc
Add support for basic Constant::Str formatting ( #3173 )
...
This PR enables us to apply the proper quotation marks, including support for escapes. There are some significant TODOs, especially around implicit concatenations like:
```py
(
"abc"
"def"
)
```
Which are represented as a single AST node, which requires us to tokenize _within_ the formatter to identify all the individual string parts.
2023-02-23 16:23:10 +00:00
Charlie Marsh
095f005bf4
Move RustPython vendored and helper code into its own crate ( #3171 )
2023-02-23 14:14:16 +00:00
Charlie Marsh
0f04aa2a5f
Bind star patterns in match statements ( #3169 )
2023-02-23 12:39:03 +00:00
Jonathan Plasse
ad7ba77fff
Fix ExceptionGroup F821 false positive ( #3167 )
2023-02-23 12:36:11 +00:00
Jeong YunWon
77d43795f8
Replace Autofix::is_enabled to result_like::BoolLike ( #3165 )
2023-02-23 07:29:13 -05:00
Jeong YunWon
4357f2be0f
Add Autofix::is_enabled() to remove repeative patterns ( #3159 )
2023-02-22 23:52:07 -05:00
Charlie Marsh
e5c1f95545
Check-in updated snapshot ( #3161 )
2023-02-23 03:42:27 +00:00
Charlie Marsh
227ff62a4e
Don't touch tuple brackets after in ( #3160 )
2023-02-23 03:10:24 +00:00
Charlie Marsh
d8e4902516
Un-modify tupleassign and function2 tests ( #3158 )
...
I manually changed these in #3080 and #3083 to get the tests passing (with notes around the deviations) -- but that's no longer necessary, now that we have proper testing that takes deviations into account.
2023-02-23 02:37:25 +00:00
Matthew Lloyd
e66739884f
Add note about prioritizing naming convention over preservation ( #3157 )
2023-02-23 02:32:46 +00:00
Charlie Marsh
5fd827545b
Add a trailing newline to all .py.expect files ( #3156 )
...
This just re-formats all the `.py.expect` files with Black, both to add a trailing newline and be doubly-certain that they're correctly formatted.
I also ensured that we add a hard line break after each statement, and that we avoid including an extra newline in the generated Markdown (since the code should contain the exact expected newlines).
2023-02-23 02:29:27 +00:00
Matthew Lloyd
c1ddcb8a60
[flake8-pie] Unnecessary list comprehension, with autofix (PIE802) ( #3149 )
2023-02-22 20:58:45 -05:00
Charlie Marsh
48a317d5f6
Change via to using ( #3155 )
2023-02-23 01:47:15 +00:00
Charlie Marsh
74e18b6cff
Split up some docs sections ( #3154 )
2023-02-22 20:18:10 -05:00
Charlie Marsh
21d02cd51f
Omit non-.py[i] files from module naming rules ( #3153 )
2023-02-23 00:38:46 +00:00
Charlie Marsh
049e77b939
Follow-up with some small doc changes ( #3152 )
2023-02-23 00:35:22 +00:00
Charlie Marsh
b9bfb81e36
Move configuration out of README and into permanent docs ( #3150 )
2023-02-22 19:25:53 -05:00
Charlie Marsh
2d4fae45d9
Avoid flagging unfixable TypedDict and NamedTuple definitions ( #3148 )
2023-02-22 23:23:25 +00:00
Charlie Marsh
726adb7efc
Avoid suggesting 'is' for constant literals ( #3146 )
2023-02-22 22:37:22 +00:00
Charlie Marsh
dbdfdeb0e1
Add pre-commit note to docs ( #3145 )
2023-02-22 17:22:47 -05:00
Charlie Marsh
1c41789c2a
Bump version to 0.0.252 ( #3142 )
2023-02-22 14:50:14 -05:00
Charlie Marsh
2f9de335db
Upgrade RustPython to match new flattened exports ( #3141 )
2023-02-22 19:36:13 +00:00
Ran Benita
ba61bb6a6c
Fix isort no-lines-before preceded by an empty section ( #3139 )
...
Fix isort no-lines-before preceded by an empty section
Fix #3138 .
2023-02-22 14:35:53 -05:00
Charlie Marsh
17ab71ff75
Include match in nested block check ( #3137 )
2023-02-22 14:32:08 -05:00
Charlie Marsh
4ad4e3e091
Avoid useless-else-on-loop for break within match ( #3136 )
2023-02-22 19:12:44 +00:00
Florian Best
6ced5122e4
refactor(use-from-import): build fixed variant via AST ( #3132 )
2023-02-22 13:17:37 -05:00
Marijn Valk
7d55b417f7
add delta-rs to list of users ( #3133 )
2023-02-22 13:07:58 -05:00
Charlie Marsh
f0e0efc46f
Upgrade RustPython to handle trailing commas in map patterns ( #3130 )
2023-02-22 11:17:13 -05:00
Charlie Marsh
1efa2e07ad
Avoid match statement misidentification in token rules ( #3129 )
2023-02-22 15:44:45 +00:00
Charlie Marsh
df3932f750
Use file-specific quote for C408 ( #3128 )
2023-02-22 15:26:46 +00:00
Rupert Tombs
817d0b4902
Fix =/== error in ManualDictLookup ( #3117 )
2023-02-22 15:14:30 +00:00
Micha Reiser
ffd8e958fc
chore: Upgrade Rust to 1.67.0 ( #3125 )
2023-02-22 10:03:17 -05:00
Micha Reiser
ed33b75bad
test(ruff_python_formatter): Run all Black tests ( #2993 )
...
This PR changes the testing infrastructure to run all black tests and:
* Pass if Ruff and Black generate the same formatting
* Fail and write a markdown snapshot that shows the input code, the differences between Black and Ruff, Ruffs output, and Blacks output
This is achieved by introducing a new `fixture` macro (open to better name suggestions) that "duplicates" the attributed test for every file that matches the specified glob pattern. Creating a new test for each file over having a test that iterates over all files has the advantage that you can run a single test, and that test failures indicate which case is failing.
The `fixture` macro also makes it straightforward to e.g. setup our own spec tests that test very specific formatting by creating a new folder and use insta to assert the formatted output.
2023-02-22 09:25:06 -05:00
Micha Reiser
262e768fd3
refactor(ruff): Implement doc_lines_from_tokens as iterator ( #3124 )
...
This is a nit refactor... It implements the extraction of document lines as an iterator instead of a Vector to avoid the extra allocation.
2023-02-22 09:22:06 -05:00
Ran Benita
bc3a9ce003
Mark typing.assert_never as no return ( #3121 )
...
This function always raises, so RET503 shouldn't trigger for it.
2023-02-22 09:15:39 -05:00
Charlie Marsh
48005d87f8
Add missing backticks from rustdoc ( #3112 )
2023-02-22 05:03:06 +00:00
Charlie Marsh
e37e9c2ca3
Skip EXE001 and EXE002 rules on Windows ( #3111 )
2023-02-21 23:39:56 -05:00
Matthieu Devlin
8fde63b323
[pylint] Implement E1205 and E106 ( #3084 )
2023-02-21 22:53:11 -05:00
Matthew Lloyd
97338e4cd6
[pylint] redefined-loop-name (W2901) ( #3022 )
...
Slightly broadens W2901 to cover `with` statements too.
Closes #2972 .
2023-02-22 03:23:47 +00:00
Charlie Marsh
9645790a8b
Support shell expansion for --config argument ( #3107 )
2023-02-21 23:33:41 +00:00
Charlie Marsh
18800c6884
Include file permissions in cache key ( #3104 )
2023-02-21 18:20:06 -05:00
Charlie Marsh
fd638a2e54
Bump version to 0.0.251 ( #3105 )
2023-02-21 18:13:59 -05:00
Charlie Marsh
fa1459d56e
Avoid prefer-list-builtin for lambdas with *args or **kwargs ( #3102 )
2023-02-21 17:44:37 -05:00
Charlie Marsh
d93c5811ea
Create bindings for MatchAs patterns ( #3098 )
2023-02-21 22:04:09 +00:00
Charlie Marsh
06e426f509
Bump version to 0.0.250 ( #3095 )
2023-02-21 15:20:46 -05:00
Carlos Gonçalves
6eb014b3b2
feat(B032): add b032 flake8_bugbear ( #3085 )
2023-02-21 19:53:29 +00:00
Charlie Marsh
d9fd78d907
Ignore setters in flake8-boolean-trap ( #3092 )
2023-02-21 19:31:00 +00:00
Charlie Marsh
37df07d2e0
Re-add compatibility to README ( #3091 )
2023-02-21 18:57:47 +00:00
Charlie Marsh
d5c65b5f1b
Add support for structural pattern matching ( #3047 )
2023-02-21 18:52:10 +00:00
Charlie Marsh
cdc4e86158
Add support for TryStar ( #3089 )
2023-02-21 13:42:20 -05:00
Charlie Marsh
50ec6d3b0f
Use LibCST to fix chained assertions ( #3087 )
2023-02-21 13:10:31 -05:00
Charlie Marsh
a6eb60cdd5
Enable function2 test ( #3083 )
2023-02-21 04:37:50 +00:00
Charlie Marsh
90c04b9cff
Enable tupleassign test ( #3080 )
2023-02-21 00:42:23 +00:00
Charlie Marsh
b701cca779
Enable some already-passing Black tests ( #3079 )
2023-02-21 00:10:35 +00:00
Charlie Marsh
ce8953442d
Add support for trailing colons in slice expressions ( #3077 )
2023-02-20 23:24:32 +00:00
Charlie Marsh
7d4e513a82
Omit while-True loops from implicit return enforcement ( #3076 )
2023-02-20 18:22:28 -05:00
Charlie Marsh
35f7f7b66d
Avoid boolean-trap rules for positional-only builtin calls ( #3075 )
2023-02-20 23:08:18 +00:00
Charlie Marsh
6e02405bd6
Add StmtKind::Try; fix trailing newlines ( #3074 )
2023-02-20 22:55:32 +00:00
Carlos Gonçalves
b657468346
feat(B029): Add B029 from flake8-bugbear ( #3068 )
2023-02-20 15:57:13 -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
7e9dea0027
Change contributing suggestion ( #3067 )
2023-02-20 20:05:38 +00:00
Colin Delahunty
9545958ad8
[flake8-simplify]: Implement manual-dict-lookup ( #2767 )
2023-02-20 20:00:59 +00:00
Colin Delahunty
41faa335d1
[tryceratops]: Verbose Log Messages ( #3036 )
2023-02-20 18:21:04 +00:00
Charlie Marsh
4cfa350112
Bump version to 0.0.249 ( #3063 )
2023-02-20 13:11:29 -05:00
Charlie Marsh
41f163fc8d
Avoid assert() to assert statement conversion in expressions ( #3062 )
2023-02-20 17:49:22 +00:00
Charlie Marsh
d21dd994e6
Increase expected size of FormatElement ( #3049 )
2023-02-20 12:47:35 -05:00
Josh Karpel
6f5a6b8c8b
Do not autofix E731 in class bodies ( #3050 )
2023-02-20 12:38:42 -05:00
Jeong YunWon
35606d7b05
clean up to fix nightly clippy warnings and dedents ( #3057 )
2023-02-20 09:33:47 -05:00
Matthew Lloyd
3ad257cfea
Add PDM to "Who's Using Ruff?" ( #3048 )
2023-02-20 03:58:22 +00:00
Charlie Marsh
b39f960cd1
Relax constraints on pep8-naming module validation ( #3043 )
2023-02-19 17:34:23 -05:00
Charlie Marsh
c297d46899
Remove unused AsFormat trait for Option<T> ( #3041 )
...
We should re-add this, but it's currently unused and doesn't compile under 1.66.0.
See: #3039 .
2023-02-19 20:19:35 +00:00
Jonathan Plasse
d6a100028c
Update docs and pre-commit after #3006 ( #3038 )
2023-02-19 14:23:01 -05:00
Jonathan Plasse
35d4e03f2a
Fix ruff_dev regex workspace dependency ( #3037 )
2023-02-19 18:02:08 +00:00
Charlie Marsh
41e77bb01d
Add some additional users to "Who's Using Ruff?" ( #3035 )
2023-02-19 16:30:01 +00:00
Charlie Marsh
2ff3dd5fbe
Bump version to 0.0.248 ( #3034 )
2023-02-19 16:21:30 +00:00
Charlie Marsh
0f0e7a521a
Avoid false-positives for break in with ( #3032 )
2023-02-19 11:17:04 -05:00
Jonathan Plasse
b75663be6d
Add missing rust-version in crates ( #3009 )
2023-02-19 15:07:17 +00:00
Tomer Chachamu
4d3d04ee61
[PLE0101] error when __init__ returns a value ( #3007 )
2023-02-19 14:54:43 +00:00
Manuel Jacob
87422ba362
Add configuration option for C408 to allow dict calls with keyword arguments. ( #2977 )
...
When creating a dict with string keys, some prefer to call dict instead of writing a dict literal.
For example: `dict(a=1, b=2, c=3)` instead of `{"a": 1, "b": 2, "c": 3}`.
2023-02-19 14:47:03 +00:00
Jeremy Goh
c1d2976fff
[docs] Add docs for flake8-implicit-str-concat rules ( #3028 )
2023-02-19 14:38:59 +00:00
Jeremy Goh
13281cd9ca
[docs] Add some docs for flake8-simplify ( #3027 )
2023-02-19 14:26:56 +00:00
Jonathan Plasse
e53652779d
Avoid raising B027 violations in .pyi files ( #3016 )
2023-02-19 14:21:33 +00:00
Jonathan Plasse
db4c611c6f
Fix broken links and markdown style ( #3017 )
2023-02-19 08:46:49 -05:00
Charlie Marsh
c25be31eb1
Fix documentation-link detection in generate_mkdocs.py ( #3030 )
2023-02-19 12:20:44 +00:00
Micha Reiser
a7c533634d
chore: Remove default_members from Cargo.toml ( #3006 )
...
This PR removes the `default_members` from the workspace configuration.
## Why
I'm not familiar with the motivation for why the `default_members` setting was added initially, and I do not object to keeping it. I'll explain my motivation for removing it below.
My main reason for removing the `default_members` override is that new contributors may not know that `cargo test`, `cargo build`, and other commands only run on a subset of crates. They may then be surprised that their PRs are failing in CI, but everything works locally.
My guess why `default_members` was added is to speed up the development workflow. That's fair, but I question the value because `ruff` is the heaviest crate to build.
2023-02-19 07:18:47 -05:00
Simon Brugman
cfa6883431
docs(readme): add Diffusers ( #3029 )
2023-02-19 07:10:02 -05:00
Nyakku Shigure
216aa929af
Remove duplicate underline in B007 autofix message ( #3021 )
2023-02-18 19:38:20 -05:00
Simon Brugman
9e45424ed6
[pycodestyle] autofix useless semicolons ( #3001 )
2023-02-17 18:52:42 -05:00
Charlie Marsh
db7f16e276
Support positional messages in assertion rewrites ( #3002 )
2023-02-17 23:44:13 +00:00
Charlie Marsh
a10a500a26
Ignore namedtuple methods in flake8-self ( #2998 )
2023-02-17 17:16:25 -05:00
Charlie Marsh
b9fef7cef7
Unlink flake8-bugbear in summary ( #2997 )
2023-02-17 15:58:33 -05:00
Charlie Marsh
34294ccc00
Deduplicate user list ( #2996 )
2023-02-17 20:07:42 +00:00
Simon Brugman
a934d01bdb
[flake8-tidy-imports] extend autofix of relative imports ( #2990 )
...
This extends the autofix for TID252 to work with for relative imports without `module` (i.e. `from .. import`). Tested with `matplotlib` and `bokeh`.
(Previously it would panic on unwrap of the module)
Note that pandas has [replaced](6057d7a93e ) `absolufy-imports` with `ruff` now!
2023-02-17 19:35:28 +00:00
Simon Brugman
0dd590f137
Fix for F541 unescape f-string ( #2971 )
2023-02-17 14:27:01 -05:00
Charlie Marsh
909a5c3253
Avoid zero-indexed column for IOError ( #2995 )
2023-02-17 14:14:28 -05:00
Charlie Marsh
5c987874c4
Enforce D403 on methods ( #2992 )
2023-02-17 18:05:48 +00:00
Nyakku Shigure
0cfe4f9c69
Remove a whitespace in B004 message ( #2991 )
2023-02-17 12:37:08 -05:00
Charlie Marsh
6a369e4a30
Remove via from sentence in README ( #2987 )
2023-02-17 13:49:09 +00:00
Charlie Marsh
6f97e2c457
Split list of users into top-level and dedicated section ( #2986 )
2023-02-17 13:36:32 +00:00
Charlie Marsh
bebd412469
Adjust header depth in docs ( #2985 )
2023-02-17 13:19:55 +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
Charlie Marsh
50ee14a418
Fix references to specific settings in README.md ( #2982 )
2023-02-17 13:07:37 +00:00
Martin Fischer
f5adbbebc5
Fix table of contents enumeration
2023-02-17 07:55:50 -05:00
Martin Fischer
c88e05dc1b
Merge Reference README section into Configuration section
2023-02-17 07:55:50 -05:00
Martin Fischer
d658bfc024
Remove options from README
2023-02-17 07:55:50 -05:00
Martin Fischer
b0d72c47b4
refactor: Move Top-level heading into ruff_dev
2023-02-17 07:55:50 -05:00
Martin Fischer
8195873cdf
Remove rule tables from README
2023-02-17 07:55:50 -05:00
Martin Fischer
bf8108469f
Remove auto-generated table of contents
2023-02-17 07:55:50 -05:00
Martin Fischer
a2277cfeba
refactor: Move fix symbol legend into ruff_dev
2023-02-17 07:55:50 -05:00
Charlie Marsh
180541a924
Unify comment terminology with that of rome_formatter ( #2979 )
2023-02-17 03:02:25 +00:00
Simon Brugman
34664a0ca0
[numpy] numpy-legacy-random ( #2960 )
...
The new `Generator` in NumPy uses bits provided by [PCG64](https://numpy.org/doc/stable/reference/random/bit_generators/pcg64.html#numpy.random.PCG64 ) which has better statistical properties than the legacy [MT19937](https://numpy.org/doc/stable/reference/random/bit_generators/mt19937.html#numpy.random.MT19937 ) used in [RandomState](https://numpy.org/doc/stable/reference/random/legacy.html#numpy.random.RandomState ). Global random functions can also be problematic with parallel processing.
This rule is probably quite useful for data scientists (perhaps in combination with `nbqa`)
References:
- [Legacy Random Generation](https://numpy.org/doc/stable/reference/random/legacy.html#legacy )
- [Random Sampling](https://numpy.org/doc/stable/reference/random/index.html#random-quick-start )
- [Using PyTorch + NumPy? You're making a mistake.](https://tanelp.github.io/posts/a-bug-that-plagues-thousands-of-open-source-ml-projects/ )
2023-02-17 02:06:30 +00:00
Charlie Marsh
e081455b06
Add support for file-scoped noqa directives ( #2978 )
...
# Summary
This allows users to do things like:
```py
# ruff: noqa: F401
```
...to ignore all `F401` directives in a file. It's equivalent to `per-file-ignores`, but allows users to specify the behavior inline.
Note that Flake8 does _not_ support this, so we _don't_ respect `# flake8: noqa: F401`. (Flake8 treats that as equivalent to `# flake8: noqa`, so ignores _all_ errors in the file. I think all of [these usages](https://cs.github.com/?scopeName=All+repos&scope=&q=%22%23+flake8%3A+noqa%3A+%22 ) are probably mistakes!)
A couple notes on the details:
- If a user has `# ruff: noqa: F401` in the file, but also `# noqa: F401` on a line that would legitimately trigger an `F401` violation, we _do_ mark that as "unused" for `RUF100` purposes. This may be the wrong choice. The `noqa` is legitimately unused, but it's also not "wrong". It's just redundant.
- If a user has `# ruff: noqa: F401`, and runs `--add-noqa`, we _won't_ add `# noqa: F401` to any lines (which seems like the obvious right choice to me).
Closes #1054 (which has some extra pieces that I'll carve out into a separate issue).
Closes #2446 .
2023-02-17 01:59:01 +00:00
Artem Mukhin
4f18fa6733
Add test case for '\u' prefix in B005 ( #2976 )
...
Based on #2958 .
2023-02-16 19:45:29 -05:00
Charlie Marsh
6088a36cd3
Use line_suffix for end-of-line comments ( #2975 )
2023-02-16 18:37:40 -05:00
Charlie Marsh
66a162fa40
Handle non-from __future__ imports ( #2974 )
...
These are uncommon, but currently panic.
Closes #2967 .
2023-02-16 22:56:03 +00:00
Mike Taves
e6722f92ed
Add Rust Trove classifier ( #2973 )
2023-02-16 17:38:36 -05:00
Charlie Marsh
750c28868f
Enable jemalloc on FreeBSD and NetBSD ( #2965 )
2023-02-16 15:21:34 -05:00
Charlie Marsh
5157f584ab
Improve pow operator spacing ( #2970 )
...
Ensure that we add spaces to expressions like `foo.bar() ** 2`.
2023-02-16 15:17:32 -05:00
Charlie Marsh
1c01ec21cb
Regenerate expected Black snapshots ( #2968 )
2023-02-16 19:39:17 +00:00
Manuel Jacob
879512742f
Skip .pytype directory by default. ( #2966 )
...
Pytype stores .pyi files in .pytype that ruff shouldn’t check or touch.
2023-02-16 14:38:08 -05:00
Florian Best
a919041dda
feat(isort): Implement isort.force_to_top ( #2877 )
2023-02-16 19:01:59 +00:00
Charlie Marsh
059601d968
Avoid trying to fix implicit returns with control flow ( #2962 )
2023-02-16 13:42:46 -05:00
Charlie Marsh
2ec1701543
Remove link in asyncio.create_task ( #2963 )
2023-02-16 17:50:56 +00:00
Charlie Marsh
370c3a5daf
Remove mdcat dependency ( #2959 )
2023-02-16 12:09:37 -05:00
Charlie Marsh
fdcb78fd8c
Avoid jemallocator on BSD ( #2957 )
2023-02-16 11:48:51 -05:00
Simon Brugman
2a744d24e5
docs: flake8-self remove unnecessary backticks ( #2951 )
2023-02-16 08:25:34 -05:00
Simon Brugman
cc30738148
Implement flake8-module-naming ( #2855 )
...
- Implement N999 (following flake8-module-naming) in pep8_naming
- Refactor pep8_naming: split rules.rs into file per rule
- Documentation for majority of the violations
Closes https://github.com/charliermarsh/ruff/issues/2734
2023-02-16 04:20:33 +00:00
Edgar R. M
147c6ff1db
Exclude crates/ruff_python_formatter/resources from pre-commit check ( #2947 )
2023-02-15 22:56:42 -05:00
Charlie Marsh
036380e6a8
Fix add-required-import with multi-line offsets ( #2946 )
2023-02-16 03:24:55 +00:00
Charlie Marsh
b6587e51ee
Use an enum to represent composition kind ( #2945 )
2023-02-15 22:14:00 -05:00
Simon Brugman
1bc37110d4
[flake8-pytest-style] autofix for composite-assertion (PT018) ( #2732 )
2023-02-16 00:36:07 +00:00
Lunarmagpie
28acdb76cf
Add support for ensure_future for RUF006 ( #2943 )
2023-02-15 23:18:11 +00:00
Martin Fischer
7b09972c97
Merge convert-loop-to-any & convert-loop-to-all to reimplemented-builtin
2023-02-15 16:24:31 -05:00
Charlie Marsh
f8d46d09ef
Implement asyncio-dangling-task to track asyncio.create_task calls ( #2935 )
...
This rule guards against `asyncio.create_task` usages of the form:
```py
asyncio.create_task(coordinator.ws_connect()) # Error
```
...which can lead to unexpected bugs due to the lack of a strong reference to the created task. See Will McGugan's blog post for reference: https://textual.textualize.io/blog/2023/02/11/the-heisenbug-lurking-in-your-async-code/ .
Note that we can't detect issues like:
```py
def f():
# Stored as `task`, but never used...
task = asyncio.create_task(coordinator.ws_connect())
```
So that would be a false negative. But this catches the common case of failing to assign the task in any way.
Closes #2809 .
2023-02-15 15:19:03 -05:00
Martin Fischer
294cd95c54
Update clap to fix ruff check --help description
...
My two clap bug fixes[1][2] have been merged and released
(see the change in README.md).
[1]: https://github.com/clap-rs/clap/pull/4710
[2]: https://github.com/clap-rs/clap/pull/4712
2023-02-15 13:30:06 -05:00
Charlie Marsh
d8e709648d
Add Transformers to README ( #2933 )
2023-02-15 17:09:50 +00:00
Charlie Marsh
52cc4d6537
Deduplicate files provided on the command-line ( #2931 )
2023-02-15 12:08:34 -05:00
messense
08e9d12137
Upload ruff binaries to GitHub release ( #2930 )
2023-02-15 12:07:47 -05:00
Charlie Marsh
39fdc71b49
Bump version to 0.0.247 ( #2932 )
2023-02-15 12:06:58 -05:00
Charlie Marsh
6b0736cf4b
Allow private accesses on current class ( #2929 )
2023-02-15 16:52:05 +00:00
Charlie Marsh
58269a918a
Apply nullable-model-string-field to all classes ( #2928 )
2023-02-15 15:54:14 +00:00
Sawbez
9168a12679
[docs] flake8-self Private member access docs ( #2912 )
2023-02-15 15:42:38 +00:00
Charlie Marsh
cb971d3a48
Respect self as positional-only argument in annotation rules ( #2927 )
2023-02-15 15:25:17 +00:00
Charlie Marsh
57a5071b4e
Rename some methods on Locator ( #2926 )
2023-02-15 10:21:49 -05:00
Charlie Marsh
976fe364d4
Remove setup.py ( #2922 )
2023-02-15 14:35:11 +00:00
messense
028c7855b2
Simplify release workflows ( #2913 )
...
* No need to build for PyPy since it only contains a binary so the platform tag is the same as CPython
* Update `maturin-action` location
2023-02-15 08:15:19 -05:00
Nick Pope
e5179f67fd
Remove autogenerated docs/rules/*.md files ( #2917 )
2023-02-15 08:11:11 -05:00
Simon Brugman
c9c199dbca
Remove testing resource introduced in #2891 ( #2916 )
2023-02-15 08:10:58 -05:00
Martin Fischer
70e378b736
Implement shell autocompletion for rule codes
...
For example:
$ ruff check --select=EM<Tab>
EM -- flake8-errmsg
EM10 EM1 --
EM101 -- raw-string-in-exception
EM102 -- f-string-in-exception
EM103 -- dot-format-in-exception
(You will need to enable autocompletion as described
in the Autocompletion section in the README.)
Fixes #2808 .
(The --help help change in the README is due to a clap bug,
for which I already submitted a fix:
https://github.com/clap-rs/clap/pull/4710 .)
2023-02-15 08:09:34 -05:00
Charlie Marsh
ca49b00e55
Add initial formatter implementation ( #2883 )
...
# Summary
This PR contains the code for the autoformatter proof-of-concept.
## Crate structure
The primary formatting hook is the `fmt` function in `crates/ruff_python_formatter/src/lib.rs`.
The current formatter approach is outlined in `crates/ruff_python_formatter/src/lib.rs`, and is structured as follows:
- Tokenize the code using the RustPython lexer.
- In `crates/ruff_python_formatter/src/trivia.rs`, extract a variety of trivia tokens from the token stream. These include comments, trailing commas, and empty lines.
- Generate the AST via the RustPython parser.
- In `crates/ruff_python_formatter/src/cst.rs`, convert the AST to a CST structure. As of now, the CST is nearly identical to the AST, except that every node gets a `trivia` vector. But we might want to modify it further.
- In `crates/ruff_python_formatter/src/attachment.rs`, attach each trivia token to the corresponding CST node. The logic for this is mostly in `decorate_trivia` and is ported almost directly from Prettier (given each token, find its preceding, following, and enclosing nodes, then attach the token to the appropriate node in a second pass).
- In `crates/ruff_python_formatter/src/newlines.rs`, normalize newlines to match Black’s preferences. This involves traversing the CST and inserting or removing `TriviaToken` values as we go.
- Call `format!` on the CST, which delegates to type-specific formatter implementations (e.g., `crates/ruff_python_formatter/src/format/stmt.rs` for `Stmt` nodes, and similar for `Expr` nodes; the others are trivial). Those type-specific implementations delegate to kind-specific functions (e.g., `format_func_def`).
## Testing and iteration
The formatter is being developed against the Black test suite, which was copied over in-full to `crates/ruff_python_formatter/resources/test/fixtures/black`.
The Black fixtures had to be modified to create `[insta](https://github.com/mitsuhiko/insta )`-compatible snapshots, which now exist in the repo.
My approach thus far has been to try and improve coverage by tackling fixtures one-by-one.
## What works, and what doesn’t
- *Most* nodes are supported at a basic level (though there are a few stragglers at time of writing, like `StmtKind::Try`).
- Newlines are properly preserved in most cases.
- Magic trailing commas are properly preserved in some (but not all) cases.
- Trivial leading and trailing standalone comments mostly work (although maybe not at the end of a file).
- Inline comments, and comments within expressions, often don’t work -- they work in a few cases, but it’s one-off right now. (We’re probably associating them with the “right” nodes more often than we are actually rendering them in the right place.)
- We don’t properly normalize string quotes. (At present, we just repeat any constants verbatim.)
- We’re mishandling a bunch of wrapping cases (if we treat Black as the reference implementation). Here are a few examples (demonstrating Black's stable behavior):
```py
# In some cases, if the end expression is "self-closing" (functions,
# lists, dictionaries, sets, subscript accesses, and any length-two
# boolean operations that end in these elments), Black
# will wrap like this...
if some_expression and f(
b,
c,
d,
):
pass
# ...whereas we do this:
if (
some_expression
and f(
b,
c,
d,
)
):
pass
# If function arguments can fit on a single line, then Black will
# format them like this, rather than exploding them vertically.
if f(
a, b, c, d, e, f, g, ...
):
pass
```
- We don’t properly preserve parentheses in all cases. Black preserves parentheses in some but not all cases.
2023-02-15 04:06:35 +00:00
Charlie Marsh
f661c90bd7
Remove dependency on ruff_rowan ( #2875 )
...
This PR removes the dependency on `ruff_rowan` (i.e., Rome's fork of rust-analyzer's `rowan`), and in turn, trims out a lot of code in `ruff_formatter` that isn't necessary (or isn't _yet_ necessary) to power the autoformatter.
We may end up pulling some of this back in -- TBD. For example, the autoformatter has its own comment representation right now, but we may eventually want to use the `comments.rs` data structures defined in `rome_formatter`.
2023-02-15 03:54:08 +00:00
Charlie Marsh
5a84df293f
Allow printing of consecutive empty lines ( #2874 )
2023-02-14 22:35:02 -05:00
Charlie Marsh
23d9309111
Remove JetBrains webinar badge ( #2910 )
2023-02-15 03:28:12 +00:00
Charlie Marsh
98ea94fdb7
Add StaticTextSlice kind to FormatElement enum ( #2873 )
...
Given our current parser abstractions, we need the ability to tell `ruff_formatter` to print a pre-defined slice from a fixed string of source code, which we've introduced here as `FormatElement::StaticTextSlice`.
2023-02-14 22:27:52 -05:00
Charlie Marsh
746e1d3436
Add contributors to acknowledgements ( #2909 )
2023-02-15 03:15:38 +00:00
Charlie Marsh
016ff01a04
Add an FAQ question around Python version support ( #2908 )
2023-02-15 03:11:44 +00:00
Charlie Marsh
298498e934
Add an Acknowledgements section to the README ( #2907 )
2023-02-15 00:25:07 +00:00
Charlie Marsh
3ef1c2e303
Add rome_formatter fork as ruff_formatter ( #2872 )
...
The Ruff autoformatter is going to be based on an intermediate representation (IR) formatted via [Wadler's algorithm](https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf ). This is architecturally similar to [Rome](https://github.com/rome/tools ), Prettier, [Skip](https://github.com/skiplang/skip/blob/master/src/tools/printer/printer.sk ), and others.
This PR adds a fork of the `rome_formatter` crate from [Rome](https://github.com/rome/tools ), renamed here to `ruff_formatter`, which provides generic definitions for a formatter IR as well as a generic IR printer. (We've also pulled in `rome_rowan`, `rome_text_size`, and `rome_text_edit`, though some of these will be removed in future PRs.)
Why fork? `rome_formatter` contains code that's specific to Rome's AST representation (e.g., it relies on a fork of rust-analyzer's `rowan`), and we'll likely want to support different abstractions and formatting capabilities (there are already a few changes coming in future PRs). Once we've dropped `ruff_rowan` and trimmed down `ruff_formatter` to the code we currently need, it's also not a huge surface area to maintain and update.
2023-02-14 19:22:55 -05:00
Simon Brugman
ac028cd9f8
[numpy] deprecated type aliases ( #2810 )
...
Closes https://github.com/charliermarsh/ruff/issues/2455
Used `NPY` as prefix code as agreed in the issue.
2023-02-14 23:45:12 +00:00
Edgar R. M
c0eb5c28d1
[docs] Add docs for flake8-errmsg ( #2888 )
2023-02-14 23:21:34 +00:00
Martin Fischer
a77b4566e4
Fix option links in mkdocs rule pages
...
In 28c9263722 I introduced automatic
linkification of option references in rule documentation,
which automatically converted the following:
## Options
* `namespace-packages`
to:
## Options
* [`namespace-packages`]
[`namespace-packages`]: ../../settings#namespace-packages
While the above is a correct CommonMark[1] link definition,
what I was missing was that we used mkdocs for our documentation
generation, which as it turns out uses a non-CommonMark-compliant
Markdown parser, namely Python-Markdown, which contrary to CommonMark
doesn't support link definitions containing code tags.
This commit fixes the broken links via a regex hack.
[1]: https://commonmark.org/
2023-02-14 17:56:21 -05:00
Martin Fischer
860993187e
Fix link relativization in generate_mkdocs.py
2023-02-14 17:56:21 -05:00
Charlie Marsh
58d4e00604
Add publish = false to unpublished crates ( #2905 )
2023-02-14 22:41:14 +00:00
Simon Legner
2d95912699
docs: fix ruff generate-shell-completion ( #2904 )
2023-02-14 22:38:29 +00:00
Simon Brugman
4f927fbacc
[flake8-tidy-imports] autofix relative imports ( #2891 )
...
Previous fix was bugged. This one is only fixing when the `module_path` is present, making it far more robust.
Closes #2764 and closes #2869
2023-02-14 22:24:59 +00:00
Anders Kaseorg
2e41301520
Switch some quotes to backticks in errors ( #2889 )
...
Improves consistency with the style decision in #723 , I think.
2023-02-14 22:24:41 +00:00
Martin Fischer
3179fc110d
Disable many-to-one mapping for now
2023-02-14 16:16:12 -05:00
Martin Fischer
03ae0118b7
many-to-one 9/9: Update table generation
2023-02-14 16:16:12 -05:00
Martin Fischer
05176890ee
many-to-one 8/9: Drop codes from registry
...
This commit was generated by running:
fastmod --accept-all '[A-Z]+[0-9]+ => ' '' crates/ruff/src/registry.rs
2023-02-14 16:16:12 -05:00
Martin Fischer
849b947b3e
many-to-one 7/9: Update JSON schema
2023-02-14 16:16:12 -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
9eda286dcd
many-to-one 5/9: Generate codes.rs from registry.rs
...
# This commit was generated by running the following Python code:
# (followed by `sed -Ei 's/(mod registry;)/\1mod codes;/' crates/ruff/src/lib.rs`
# and `cargo fmt`).
import json
import re
import subprocess
def parse_registry():
file = open('crates/ruff/src/registry.rs')
rules = []
while next(file) != 'ruff_macros::register_rules!(\n':
continue
while (line := next(file)) != ');\n':
line = line.strip().rstrip(',')
if line.startswith('//') or line.startswith('#['):
rules.append(line)
continue
code, path = line.split(' => ')
name = path.rsplit('::')[-1]
rules.append((code, name))
while (line := next(file)) != 'pub enum Linter {\n':
continue
prefixes = []
prefix2linter = []
while (line := next(file).strip()) != '}':
if line.startswith('//'):
continue
if line.startswith('#[prefix = '):
prefixes.append(line.split()[-1].strip('"]'))
else:
for prefix in prefixes:
prefix2linter.append((prefix, line.rstrip(',')))
prefixes.clear()
prefix2linter.sort(key = lambda t: len(t[0]), reverse=True)
return rules, prefix2linter
rules, prefix2linter = parse_registry()
def parse_code(code):
prefix = re.match('[A-Z]+', code).group()
if prefix in ('E', 'W'):
return 'Pycodestyle', code
for prefix, linter in prefix2linter:
if code.startswith(prefix):
return linter, code[len(prefix) :]
assert False
text = '''
use crate::registry::{Linter, Rule};
pub fn code_to_rule(linter: Linter, code: &str) -> Option<Rule> {
#[allow(clippy::enum_glob_use)]
use Linter::*;
Some(match (linter, code) {
'''
for entry in rules:
if isinstance(entry, str):
if entry.startswith('//'):
text += '\n' + entry
else:
text += entry
else:
namespace, code = parse_code(entry[0])
text += f'({namespace}, "{code}") => Rule::{entry[1]},'
text += '\n'
text += '''
_ => return None,
})
}
'''
with open('crates/ruff/src/codes.rs', 'w') as f:
f.write(text)
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
1b8d2df3bf
many-to-one 3/9: Update RuleSelector::short_code
...
Same reasoning as for the previous commit ... one &'static str
becomes two &'static str because we split the RuleCodePrefix enum.
Note that the .unwrap() we have to add now, will actually
be removed in the 6th commit.
2023-02-14 16:16:12 -05:00
Martin Fischer
179ead0157
many-to-one 2/9: Newtype Rule::noqa_code return type
...
Rule::noqa_code previously return a single &'static str,
which was possible because we had one enum listing all
rule code prefixes. This commit series will however split up
the RuleCodePrefix enum into several enums ... so we'll end up
with two &'static str ... this commit wraps the return type
of Rule::noqa_code into a newtype so that we can easily change
it to return two &'static str in the 6th commit of this series.
2023-02-14 16:16:12 -05:00
Martin Fischer
d451c7a506
many-to-one 1/9: Rename Rule::code to Rule::noqa_code
...
Post this commit series several codes can be mapped to a single rule,
this commit therefore renames Rule::code to Rule::noqa_code,
which is the code that --add-noqa will add to ignore a rule.
2023-02-14 16:16:12 -05:00
Martin Fischer
502ce80c91
many-to-one 0/9: Introduce RuleSelector::Linter variant
...
We want to remove the variants denoting whole Linters
from the RuleCodePrefix enum, so we have to introduce
a new RuleSelector::Linter variant.
2023-02-14 16:16:12 -05:00
Charlie Marsh
49d22d8fe2
Ignore non-imperative-mood in Google docstring convention ( #2900 )
2023-02-14 20:42:20 +00:00
Chris May
08e0b76587
Add headers to configutation options ( #2896 )
...
This completes the word from the discussion in #2643 , adding headers to clarify the `pyproject.toml` and `ruff.toml` sections.
2023-02-14 13:45:59 -05:00
Charlie Marsh
f7515739ac
Improve consistency of some rule docs ( #2887 )
2023-02-14 04:36:37 +00:00
Sawbez
53e810ed3e
[docs] Add docs for the entirety of flake8-builtins ( #2840 )
2023-02-14 04:30:30 +00:00
Charlie Marsh
66a195f805
Extend B904 to else branches ( #2886 )
2023-02-14 03:58:15 +00:00
Jeremiah England
b8483975a4
docs(SIM114): fix typo in example Python code ( #2884 )
2023-02-14 03:23:19 +00:00
Charlie Marsh
4dd2032687
Unversion unpublished crates ( #2882 )
2023-02-14 03:03:49 +00:00
Charlie Marsh
c6c15d5cf9
Avoid unnecessary-else violations in elif branches ( #2881 )
...
Long-time source of confusion -- two reports over 1800 issues apart.
Closes #1035 .
Closes #2879 .
2023-02-14 02:51:12 +00:00
Charlie Marsh
2bf7b35268
Re-enable custom allocators ( #2876 )
2023-02-14 02:37:22 +00:00
Charlie Marsh
6d1adc85fc
Remove autofix for prefer-type-error ( #2880 )
2023-02-14 02:26:22 +00:00
Martin Fischer
02285c18d1
Remove autogenerated docs/rules/*.md files
2023-02-13 19:34:06 -05:00
Martin Fischer
8120d7c974
Change rule page links in README from GitHub to beta.ruff.rs
2023-02-13 19:34:06 -05:00
Martin Fischer
c858804ed4
refactor: Move docs/ gitignores to docs/.gitignore
2023-02-13 19:34:06 -05:00
Anders Kaseorg
b9d075c252
Alphabetize flake8-raise and flake8-self in documentation ( #2871 )
2023-02-13 18:03:09 -05:00
Charlie Marsh
7627e840c9
Avoid noqa removal upon unhandled syntax errors ( #2864 )
2023-02-13 10:37:55 -05:00
Charlie Marsh
3c03e2cb2e
Rename flake8-django rules to match convention ( #2861 )
2023-02-13 15:30:04 +00:00
Charlie Marsh
aeae63b7ea
Avoid false-positives for runtime-types in type checking blocks ( #2863 )
2023-02-13 10:26:34 -05:00
Charlie Marsh
7be17c5f1e
Avoid false-positives with multi-byte characters in B005 ( #2862 )
2023-02-13 15:07:55 +00:00
Charlie Marsh
6128346b08
Re-show --target-version on CLI interface ( #2859 )
2023-02-13 15:04:11 +00:00
Charlie Marsh
1705574e75
Handle multiple receiver decorators in receiver-decorator ( #2858 )
2023-02-13 14:57:11 +00:00
Charlie Marsh
15f65fa8d6
Run cargo dev generate-all ( #2860 )
2023-02-13 14:55:44 +00:00
Ville Skyttä
d1cf0ee52b
Remove "blanket" from RUF100 README message ( #2844 )
2023-02-13 14:43:35 +00:00
Florian Best
32520ff07f
ci(gitignore): ignore VIM files ( #2856 )
2023-02-13 09:29:53 -05:00
Ville Skyttä
3659236580
Remove no longer needed setup.py INP001 ignore ( #2846 )
2023-02-13 09:00:35 -05:00
Charlie Marsh
dde69d50b5
Move more dependencies into workspace dependencies ( #2842 )
2023-02-13 04:19:26 +00:00
Charlie Marsh
67198ce7b3
Revert "Run release on tag creation"
...
This reverts commit c21a5912b9 .
2023-02-12 23:11:31 -05:00
Charlie Marsh
c21a5912b9
Run release on tag creation
2023-02-12 22:33:01 -05:00
Charlie Marsh
48a5cd1dd9
Revert "perf: Use custom allocator ( #2768 )" ( #2841 )
...
This is causing wheel creation to fail on some of our more exotic build targets: https://github.com/charliermarsh/ruff/actions/runs/4159524132 .
Let's figure out how to gate appropriately, but for now, reverting to get the release out.
2023-02-12 22:31:34 -05:00
Charlie Marsh
63f3d5e610
Update pre-commit instructions ( #2838 )
2023-02-13 00:06:40 +00:00
Charlie Marsh
7dab4807d0
Allow compound statements of single ellipsis ( #2837 )
...
This allows `class C: ...`-style compound statements in stub files.
Closes #2835 .
2023-02-12 18:56:43 -05:00
Charlie Marsh
83f6e52c92
Bump version to 0.0.246 ( #2834 )
2023-02-12 23:39:51 +00:00
Charlie Marsh
5ce7ce5bc3
Check-in updated snapshot for SIM111 ( #2836 )
2023-02-12 23:37:52 +00:00
Florian Best
749d197119
docs(SIM114): fix typo in python code ( #2833 )
2023-02-12 18:35:29 -05:00
Charlie Marsh
46c184600f
Include package inference during --add-noqa command ( #2832 )
2023-02-12 22:45:39 +00:00
Charlie Marsh
e2051ef72f
Use smarter inversion for comparison checks ( #2831 )
2023-02-12 22:39:29 +00:00
Charlie Marsh
1abaece9ed
Fix unused multi-assignments in a single pass ( #2829 )
2023-02-12 22:28:03 +00:00
Charlie Marsh
8b35b052b8
Avoid duplicates in if-with-same-arms ( #2827 )
2023-02-12 22:22:19 +00:00
Charlie Marsh
5a34504149
Implement ComparableStmt ( #2826 )
2023-02-12 22:00:01 +00:00
trag1c
0e53ddc2b3
Added Tables of Contents for CONTRIBUTING.md and CODE_OF_CONDUCT.md ( #2824 )
2023-02-12 16:38:18 -05:00
Colin Delahunty
1f07ad6e61
[flake8-simplify]: combine-if-conditions ( #2823 )
2023-02-12 21:00:32 +00:00
Charlie Marsh
1666e8ba1e
Add a --show-fixes flag to include applied fixes in output ( #2707 )
2023-02-12 20:48:01 +00:00
Charlie Marsh
c399b3e6c1
Run cargo dev generate-all ( #2822 )
2023-02-12 19:11:49 +00:00
Charlie Marsh
9089ef74bc
Upgrade RustPython ( #2821 )
2023-02-12 18:45:59 +00:00
Martin Fischer
28c9263722
Automatically linkify option references in rule documentation
...
Previously the rule documentation referenced configuration options
via full https:// URLs, which was bad for several reasons:
* changing the website would mean you'd have to change all URLs
* the links didn't work when building mkdocs locally
* the URLs showed up in the `ruff rule` output
* broken references weren't detected by our CI
This commit solves all of these problems by post-processing the
Markdown, recognizing sections such as:
## Options
* `flake8-tidy-imports.ban-relative-imports`
`cargo dev generate-all` will automatically linkify such references
and panic if the referenced option doesn't exist.
Note that the option can also be linked in the other Markdown sections
via e.g. [`flake8-tidy-imports.ban-relative-imports`] since
the post-processing code generates a CommonMark link definition.
Resolves #2766 .
2023-02-12 13:19:11 -05:00
Martin Fischer
fc4c927788
refactor: Introduce ConfigurationOptions::get method
2023-02-12 13:19:11 -05:00
Zeddicus414
26f39cac2f
Add PD002 use-of-inplace-argument documentation ( #2799 )
2023-02-12 18:10:34 +00:00
Simon Brugman
02897a141b
[flake8-tidy-imports] add documentation for banned-api ( #2819 )
2023-02-12 18:09:39 +00:00
Nyakku Shigure
fc465cc2af
[flake8-pyi]: add rules for unrecognized platform check (PYI007, PYI008) ( #2805 )
...
Add two [flake8-pyi](https://github.com/PyCQA/flake8-pyi ) rules (Y007, Y008). ref: #848
The specifications are described in [PEP 484 - Version and platform checking](https://peps.python.org/pep-0484/#version-and-platform-checking )
The original implementation in flake8-pyi is shown below.
- Implemention: 66f28a4407/pyi.py (L1429-L1443)
- Tests: 66f28a4407/tests/sysplatform.pyi
2023-02-12 18:02:38 +00:00
Charlie Marsh
ca8a122889
Add flake8-django to LICENSE ( #2820 )
2023-02-12 17:51:40 +00:00
Karol Onyśko
6769a5bce7
Implement flake8-django plugin rules ( #2586 )
2023-02-12 17:47:59 +00:00
Zeddicus414
fda93c6245
Add E722 bare-except documentation ( #2796 )
2023-02-12 16:51:32 +00:00
Charlie Marsh
099d5414f2
Allow non-verbose raise when cause is present ( #2816 )
...
The motivating issue here is of the following form:
```py
try:
raise Exception("We want to hide this error message")
except Exception:
try:
raise Exception("We want to show this")
except Exception as exc:
raise exc from None
```
However, I think we should avoid this if _any_ cause is present, since causes require a named exception.
Closes #2814 .
2023-02-12 16:48:13 +00:00
Charlie Marsh
9ddd5e4cfe
Allow private accesses on super calls ( #2815 )
2023-02-12 16:11:25 +00:00
trag1c
b8835c2e35
Added MkDocs section to CONTRIBUTING.md ( #2803 )
2023-02-12 16:07:24 +00:00
Simon Brugman
1d4422f004
[flake8-comprehensions] improve autofix for C401, C402 and C417 ( #2806 )
2023-02-12 16:03:37 +00:00
Simon Brugman
2dccb7611a
[flake8-comprehensions] bugfix for C413 autofix ( #2804 )
2023-02-12 15:56:07 +00:00
Simon Brugman
f8ac6d7bf0
fix: script add_plugin.py test import ( #2807 )
2023-02-12 09:58:23 -05:00
Simon Brugman
0123425be1
[flake8-comprehensions] autofix C414 and C417 + bugfix ( #2693 )
...
Closes https://github.com/charliermarsh/ruff/issues/2262 and closes https://github.com/charliermarsh/ruff/issues/2423
Fixes bug where some cases generated duplicated violations (see https://github.com/charliermarsh/ruff/pull/2732#issuecomment-1426397842 )
2023-02-12 05:20:42 +00:00
Charlie Marsh
c53f91d943
Remove public re-export of commands ( #2801 )
2023-02-12 04:59:35 +00:00
Charlie Marsh
4a12ebb9b1
Improve f-string-missing-placeholders documentation ( #2800 )
2023-02-12 04:58:24 +00:00
Martin Fischer
0e4d5eeea7
Implement config subcommand
...
The synopsis is as follows.
List all top-level config keys:
$ ruff config
allowed-confusables
builtins
cache-dir
... etc.
List all config keys in a specific section:
$ ruff config mccabe
max-complexity
Describe a specific config option:
$ ruff config mccabe.max-complexity
The maximum McCabe complexity to allow before triggering `C901` errors.
Default value: 10
Type: int
Example usage:
```toml
# Flag errors (`C901`) whenever the complexity level exceeds 5.
max-complexity = 5
```
2023-02-11 23:43:09 -05:00
Martin Fischer
bbe44360e8
refactor: Move name out of OptionField & OptionGroup
2023-02-11 23:43:09 -05:00
Martin Fischer
37e80d98ab
refactor: Reorder members in ruff::settings::options_base
2023-02-11 23:43:09 -05:00
Charlie Marsh
306393063d
Refactor generator to use Astor-derived precedence levels ( #2798 )
2023-02-12 04:30:16 +00:00
Martin Fischer
f5a3c90288
Rename new ruff rule output format to "pretty"
...
The new `ruff rule` output format introduced in
551b810aeb doesn't print Markdown but
rather some rich text with escape sequences for colors and links,
it's actually the "text" format that prints Markdown, so naming the new
format "markdown" is very confusing. This commit therefore renames it to
"pretty".
This isn't a breaking change since there hasn't been a release yet.
2023-02-11 23:23:37 -05:00
Charlie Marsh
8289ede00f
Use output-stdout pattern for linter command ( #2794 )
2023-02-12 03:09:03 +00:00
Charlie Marsh
77e65c9ff5
Split commands.rs into separate files ( #2792 )
2023-02-12 02:58:13 +00:00
Charlie Marsh
d827a9156e
Add documentation on enabling autocompletion ( #2791 )
2023-02-12 02:51:50 +00:00
Charlie Marsh
418808895e
Add docs for f-string-missing-placeholders and unused-variable ( #2790 )
2023-02-12 02:48:36 +00:00
Charlie Marsh
ac4e212ed2
Move Wasm clippy to its own job ( #2789 )
2023-02-12 02:41:28 +00:00
Nick Pope
551b810aeb
Add rendering of rule markdown for terminal output ( #2747 )
...
Add rendering of rule markdown for terminal output
This is achieved by making use of the `mdcat` crate.
See the following links for details:
- https://crates.io/crates/mdcat
- https://github.com/swsnr/mdcat
- https://docs.rs/mdcat/latest/mdcat/
2023-02-12 02:32:45 +00:00
Charlie Marsh
1b61d4e18b
Support unused variable removal in multi-assignment statements ( #2786 )
2023-02-12 00:53:11 +00:00
Charlie Marsh
752c0150e1
Improve unused-variable autofixes for with statements ( #2785 )
2023-02-12 00:38:14 +00:00
Charlie Marsh
81651a8479
Respect continuations in noqa enforcement ( #2783 )
2023-02-11 23:29:37 +00:00
Charlie Marsh
86d0749ed7
Use consistent formatting for lint-failure messages ( #2782 )
2023-02-11 22:52:18 +00:00
Charlie Marsh
19fc410683
Remove raw string from hardcoded-sql-expression ( #2780 )
2023-02-11 20:05:57 +00:00
Charlie Marsh
5a70a573cd
Avoid treating deferred string annotations as required-at-runtime ( #2779 )
2023-02-11 15:00:08 -05:00
Charlie Marsh
74731a3456
Fix reference to ban-relative-imports setting ( #2776 )
2023-02-11 18:34:25 +00:00
Micha Reiser
863e39fe5f
perf: Use custom allocator ( #2768 )
...
This PR replaces the system allocator with a custom allocator to improve performance:
* Windows: mimalloc
* Unix: tikv-jemallocator
## Performance:
* Linux
* `cpython --no-cache`: 208.8ms -> 190.5ms
* `cpython`: 32.8ms -> 31ms
* Mac:
* `cpython --no-cache`: 436.3ms -> 380ms
* `cpython`: 40.9ms -> 39.6ms
* Windows:
* `cpython --no-cache`: 367ms -> 268ms
* `cpython`: 92.5ms -> 92.3ms
## Size
* Linux: +5MB from 13MB -> 18MB (I need to double check this)
* Mac: +0.7MB from 8.3MB-> 9MB
* Windows: -0.16MB from 8.29MB -> 8.13MB (that's unexpected)
2023-02-11 13:26:07 -05:00
Charlie Marsh
d0f9ee33ec
Remove erroneous print statements
2023-02-11 12:45:40 -05:00
Charlie Marsh
1cf3d880a7
Don't treat all future import accesses as non-runtime ( #2774 )
...
This was just an oversight and misunderstanding on my part. We had some helpful tests, but I misunderstood the "right" behavior so thought they were passing.
Closes #2761 .
2023-02-11 12:44:15 -05:00
Charlie Marsh
97dcb738fa
Run cargo dev generate-all
2023-02-11 12:43:48 -05:00
Charlie Marsh
ffb4e89a98
Remove multiple-statements-on-one-line-def (E704) ( #2773 )
2023-02-11 12:34:21 -05:00
Charlie Marsh
43b7ee215c
Ignore colon-after-lambda in compound statement rules ( #2771 )
2023-02-11 12:22:53 -05:00
Michał Mrówka
77099dcd4d
implemented option lines-between-types for isort ( #2762 )
...
Fixes #2585
Add support for the isort option [lines_between_types](https://pycqa.github.io/isort/docs/configuration/options.html#lines-between-types )
2023-02-11 12:17:37 -05:00
Martin Fischer
70ff65154d
Rename function-is-too-complex to complex-structure
2023-02-11 12:05:17 -05:00
Martin Fischer
7db6a2d6d4
Rename rules containing PEP reference in name
2023-02-11 12:05:17 -05:00
Martin Fischer
42924c0d9a
Rename a bunch of pydocstyle rules
2023-02-11 12:05:17 -05:00
Martin Fischer
31d00936ee
Drop no- from no-unnecessary-* rule names
2023-02-11 12:05:17 -05:00
Martin Fischer
c3c5d9a852
Rename nested-if-statements to collapsible-if
2023-02-11 12:05:17 -05:00
Martin Fischer
7e5c19385c
Rename return-bool-condition-directly to needless-bool
2023-02-11 12:05:17 -05:00
Simon Brugman
5b54325c81
enable navigation in footer in docs ( #2760 )
2023-02-11 05:08:33 -05:00
trag1c
e6538a7969
Added logo and favicon for mkdocs ( #2757 )
2023-02-10 23:34:47 -05:00
Charlie Marsh
24faabf1f4
Bump version to 0.0.245
2023-02-10 22:15:27 -05:00
Charlie Marsh
9b0a160239
Only update docs on release ( #2755 )
2023-02-10 22:14:50 -05:00
Charlie Marsh
9fd29e2c54
Mention default in relative-imports doc
2023-02-10 22:12:22 -05:00
Simon Brugman
e83ed0ecba
Implement autofix for relative imports (TID252) ( #2739 )
2023-02-10 22:05:47 -05:00
Charlie Marsh
dadbfea497
Flag private member accesses on calls et al ( #2753 )
2023-02-10 19:23:22 -05:00
Nick Pope
9f84c497f9
Adjust heading level in rule documentation ( #2749 )
2023-02-10 19:10:42 -05:00
Martin Fischer
0ec25d1514
Rename dynamically-typed-expression to any-type ( #2751 )
2023-02-10 19:02:31 -05:00
Charlie Marsh
6a87c99004
Use explicit fields for implicit-namespace-package
2023-02-10 18:09:30 -05:00
Charlie Marsh
c8f60c9588
Improve implicit-namespace-package documentation
2023-02-10 18:06:48 -05:00
Charlie Marsh
113610a8d4
Improve hardcoded-sql-expression documentation
2023-02-10 18:03:01 -05:00
Charlie Marsh
6376e5915e
Improve dynamically-typed-expression documentation
2023-02-10 17:55:26 -05:00
Charlie Marsh
3d8fb5be20
Rewrite documentation for yield-in-init ( #2748 )
2023-02-10 17:49:55 -05:00
Charlie Marsh
0040991778
Respect NO_COLOR flags in --show-source ( #2750 )
2023-02-10 17:27:40 -05:00
Charlie Marsh
acb70520f8
Add colored environment variables to README ( #2746 )
2023-02-10 17:06:02 -05:00
Charlie Marsh
6eb9268675
Allow named unicodes in bidirectional escape check ( #2710 )
2023-02-10 16:59:28 -05:00
Charlie Marsh
e5f5142e3e
Improve yield-in-init documentation
2023-02-10 16:47:44 -05:00
Charlie Marsh
98d5ffb817
Fix __init__.py-to-__init__ in documentation
2023-02-10 16:30:36 -05:00
Charlie Marsh
3f20f73413
Use function_type::classify for yield-in-init ( #2742 )
2023-02-10 16:19:45 -05:00
tomecki
a5e42d2f7c
pylint: E0100 yield-in-init ( #2716 )
2023-02-10 16:15:15 -05:00
Charlie Marsh
0bc1f68111
Only trigger compound statements after select keywords ( #2737 )
2023-02-10 15:21:06 -05:00
Charlie Marsh
d2b09d77c5
Only validate __all__ bindings for global scope ( #2738 )
2023-02-10 15:16:21 -05:00
Charlie Marsh
0377834f9f
Mark __all__ members as used at end-of-scope ( #2733 )
2023-02-10 14:32:05 -05:00
Charlie Marsh
3d650f9dd6
Relax conditions in bad-string-format-type ( #2731 )
2023-02-10 14:25:59 -05:00
Charlie Marsh
a72590ecde
Expand S110 and S112 ranges to include entire exception handler ( #2729 )
2023-02-10 13:27:18 -05:00
Charlie Marsh
812b227334
Avoid flagging typed exceptions in tuples ( #2728 )
2023-02-10 13:24:45 -05:00
Martin Fischer
6f58717ba4
refactor: Stop including Rule::code() in pycodestyle .snap filenames
2023-02-10 13:15:47 -05:00
Florian Best
8aab96fb9e
feat(isort): Implement known-local-folder ( #2657 )
2023-02-10 13:15:34 -05:00
Nick Pope
9e6f7153a9
Handle more functions that never return in RET503 ( #2719 )
2023-02-10 12:09:05 -05:00
Peter Pentchev
cda2ff0b18
Handle functions that never return in RET503 ( #2701 )
2023-02-10 09:28:34 -05:00
Martin Fischer
ec63658250
Disallow rule names starting with avoid-*
2023-02-10 09:25:29 -05:00
Martin Fischer
1a97de0b01
Disallow rule names starting with uses-*
2023-02-10 09:25:29 -05:00
Martin Fischer
1cbe48522e
Disallow rule names ending in *-used
2023-02-10 09:25:29 -05:00
Martin Fischer
bfbde537af
Disallow rule names starting with do-not-*
2023-02-10 09:25:29 -05:00
Martin Fischer
cba91b758b
Add test for rule names
2023-02-10 09:25:29 -05:00
Martin Fischer
0bab642f5a
Describe rule naming convention in CONTRIBUTING.md
2023-02-10 09:25:29 -05:00
Martin Fischer
bd09a1819f
Drop unused once_cell dependency from ruff_macros
2023-02-10 09:25:29 -05:00
Martin Fischer
682d206992
refactor: Reduce code duplication
2023-02-10 08:24:22 -05:00
Martin Fischer
c32441e4ab
refactor: Use format! keyword arguments
2023-02-10 08:24:22 -05:00
Martin Fischer
6f16f1c39b
refactor: Reduce code duplication
2023-02-10 08:24:22 -05:00
Martin Fischer
9011456aa1
refactor: Simplify attribute handling in rule_code_prefix
...
if_all_same(codes.values().cloned()).unwrap_or_default()
was quite unreadable because it wasn't obvious that codes.values() are
the prefixes. It's better to introduce another Map rather than having
Maps within Maps.
2023-02-10 08:24:22 -05:00
Martin Fischer
fa191cceeb
refactor: Avoid implicit precondition
2023-02-10 08:24:22 -05:00
Charlie Marsh
ac6c3affdd
Remove public Rust API ( #2709 )
2023-02-09 23:16:49 -05:00
Charlie Marsh
9a018c1650
Import AutofixKind from violation
2023-02-09 23:06:02 -05:00
Charlie Marsh
0aef5c67a3
Remove src/registry.rs
2023-02-09 23:04:28 -05:00
Charlie Marsh
a048594416
Gate Path.readlink() behind Python 3.9+ guard ( #2708 )
2023-02-09 22:57:31 -05:00
Charlie Marsh
5437f1299b
Remove lifetimes from Printer ( #2704 )
2023-02-09 21:44:15 -05:00
Charlie Marsh
41c0608a69
Add test module a test-only module ( #2703 )
2023-02-09 21:28:10 -05:00
messense
eb0d42187f
Manage LibCST and RustPython with cargo workspace dependencies ( #2700 )
2023-02-09 20:49:50 -05:00
Colin Delahunty
48daa0f0ca
[pylint]: bad-string-format-type ( #2572 )
2023-02-09 20:08:56 -05:00
Charlie Marsh
417fe4355f
Add colors to statistics output ( #2699 )
2023-02-09 19:40:29 -05:00
Florian Best
a129181407
feat(cli): let --statistics show fixable codes ( #2659 )
2023-02-09 19:36:31 -05:00
Matt Oberle
fc628de667
Implement bandit's 'hardcoded-sql-expressions' S608 ( #2698 )
...
This is an attempt to implement `bandit` rule `B608` (renamed here `S608`).
- https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html
The rule inspects strings constructed via `+`, `%`, `.format`, and `f""`.
- `+` and `%` via `BinOp`
- `.format` via `Call`
- `f""` via `JoinedString`
Any SQL-ish strings that use Python string formatting are flagged.
The expressions and targeted expression types for the rule come from here:
- 7104b336d3/bandit/plugins/injection_sql.py
> Related Issue: https://github.com/charliermarsh/ruff/issues/1646
2023-02-09 19:28:17 -05:00
Charlie Marsh
9e2418097c
Run cargo dev generate-all
2023-02-09 19:14:02 -05:00
Charlie Marsh
d4e5639aaf
Add flake8-pyi to CONTRIBUTING.md
2023-02-09 19:04:55 -05:00
Steve Dignam
67e58a024a
Add flake8-pyi with one rule ( #2682 )
...
Add basic scaffold for [flake8-pyi](https://github.com/PyCQA/flake8-pyi ) and the first rule, Y001
rel: https://github.com/charliermarsh/ruff/issues/848
2023-02-09 19:03:11 -05:00
Charlie Marsh
233be0e074
Suppress parse errors with explicit # noqa: E999 directives ( #2697 )
2023-02-09 18:24:19 -05:00
Nick Pope
7750087f56
Remove duplicate documentation for TRY002 ( #2692 )
2023-02-09 12:08:00 -05:00
Charlie Marsh
7d5fb0de8a
Add documentation for mccabe, isort, and flake8-annotations ( #2691 )
2023-02-09 11:56:18 -05:00
Charlie Marsh
8a98cfc4b8
Treat re-exported annotations as used-at-runtime ( #2689 )
2023-02-09 11:22:15 -05:00
Charlie Marsh
54d1719424
Hide rule configuration settings on CLI ( #2687 )
2023-02-09 11:13:04 -05:00
Charlie Marsh
0f622f0126
Upgrade RustPython to pull in newline-handling optimizations ( #2688 )
2023-02-09 11:12:43 -05:00
Charlie Marsh
739a92e99d
Implement compound-statements (E701, E702, E703, E704) ( #2680 )
2023-02-08 22:57:39 -05:00
Charlie Marsh
5a07c9f57c
Only include rule links once in README ( #2678 )
2023-02-08 21:48:05 -05:00
Colin Delahunty
31027497c6
[flake8-bandit]: try-except-continue ( #2674 )
2023-02-08 21:44:01 -05:00
Charlie Marsh
dabfdf718e
Mark flake8-simplify rules as unfixable in non-fixable cases ( #2676 )
2023-02-08 21:28:28 -05:00
Charlie Marsh
5829bae976
Support callable decorators in classmethod_decorators et al ( #2675 )
2023-02-08 21:11:36 -05:00
Charlie Marsh
ff3665a24b
Mark RUF005 as fixable
2023-02-08 18:02:33 -05:00
Charlie Marsh
125615af12
Bump version to 0.0.244
2023-02-08 17:28:59 -05:00
Charlie Marsh
6339f8e009
Use separate exit codes for fatal errors vs. lint errors ( #2670 )
2023-02-08 15:21:15 -05:00
Charlie Marsh
81abc5d7d8
Move error and warning messages into log macro ( #2669 )
2023-02-08 14:39:09 -05:00
Charlie Marsh
75fad989f4
Add --exit-non-zero-on-fix ( #2668 )
2023-02-08 14:27:54 -05:00
Charlie Marsh
cb4a221905
Treat annotated assignments in class and module scopes as runtime ( #2667 )
2023-02-08 13:59:25 -05:00
Charlie Marsh
286d8c18dd
Remove ExprKind::Call from call path collection ( #2666 )
2023-02-08 13:35:18 -05:00
Florian Best
124461bddf
test(UP003): let type reference be the builtin ( #2664 )
2023-02-08 12:44:37 -05:00
Charlie Marsh
7482a4a5b8
Avoid false-positive in chained type calls ( #2663 )
2023-02-08 12:18:36 -05:00
Charlie Marsh
9f9f25ff7c
Accommodate multiple @pytest.mark.parametrize decorators ( #2662 )
2023-02-08 11:13:24 -05:00
Nuno Mendes
9cd1bf9c03
doc: add documentation for TRY002 ( #2655 )
2023-02-08 11:04:31 -05:00
Florian Best
3862dc2626
docs: use new command line arguments ( #2658 )
2023-02-08 10:36:53 -05:00
Charlie Marsh
2a0927a5ef
Update Discord link
2023-02-08 04:36:59 -05:00
Charlie Marsh
824c0d2680
Implement whitespace-before-comment (E261, E262, E265, E266) ( #2654 )
2023-02-07 23:41:32 -05:00
Charlie Marsh
f5efdd058e
Implement whitespace-around-keywords (E271, E272, E273, E274) ( #2653 )
2023-02-07 22:31:13 -05:00
Charlie Marsh
4c35feaa18
Add documentation for eradicate, flake8-import-conventions, and flake8-no-pep420 ( #2652 )
2023-02-07 22:19:21 -05:00
Charlie Marsh
8261d0656e
Disable autofix for flake8-print rules ( #2651 )
2023-02-07 21:38:57 -05:00
Charlie Marsh
a9aa96b24f
Add documentation for flake8-quotes rules ( #2650 )
2023-02-07 21:20:24 -05:00
Charlie Marsh
367f115d83
Add color to fixable error asterisk ( #2647 )
2023-02-07 19:12:18 -05:00
Charlie Marsh
56398e0002
Tweak format for rule explanations ( #2645 )
2023-02-07 19:02:41 -05:00
Ville Skyttä
4b49fd9494
Ignore all non-.py wrt. implicit namespace package ( #2640 )
...
It's not only `.pyi` that should be exempt for this, but also for example scripts which don't have an extension, explicitly passed in command line args.
2023-02-07 18:21:59 -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
8fd29b3b60
Remove dependency on "unparse" feature ( #2641 )
2023-02-07 17:23:09 -05:00
Charlie Marsh
e427171323
Unify imports from rustpython_parser::ast ( #2639 )
2023-02-07 16:54:50 -05:00
Charlie Marsh
be08384fb0
Run cargo dev generate-all
2023-02-07 16:48:06 -05:00
Charlie Marsh
2f7f4943e3
Rename some local variables
2023-02-07 16:24:53 -05:00
Charlie Marsh
67e9ff7cc8
Reorder imports ( #2638 )
2023-02-07 16:22:47 -05:00
Charlie Marsh
0355ba571e
Skip ternary fixes for yields and awaits ( #2637 )
2023-02-07 15:18:52 -05:00
Charlie Marsh
38db7fd114
Avoid boolean-trap errors in __setitem__ ( #2636 )
2023-02-07 15:04:33 -05:00
Charlie Marsh
8ee51eb5c6
Treat @staticmethod as higher-precedence than ABC ( #2635 )
2023-02-07 14:57:03 -05:00
Aarni Koskela
2bc16eb4e3
flake8-annotations: add ignore-fully-untyped ( #2128 )
...
This PR adds a configuration option to inhibit ANN* violations for functions that have no other annotations either, for easier gradual typing of a large codebase.
2023-02-07 11:35:57 -05:00
Charlie Marsh
4e36225145
Avoid no-unnecessary-dict-kwargs errors with reserved keywords ( #2628 )
2023-02-07 11:25:09 -05:00
Charlie Marsh
850069d0aa
Avoid non-recursion in nested typing function calls ( #2627 )
2023-02-07 11:21:49 -05:00
Charlie Marsh
9fa98ed90b
Accommodate pos-only arguments when checking self name ( #2626 )
2023-02-07 10:50:50 -05:00
Charlie Marsh
2b4ce78830
Delete unreferenced snapshots ( #2619 )
2023-02-06 23:22:41 -05:00
Colin Delahunty
7647cafe12
[pylint]: bidirectional-unicode ( #2589 )
2023-02-06 22:49:18 -05:00
Charlie Marsh
7686179318
Remove unused src/registry.rs
2023-02-06 22:43:25 -05:00
Charlie Marsh
bf718fdf26
Bump Ruff version to 0.0.243
2023-02-06 21:22:54 -05:00
Steve Dignam
3b3466f6da
Add flake8-pie single_starts_ends_with ( #2616 )
2023-02-06 21:22:32 -05:00
Charlie Marsh
f981f491aa
Support ignore-names for all relevant pep8-naming rules ( #2617 )
2023-02-06 21:14:55 -05:00
Charlie Marsh
95fef43c4d
Add some additional tests for relative imports
2023-02-06 21:13:23 -05:00
Charlie Marsh
097c679cf3
Support relative paths for typing-modules ( #2615 )
2023-02-06 19:51:37 -05:00
Charlie Marsh
3bca987665
Avoid removing quotes from runtime annotations ( #2614 )
2023-02-06 18:15:19 -05:00
Ville Skyttä
60ee1d2c17
fix(pep8-naming): typing.NamedTuple and typing.TypedDict treatment ( #2611 )
2023-02-06 17:11:37 -05:00
Charlie Marsh
2dd04dd6a3
Check in updated snapshot
2023-02-06 16:34:47 -05:00
Charlie Marsh
e59b75d31b
Bump version to 0.0.242
2023-02-06 16:25:29 -05:00
Charlie Marsh
610f150dd1
Remove autofix from bad-str-strip-call; add suggestions instead ( #2610 )
2023-02-06 16:25:20 -05:00
Charlie Marsh
cee0d0abaa
Check in updated snapshot
2023-02-06 15:48:23 -05:00
Charlie Marsh
12ed1837ee
Ignore typos in snapshots ( #2609 )
2023-02-06 15:43:03 -05:00
Colin Delahunty
6272293180
[pylint]: bad-str-strip-call (With Autofix) ( #2570 )
2023-02-06 15:34:37 -05:00
Charlie Marsh
f8b8b05b80
Visit deferred assignments after deferred type annotations ( #2607 )
2023-02-06 14:40:41 -05:00
Charlie Marsh
79776c12e2
Allow blank line before sticky-comment functions in docstrings ( #2597 )
2023-02-05 18:48:29 -05:00
Charlie Marsh
7fa5ce8b63
Automatically remove empty type-checking blocks ( #2598 )
2023-02-05 18:46:07 -05:00
Charlie Marsh
f6864a96f6
Enable autofix for unnecessary-paren-on-raise-exception ( #2596 )
2023-02-05 18:19:27 -05:00
Charlie Marsh
291ef9856a
Remove unnecessary super_args.rs ( #2594 )
2023-02-05 18:02:09 -05:00
Charlie Marsh
87d0aa5561
Move python into its own ruff_python crate ( #2593 )
2023-02-05 17:53:58 -05:00
Charlie Marsh
ecc9f5de99
Fix accidental setup.py changes
2023-02-05 17:18:11 -05:00
Charlie Marsh
f40b974206
Add a description of project structure ( #2590 )
2023-02-05 17:01:09 -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
Charlie Marsh
e3dfa2e04e
Implement pycodestyle's logical line detection ( #1130 )
...
Along with the logical line detection, this adds 14 of the missing `pycodestyle` rules.
For now, this is all gated behind a `logical_lines` feature that's off-by-default, which will let us implement all rules prior to shipping, since we want to couple the release of these rules with new defaults and instructions.
2023-02-05 15:06:02 -05:00
Ville Skyttä
f03c8fff14
fix(commented-out-code): mypy and SPDX-License-Identifier false positives ( #2587 )
...
https://mypy.readthedocs.io/en/stable/inline_config.html#configuration-comment-format
https://spdx.github.io/spdx-spec/v2.3/using-SPDX-short-identifiers-in-source-files/#e2-format-for-spdx-license-identifier
2023-02-05 15:04:36 -05:00
Charlie Marsh
452b5a4b79
Propagate attribute-like macros in define_rule_mapping ( #2583 )
...
This enables us to feature-flag rules, like:
```rust
ruff_macros::define_rule_mapping!(
#[cfg(feature = "logical_lines")]
E111 => rules::pycodestyle::rules::IndentationWithInvalidMultiple,
...
)
```
2023-02-05 12:26:23 -05:00
Colin Delahunty
1e1dc3a7ed
[pyupgrade]: Removes quotes from annotations ( #2431 )
2023-02-05 09:43:09 -05:00
Charlie Marsh
84be1df9d5
Avoid infinite renames for unused-loop-control-variable ( #2581 )
2023-02-05 08:01:07 -05:00
Florian Best
6b3ae1a8e1
fix: fix syntax error in Python test COM81 ( #2575 )
2023-02-05 07:11:46 -05:00
Colin Delahunty
5275f6c90e
Allows UP030 to work better with *args and **kwargs ( #2568 )
2023-02-04 17:34:48 -05:00
Anders Kaseorg
6683ed49bc
Portably find ruff binary path from Python ( #2574 )
...
Prefer the version from a currently active virtualenv over a version
from `pip install --user`. Add the .exe extension on Windows, and
find the path for `pip install --user` correctly on Windows.
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-02-04 17:19:27 -05:00
Chris Chan
ced55084db
Implement pylint's too-many-return-statements rule (PLR0911) ( #2564 )
2023-02-04 16:56:36 -05:00
Chris Chan
f8f36a7ee0
Implement pylint's too-many-branches rule (PLR0912) ( #2550 )
2023-02-04 16:38:03 -05:00
Charlie Marsh
4190031618
Run cargo fmt
2023-02-04 08:36:57 -05:00
Matteo Vitali
5a9258327b
Fix python module invocation ( #2563 )
2023-02-04 08:23:13 -05:00
Charlie Marsh
dd0145624b
Ignore direct root-children in implicit-namespace-package ( #2565 )
2023-02-04 08:21:24 -05:00
Charlie Marsh
7d4f0a8320
Bump Ruff version to 0.0.241
2023-02-03 19:25:12 -05:00
Charlie Marsh
4149bc7be8
Ignore direct source-children in implicit-namespace-package ( #2560 )
2023-02-03 19:20:27 -05:00
Pierre Sassoulas
e6316b185e
[pylint] Rename 'too-many-args' to 'too-many-arguments'
...
The actual name
2023-02-03 18:58:32 -05:00
Pierre Sassoulas
a2183be96e
[pylint] Rename constant-comparison to comparison-of-constant
...
The actual name
2023-02-03 18:58:32 -05:00
Pierre Sassoulas
df39a95925
[pylint] Rename use-sys-exit to consider-using-sys-exit
...
The actual name
2023-02-03 18:58:32 -05:00
Charlie Marsh
ff859ead85
Remove unused misplaced_comparison_constant.rs file
2023-02-03 17:10:48 -05:00
Charlie Marsh
b2be30cb07
Mark fixable issues in printer output ( #2500 )
2023-02-03 16:26:06 -05:00
Charlie Marsh
b9c1a3c5c1
Move benchmarking instructions to CONTRIBUTING.md ( #2554 )
2023-02-03 14:53:53 -05:00
Charlie Marsh
9751951d10
Allow F811 noqa declarations on containing import lines ( #2553 )
2023-02-03 14:51:06 -05:00
Charlie Marsh
64c79bde83
Mark sometimes-fixable rules as Availability::Sometimes ( #2552 )
2023-02-03 14:42:10 -05:00
Charlie Marsh
da0374f360
Update RustPython to pull in lexer optimizations ( #2551 )
2023-02-03 14:31:53 -05:00
Charlie Marsh
c26b58ba28
Hide globset logging even with --verbose
2023-02-03 13:31:04 -05:00
Charlie Marsh
56f935640a
Avoid hang when detecting trailing comments ( #2549 )
2023-02-03 13:05:55 -05:00
Charlie Marsh
85ca6cde49
Fix a few nursery rule violations ( #2548 )
2023-02-03 11:59:29 -05:00
Aarni Koskela
38addbe50d
Soft-deprecate update_check ( #2530 )
2023-02-03 11:33:38 -05:00
Charlie Marsh
924e35b1c3
Add print_stdout and print_stderr to Clippy enforcement ( #2542 )
2023-02-03 11:13:44 -05:00
Charlie Marsh
d05ea4dbac
Exit upon showing files with --show-files ( #2543 )
2023-02-03 09:41:09 -05:00
Charlie Marsh
b5ac93d2ee
Move Clippy configuration to config.toml ( #2541 )
2023-02-03 09:26:36 -05:00
Aarni Koskela
924e264156
Move flake8-{errmsg,print} violations ( #2536 )
2023-02-03 09:03:49 -05:00
Aarni Koskela
14c5000ad5
Move McCabe violations ( #2534 )
2023-02-03 08:41:11 -05:00
Aarni Koskela
d985473f4f
Move pygrep-hooks violations ( #2539 )
2023-02-03 08:41:05 -05:00
Aarni Koskela
47e0b2521a
Move flake8-2020 violations ( #2537 )
2023-02-03 08:40:56 -05:00
Aarni Koskela
a319980a7c
Move pep8-naming violations ( #2538 )
2023-02-03 08:40:48 -05:00
Aarni Koskela
3336dd63f4
Move flake8-implicit-str-concat violations ( #2535 )
2023-02-03 08:24:06 -05:00
Aarni Koskela
ae20a721a1
Don't walk past project root when figuring out exclusion ( #2471 )
2023-02-03 08:23:51 -05:00
Aarni Koskela
a26b1f43e9
Move flake8-unused-arguments violations ( #2533 )
2023-02-03 08:19:18 -05:00
Chris Chan
139a6d8331
Minor fixes to PLR0915 logic ( #2518 )
2023-02-03 08:10:59 -05:00
Jacob Coffee
04ef674195
Add Jetbrains Webinar Event (Temporary) ( #2516 )
2023-02-03 08:08:27 -05:00
Aarni Koskela
db852a0b11
Move ruff violations ( #2526 )
2023-02-03 07:43:39 -05:00
Aarni Koskela
87c3b0e4e2
Move pydocstyle violations ( #2524 )
2023-02-03 07:42:52 -05:00
Aarni Koskela
82784a7607
Move flake8-debugger violation ( #2522 )
2023-02-03 07:40:53 -05:00
Aarni Koskela
f2da855048
Move flake8-datetimez violations ( #2528 )
2023-02-03 07:40:00 -05:00
Aarni Koskela
81b60cf9fe
Move flake8-bandit violations ( #2525 )
2023-02-03 07:39:49 -05:00
Maksudul Haque
c96ba6dec4
[flake8-self] Fix False Negative Issue on Rule SLF001 ( #2527 )
2023-02-03 07:39:24 -05:00
Martin Fischer
0f8f250bea
refactor: Simplify UpstreamCategory
...
There's no need to hardcode the prefix string since
it can be derived from the RuleCodePrefix.
2023-02-02 23:46:32 -05:00
Martin Fischer
a3ffaa5d9b
refactor: Rename LinterCategory to UpstreamCategory
...
LinterCategory was somewhat misnamed since it's not actually
a category for linters but rather a category for upstream lints.
Since we want to introduce our own categories, naming the type
UpstreamCategory is more clear.
2023-02-02 23:46:32 -05:00
Martin Fischer
187ed874e9
refactor: Make Rule::from_code return Rule instead of &'static Rule
2023-02-02 23:46:32 -05:00
Charlie Marsh
a30c77e752
Mark --add-noqa as incompatible with --fix ( #2513 )
2023-02-02 23:43:05 -05:00
Florian Best
7e9b9cc7b3
feat: add autofix for PLR0402 ( #2504 )
2023-02-02 23:25:16 -05:00
Charlie Marsh
d4cef9305a
Track overridden bindings within each scope ( #2511 )
2023-02-02 22:31:46 -05:00
Charlie Marsh
a074625121
Avoid renaming unused loop variables with deferred usages ( #2509 )
2023-02-02 20:59:47 -05:00
Charlie Marsh
9c55ab35df
Change LogLevel comments to docs
2023-02-02 20:23:10 -05:00
Charlie Marsh
a95474f2b1
Use a copy-on-write to avoid extra contents clone ( #2508 )
2023-02-02 20:19:16 -05:00
Víctor
3e6fe46bc4
Add number of files processed in debug info (-v) ( #2506 )
2023-02-02 20:19:00 -05:00
Charlie Marsh
bc81cea4f4
Notify user if autofix introduces syntax error ( #2507 )
2023-02-02 20:02:09 -05:00
Charlie Marsh
cb0f226962
Always report parse errors back to the user ( #2505 )
2023-02-02 19:12:17 -05:00
Charlie Marsh
fa56fabed9
Remove a result wrapper from linter.rs ( #2503 )
2023-02-02 18:47:45 -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
Charlie Marsh
ee01e666c5
Allow list() and tuple() calls in __all__ assignments ( #2499 )
2023-02-02 15:45:14 -05:00
Jonathan Plasse
2b0de8ccd9
Fix clippy error ( #2498 )
2023-02-02 15:38:18 -05:00
Aarni Koskela
739c57b31b
Move flake8-annotations violations to rules file ( #2496 )
2023-02-02 15:17:54 -05:00
Aarni Koskela
c3e0137f22
Move flake8-return violations to rules module ( #2492 )
2023-02-02 15:13:49 -05:00
Aarni Koskela
77716108af
Move flake8-simplify violations to rule modules ( #2495 )
2023-02-02 15:13:16 -05:00
Jonathan Plasse
335395adec
Mirror CI clippy command for pre-commit hook ( #2494 )
2023-02-02 14:59:19 -05:00
Aarni Koskela
65f8f1a6f7
Move pylint violations to rule modules ( #2489 )
2023-02-02 14:47:58 -05:00
Aarni Koskela
858af8debb
Move pyupgrade violations to rule modules ( #2490 )
2023-02-02 14:47:43 -05:00
Aarni Koskela
5f1bbf0b6b
Move pycodestyle violations to rule modules ( #2483 )
2023-02-02 14:29:23 -05:00
Aarni Koskela
40cb905ae5
Move pyflakes violations to rule modules ( #2488 )
2023-02-02 14:00:59 -05:00
Jonathan Plasse
e89b4a5de5
Fix hardcoded url in transform_readme.py ( #2487 )
2023-02-02 13:59:22 -05:00
Charlie Marsh
651f6b6bce
Bump Ruff version to 0.0.240
2023-02-02 12:45:23 -05:00
Charlie Marsh
d3c3198b24
Fix versions in BREAKING_CHANGES.md
2023-02-02 12:45:20 -05:00
Charlie Marsh
ec6054edce
Treat if 0: and if False: as type-checking blocks ( #2485 )
2023-02-02 12:35:59 -05:00
Charlie Marsh
a0df78cb7d
Visit NamedExpr values before targets ( #2484 )
2023-02-02 12:21:58 -05:00
Aarni Koskela
ac41c33d1f
Move flake8-blind-except violation to rule module ( #2479 )
2023-02-02 12:21:25 -05:00
Aarni Koskela
b4b8782243
Move remaining flake8-pytest-style violations to rule modules ( #2482 )
2023-02-02 12:10:49 -05:00
Florian Best
8e53a4d1d3
fix: assertTrue()/assertFalse() fixer should not test for identity ( #2476 )
2023-02-02 11:24:35 -05:00
Charlie Marsh
668860cba3
Add more information to Pylint FAQ section
2023-02-02 11:08:17 -05:00
Aarni Koskela
038e8cfba0
Move flake8-quotes violations to rules module ( #2475 )
2023-02-02 10:08:12 -05:00
Aarni Koskela
ebfa55cea3
Move flake8-builtins violations to rules file ( #2478 )
2023-02-02 10:03:09 -05:00
Aarni Koskela
aa0fc0f9c2
Move flake8-bugbear violations to rule modules ( #2474 )
2023-02-02 09:34:26 -05:00
Aarni Koskela
aa85c81280
Move flake8-comprehensions violations to rule files ( #2477 )
2023-02-02 09:26:50 -05:00
Charlie Marsh
f5fd6f59ea
Remove extraneous test file
2023-02-02 08:46:03 -05:00
Martin Fischer
540e31f5f4
Carry-over ignore to next config layer if select = [] ( #2467 )
...
Resolves #2461 .
2023-02-02 08:45:07 -05:00
Chris Chan
8136cc9238
Implement pylint's too-many-statements rule (PLR0915) ( #2445 )
2023-02-02 08:18:37 -05:00
Charlie Marsh
2c71535016
Update snapshots
2023-02-02 08:15:33 -05:00
Aarni Koskela
cce8fb9882
isort: support forced_separate ( #2268 )
2023-02-02 08:08:02 -05:00
Maksudul Haque
9e59c99133
[flake8-self] Add Plugin and Rule SLF001 ( #2470 )
2023-02-02 07:58:14 -05:00
Colin Delahunty
b032f50775
[pyupgrade]: Remove outdated sys.version_info blocks ( #2099 )
2023-02-02 07:49:24 -05:00
Charlie Marsh
1c2fc38853
Use LibCST to reverse Yoda conditions ( #2468 )
...
Our existing solution was having trouble with parenthesized expressions. This actually may affect more than `SIM300`, but let's address them as they come up.
Closes #2466 .
2023-02-02 00:07:43 -05:00
Charlie Marsh
f16f3a4a03
Avoid removing un-selected codes when applying --add-noqa edits ( #2465 )
...
The downside here is that we have to leave blank `# noqa` directives intact. Otherwise, we risk removing necessary `# noqa` coverage for rules that aren't selected.
Closes #2254 .
2023-02-01 22:22:31 -05:00
Charlie Marsh
30a09ec211
Respect parent noqa in --add-noqa ( #2464 )
2023-02-01 21:58:01 -05:00
Reid Swan
ec7b25290b
feat: Add isort option lines-after-imports ( #2440 )
...
Fixes https://github.com/charliermarsh/ruff/issues/2243
Adds support for the isort option [lines_after_imports](https://pycqa.github.io/isort/docs/configuration/options.html#lines-after-imports ) to insert blank lines between imports and the follow up code.
2023-02-01 21:39:45 -05:00
Charlie Marsh
68422d4ff2
Allow non-ruff.toml-named files for --config ( #2463 )
...
Previously, if you passed in a file on the command-line via `--config`, it had to be named either `pyproject.toml` or `ruff.toml` -- otherwise, we errored. I think this is too strict. `pyproject.toml` is a special name in the ecosystem, so we should require _that_; but otherwise, let's just assume it's in `ruff.toml` format.
As an alternative, we could add a `--pyproject` argument for `pyproject.toml`, and assume anything passed to `--config` is in `ruff.toml` format. But that _would_ be a breaking change and is arguably more confusing. (This isn't a breaking change, since it only loosens the CLI.)
Closes #2462 .
2023-02-01 21:35:42 -05:00
Charlie Marsh
2abaffd65b
Improve consistency of backticks for plugin names ( #2460 )
2023-02-01 19:17:32 -05:00
Charlie Marsh
06cbf5a2ae
Add some top-level links to the README ( #2458 )
2023-02-01 19:10:41 -05:00
Charlie Marsh
f432ce291a
Add Fathom to docs
2023-02-01 18:41:24 -05:00
Charlie Marsh
1eb331143d
Add Fathom to playground
2023-02-01 18:30:40 -05:00
Henry Schreiner
db1b1672b8
fix: minor spacing typo in message for PTH123 ( #2453 )
2023-02-01 14:39:50 -05:00
Charlie Marsh
6861e59103
Only avoid PEP604 rewrites for pre-Python 3.10 code ( #2449 )
...
I moved the `self.in_annotation` guard out of the version check in #1563 . But, I think that was a mistake. It was done to resolve #1560 , but the fix in that case _should've_ been to set a different Python version.
Closes #2447 .
2023-02-01 13:03:51 -05:00
Charlie Marsh
778c644ee3
Trigger, but don't fix, SIM rules if comments are present ( #2450 )
2023-02-01 12:56:02 -05:00
Martin Fischer
e66a6b6d05
refactor: Define ruff_dev::ROOT_DIR
2023-02-01 09:17:53 -05:00
Martin Fischer
faea478ca5
fix: failing snapshot test on Windows
2023-02-01 09:17:53 -05:00
Martin Fischer
39b5fa0e24
refactor: Make test_path prefix the fixture path
2023-02-01 09:17:53 -05:00
Martin Fischer
df413d1ece
refactor: Introduce test_resource_path helper
2023-02-01 09:17:53 -05:00
Martin Fischer
cfd0693ae5
refactor: Document internal test_path function
2023-02-01 09:17:53 -05:00
Martin Fischer
56ad160c05
refactor: Move test_path helper to new test module
2023-02-01 09:17:53 -05:00
Florian Best
9d8c6ba671
more builtin name checks when autofixing ( #2430 )
2023-02-01 08:16:47 -05:00
Charlie Marsh
1ea88ea56b
Avoid iterating over body twice ( #2439 )
2023-02-01 08:12:36 -05:00
Florian Best
7f44ffb55c
docs(CONTRIBUTING): add instructions how to update the test snapshots ( #2412 )
2023-02-01 07:44:20 -05:00
Charlie Marsh
dbd640d90f
Remove unused Cargo.lock file ( #2437 )
2023-02-01 07:33:59 -05:00
Aarni Koskela
e5082c7d6c
isort: split up package ( #2434 )
2023-02-01 07:17:31 -05:00
Charlie Marsh
841d176289
Move super-args and unnecessary-coding-comment into their own modules ( #2432 )
2023-01-31 22:26:56 -05:00
Charlie Marsh
c15595325c
Bump version to 0.0.239
2023-01-31 19:06:22 -05:00
Florian Best
e97b1a4280
fix: ignore fix if "bool" is not builtin ( #2429 )
2023-01-31 19:03:46 -05:00
Florian Best
82ec884a61
feat: let SIM210 return expressions without bool() wrapping ( #2410 ) ( #2426 )
2023-01-31 18:25:22 -05:00
Maksudul Haque
7c1a6bce7b
[flake8-raise] Add Plugin and RSE102 Rule ( #2354 )
2023-01-31 18:09:40 -05:00
Charlie Marsh
84a8b628b8
Avoid implicit-namespace-package checks for .pyi files ( #2420 )
2023-01-31 17:35:30 -05:00
Charlie Marsh
142b627bb8
Avoid Bandit false-positives for empty-string-as-password ( #2421 )
2023-01-31 16:56:03 -05:00
Charlie Marsh
fbf231e1b8
Allow implicit multiline strings with internal quotes to use non-preferred quote ( #2416 )
...
As an example, if you have `single` as your preferred style, we'll now allow this:
```py
assert s.to_python(123) == (
"123 info=SerializationInfo(include=None, exclude=None, mode='python', by_alias=True, exclude_unset=False, "
"exclude_defaults=False, exclude_none=False, round_trip=False)"
)
```
Previously, the second line of the implicit string concatenation would be flagged as invalid, despite the _first_ line requiring double quotes. (Note that we'll accept either single or double quotes for that second line.)
Mechanically, this required that we process sequences of `Tok::String` rather than a single `Tok::String` at a time. Prior to iterating over the strings in the sequence, we check if any of them require the non-preferred quote style; if so, we let _any_ of them use it.
Closes #2400 .
2023-01-31 16:27:15 -05:00
Florian Best
1dd9ccf7f6
feat: let SIM103 return expressions without bool() wrapping ( #2410 )
2023-01-31 16:11:44 -05:00
Charlie Marsh
d601abe01b
Rename flake8-quotes snapshots and tests ( #2415 )
2023-01-31 16:08:00 -05:00
Charlie Marsh
15d4774b6b
Avoid flagging same-condition cases in SIM103 ( #2404 )
2023-01-31 12:45:51 -05:00
Charlie Marsh
293c7e00d5
Include method name in B027 message ( #2403 )
2023-01-31 12:41:22 -05:00
Thomas M Kehrenberg
c3a3195922
Fix option name "max-args" in the documentation ( #2401 )
2023-01-31 12:30:05 -05:00
Martin Fischer
39d98d3488
Disable panic hook about reporting issues for debug builds
...
In order to avoid confusing new developers. When a debug build panics
chances are that the panic is caused by local changes and should in
fact not be reported on GitHub.
2023-01-31 12:24:26 -05:00
Charlie Marsh
cd3d82213a
Handle multi-byte lines in RUF100 ( #2392 )
2023-01-31 07:59:16 -05:00
Charlie Marsh
a9a0026f2f
Don't panic for --statistics with no errors ( #2391 )
2023-01-31 07:53:29 -05:00
Hassan Kibirige
da4618d77b
For neovim:null_ls use ruff builtin for formatting ( #2386 )
...
null_ls picked up the recommended snippet in README.md and ruff formatting now a builtin.
Ref:
1. 482990e391
2. 7b2b28e207/doc/BUILTINS.md (ruff-1)
2023-01-31 07:22:14 -05:00
Martin Fischer
1b0748d19d
refactor: Simplify Linter::categories
2023-01-31 07:21:12 -05:00
Martin Fischer
0b7fa64481
refactor: Drop PartialOrd & Ord impls for RuleSelector
...
RuleSelector implemented PartialOrd & Ord because ruff::flake8_to_ruff
was using RuleSelector within a BTreeSet (which requires contained
elements to implement Ord). There however is no inherent order to
rule selectors, so PartialOrd & Ord should not be implemented.
This commit changes BTreeSet<RuleSelector> to HashSet<RuleSelector>
and adds an explicit sort calls based on the serialized strings,
letting us drop the PartialOrd & Ord impls in favor of a Hash impl.
2023-01-31 07:21:12 -05:00
Samuel Cormier-Iijima
09d593b124
[I001] fix isort check for files with tabs and no indented blocks ( #2374 )
...
This is a followup to #2361 . The isort check still had an issue in a rather specific case: files with a multiline import, indented with tabs, and not containing any indented blocks.
The root cause is this: [`Stylist`'s indentation detection](ad8693e3de/src/source_code/stylist.rs (L163-L172) ) works by finding `Indent` tokens to determine the type of indentation used by a file. This works for indented code blocks (loops/classes/functions/etc) but does not work for multiline values, so falls back to 4 spaces if the file doesn't contain code blocks.
I considered a few possible solutions:
1. Fix `detect_indentation` to avoid tokenizing and instead use some other heuristic to determine indentation. This would have the benefit of working in other places where this is potentially an issue, but would still fail if the file doesn't contain any indentation at all, and would need to fall back to option 2 anyways.
2. Add an option for specifying the default indentation in Ruff's config. I think this would confusing, since it wouldn't affect the detection behavior and only operate as a fallback, has no other current application and would probably end up being overloaded for other things.
3. Relax the isort check by comparing the expected and actual code's lexed tokens. This would require an additional lexing step.
4. Relax the isort check by comparing the expected and actual code modulo whitespace at the start of lines.
This PR does approach 4, which in addition to being the simplest option, has the (expected, although I didn't benchmark) added benefit of improved performance, since the check no longer needs to do two allocations for the two `dedent` calls. I also believe that the check is still correct enough for all practical purposes.
2023-01-31 07:18:54 -05:00
Erik Welch
adc134ced0
Fix typos: s/scripy/scipy/g ( #2380 )
2023-01-31 07:17:18 -05:00
Charlie Marsh
6051a0c1c8
Include per-file ignore matches in debug logging ( #2376 )
2023-01-30 23:11:56 -05:00
Charlie Marsh
00495e8620
Use human-readable types for documentation values ( #2375 )
2023-01-30 23:05:28 -05:00
Colin Delahunty
ad8693e3de
[pyupgrade] Implement import-replacement rule (UP035) ( #2049 )
2023-01-30 19:58:28 -05:00
Charlie Marsh
69e20c4554
Minor improvements to the docs ( #2371 )
2023-01-30 19:06:05 -05:00
Charlie Marsh
b5816634b3
Add a link to MkDocs ( #2370 )
2023-01-30 19:00:57 -05:00
Charlie Marsh
e8810eae64
Fix version number in BREAKING_CHANGES.md
2023-01-30 18:49:11 -05:00
Charlie Marsh
ba26a60e2a
Disable incompatible rules rather than merely warning ( #2369 )
...
This is another temporary fix for the problem described in #2289 and #2292 . Rather than merely warning, we now disable the incompatible rules (in addition to the warning). I actually think this is quite a reasonable solution, but we can revisit later. I just can't bring myself to ship another release with autofix broken-by-default 😂
2023-01-30 18:47:05 -05:00
Charlie Marsh
42459c35b0
Update BREAKING_CHANGES.md
2023-01-30 17:50:26 -05:00
Charlie Marsh
1cbd929a0a
Bump version to 0.0.238
2023-01-30 16:44:19 -05:00
Charlie Marsh
5f07e70762
Recommend disabling explicit-string-concatenation ( #2366 )
...
If `allow-multiline = false` is set, then if the user enables `explicit-string-concatenation` (`ISC003`), there's no way for them to create valid multiline strings. This PR notes that they should turn off `ISC003`.
Closes #2362 .
2023-01-30 16:42:30 -05:00
Charlie Marsh
8963a62ec0
Refine criteria for exc_info logger rules ( #2364 )
...
We now only trigger `logging-exc-info` and `logging-redundant-exc-info` when in an exception handler, with an `exc_info` that isn't `true` or `sys.exc_info()`.
Closes #2356 .
2023-01-30 16:32:00 -05:00
Charlie Marsh
4589daa0bd
Ignore magic comparisons to bytes by default ( #2365 )
2023-01-30 16:31:48 -05:00
Charlie Marsh
ea0274d22c
Use bold for deprecated
2023-01-30 16:28:21 -05:00
Charlie Marsh
ca1129ad27
Document new rule config resolution
2023-01-30 16:26:59 -05:00
Martin Fischer
104c63afc6
Exclude deprecated extend-ignore from the JSON schema
...
Now that the option is deprecated we no longer
want IDEs to suggest it in their autocompletion.
2023-01-30 16:26:59 -05:00
Martin Fischer
ba457c21b5
Improve rule config resolution
...
Ruff allows rules to be enabled with `select` and disabled with
`ignore`, where the more specific rule selector takes precedence,
for example:
`--select ALL --ignore E501` selects all rules except E501
`--ignore ALL --select E501` selects only E501
(If both selectors have the same specificity ignore selectors
take precedence.)
Ruff always had two quirks:
* If `pyproject.toml` specified `ignore = ["E501"]` then you could
previously not override that with `--select E501` on the command-line
(since the resolution didn't take into account that the select was
specified after the ignore).
* If `pyproject.toml` specified `select = ["E501"]` then you could
previously not override that with `--ignore E` on the command-line
(since the resolution didn't take into account that the ignore was
specified after the select).
Since d067efe265 (#1245 )
`extend-select` and `extend-ignore` always override
`select` and `ignore` and are applied iteratively in pairs,
which introduced another quirk:
* If some `pyproject.toml` file specified `extend-select`
or `extend-ignore`, `select` and `ignore` became pretty much
unreliable after that with no way of resetting that.
This commit fixes all of these quirks by making later configuration
sources take precedence over earlier configuration sources.
While this is a breaking change, we expect most ruff configuration
files to not rely on the previous unintutive behavior.
2023-01-30 16:26:59 -05:00
Martin Fischer
a92958f941
Test that more specific select wins over less specific ignore
2023-01-30 16:26:59 -05:00
Martin Fischer
1cd206285e
refactor: test impl From<&Configuration> for RuleTable
...
Previously we tested the resolve_codes helper function directly.
Since we want to rewrite our resolution logic in the next commit,
this commit changes the tests to test the more high-level From impl.
2023-01-30 16:26:59 -05:00
Samuel Cormier-Iijima
5ac5b69e9f
[I001] fix isort for files with tab-based indentation ( #2361 )
...
This PR fixes two related issues with using isort on files using tabs for indentation:
- Multiline imports are never considered correctly formatted, since the comparison with the generated code will always fail.
- Using autofix generates code that can have mixed indentation in the same line, for imports that are within nested blocks.
2023-01-30 15:36:19 -05:00
Charlie Marsh
01fedec1e7
Add SciPy and meson-python ( #2363 )
2023-01-30 15:34:19 -05:00
Martin Fischer
ef20692149
fix: clap usage for CLI help generation in the README ( #2358 )
2023-01-30 13:14:40 -05:00
Simon Brugman
50046fbed3
Extend conventional imports defaults to include TensorFlow et al ( #2353 )
...
extend conventional imports
Based on configuration from Visual Studio for Python
(https://code.visualstudio.com/docs/python/editing#_quick-fixes )
2023-01-30 11:04:19 -05:00
Charlie Marsh
6798675db1
Avoid removing trailing comments when autofixing ( #2352 )
2023-01-30 07:44:20 -05:00
Akhil
8e5a944ce1
Implement Pylint's too-many-arguments rule (PLR0913) ( #2308 )
2023-01-30 07:34:37 -05:00
messense
1e325edfb1
Configure automatically generated release notes ( #2341 )
2023-01-30 07:21:29 -05:00
Simon Brugman
502574797f
include tomllib in standard lib ( #2345 )
2023-01-30 06:59:59 -05:00
Charlie Marsh
7a83b65fbe
Pre-allocate output contents during autofix application ( #2340 )
2023-01-29 22:40:27 -05:00
Charlie Marsh
74e3cdfd7c
Add a dedicated single-fix helper ( #2339 )
2023-01-29 22:38:29 -05:00
Simon Brugman
2ef28f217c
pandas vet autofix for PD002 and general refactor
2023-01-29 22:30:37 -05:00
Simon Brugman
63fc912ed8
refactor: use remove_argument helper in pyupgrade
2023-01-29 22:30:37 -05:00
Martin Fischer
d76a47d366
Implement ruff linter subcommand
...
The subcommand lists all supported upstream linters and their prefixes:
$ ruff linter
F Pyflakes
E/W pycodestyle
C90 mccabe
I isort
N pep8-naming
D pydocstyle
UP pyupgrade
YTT flake8-2020
# etc...
Just like with the `rule` subcommand `--format json` is supported:
$ ruff linter --format json
[
{
"prefix": "F",
"name": "Pyflakes"
},
{
"prefix": "",
"name": "pycodestyle",
"categories": [
{
"prefix": "E",
"name": "Error"
},
{
"prefix": "W",
"name": "Warning"
}
]
},
# etc...
2023-01-29 21:32:37 -05:00
Martin Fischer
b532fce792
refactor: Change RuleNamespace::prefixes to common_prefix
...
Previously Linter::parse_code("E401") returned
(Linter::Pycodestyle, "401") ... after this commit it returns
(Linter::Pycodestyle, "E401") instead, which is important
for the future implementation of the many-to-many mapping.
(The second value of the tuple isn't used currently.)
2023-01-29 21:32:37 -05:00
Charlie Marsh
3ee6a90905
Remove remove-six-compat (UP016) ( #2332 )
2023-01-29 21:19:59 -05:00
Samuel Cormier-Iijima
0a6d2294a7
[TRY201] don't check raise statements in nested exception handlers ( #2337 )
2023-01-29 21:16:18 -05:00
Simon Brugman
e66fb42d0b
refactor: use patch(diagnostic.kind.rule()) ( #2336 )
2023-01-29 21:15:09 -05:00
Simon Brugman
5165b703d9
Add VS Code to gitignore; fix typos ( #2333 )
2023-01-29 21:14:38 -05:00
Simon Brugman
b40cd1fabc
debug assert for fix usage ( #2335 )
2023-01-29 21:13:42 -05:00
Charlie Marsh
64fb0bd2cc
Include both ruff help and ruff help check in README ( #2325 )
2023-01-29 17:01:15 -05:00
Charlie Marsh
2ad29089af
Allow list comprehensions for __all__ assignment ( #2326 )
2023-01-29 14:26:54 -05:00
Florian Best
f41796d559
feat: add ruff --statistics ( #2284 )
...
Closes #2284 .
2023-01-29 13:44:56 -05:00
Samuel Cormier-Iijima
945a9e187c
Migrate violations to named fields ( #2317 )
...
Fairly mechanical. Did a few of the simple cases manually to make sure things were working, and I think the rest will be easily achievable via a quick `fastmod` command.
ref #1871
2023-01-29 13:29:53 -05:00
Charlie Marsh
546413defb
Fix remaining RelativeImportsOrder typo
2023-01-29 11:33:12 -05:00
Charlie Marsh
e371ef9b1a
Place star before other member imports ( #2320 )
...
I think we've never run into this case, since it's rare to import `*` from a module _and_ import some other member explicitly. But we were deviating from `isort` by placing the `*` after other members, rather than up-top.
Closes #2318 .
2023-01-28 22:17:43 -05:00
Charlie Marsh
c9585fe304
Run generate-all
2023-01-28 22:13:07 -05:00
Charlie Marsh
535868f939
Update fixable list ( #2316 )
2023-01-28 20:18:55 -05:00
Chirag
cec993aaa9
Add ruff . to documentation ( #2307 )
2023-01-28 14:53:11 -05:00
Samuel Cormier-Iijima
1a32d873f0
Fix regression with line-based rules not being ignored per-file ( #2311 )
2023-01-28 14:48:32 -05:00
Samuel Cormier-Iijima
f308f9f27e
Respect per-file-ignores when checking noqa ( #2309 )
...
`RUF100` does not take into account a rule ignored for a file via a `per-file-ignores` configuration. To see this, try the following pyproject.toml:
```toml
[tool.ruff.per-file-ignores]
"test.py" = ["F401"]
```
and this test.py file:
```python
import itertools # noqa: F401
```
Running `ruff --extend-select RUF100 test.py`, we should expect to get this error:
```
test.py:1:19: RUF100 Unused `noqa` directive (unused: `F401`)
```
The issue is that the per-file-ignores diagnostics are filtered out after the noqa checks, rather than before.
2023-01-28 14:16:30 -05:00
Jonathan Plasse
73dccce5f5
Isolate integration tests ( #2306 )
2023-01-28 13:32:50 -05:00
Charlie Marsh
fc9fae6579
Remove picture tag from PyPI and MkDocs
2023-01-28 11:49:52 -05:00
Charlie Marsh
add7fefeb5
Bump version to 0.0.237
2023-01-28 10:52:14 -05:00
Charlie Marsh
ec24947865
Fix version shorthand detection to use -V instead of -v ( #2301 )
...
Fixes a regression introduced in eda2be6350 (but not yet released to users). (`-v` is a real flag, but it's an alias for `--verbose`, not `--version`.)
Closes #2299 .
2023-01-28 10:47:47 -05:00
Charlie Marsh
8038d32649
Deploy under docs subdirectory
2023-01-28 10:28:40 -05:00
Charlie Marsh
0362cc1098
Allow manual trigger for docs
2023-01-28 10:24:52 -05:00
Charlie Marsh
860e3110c0
Serve docs under /docs subdirectory
2023-01-28 10:22:35 -05:00
Jonxslays
0fa8c578cb
Fix typo in typing_extensions ( #2298 )
2023-01-28 10:03:54 -05:00
Charlie Marsh
861df12269
Preserve global binding kind during reassignments ( #2297 )
2023-01-28 08:40:09 -05:00
Charlie Marsh
071e3fd196
Split MkDocs site into multiple pages ( #2296 )
2023-01-28 08:31:16 -05:00
Martin Fischer
dd79ec293a
Rename new explain subcommand to rule
...
We probably want to introduce multiple explain subcommands and
overloading `explain` to explain it all seems like a bad idea.
We may want to introduce a subcommand to explain config options and
config options may end up having the same name as their rules, e.g. the
current `banned-api` is both a rule name (although not yet exposed to
the user) and a config option.
The idea is:
* `ruff rule` lists all rules supported by ruff
* `ruff rule <code>` explains a specific rule
* `ruff linter` lists all linters supported by ruff
* `ruff linter <name>` lists all rules/options supported by a specific linter
(After this commit only the 2nd case is implemented.)
2023-01-28 07:26:20 -05:00
Martin Fischer
5d331e43bf
fix: help text and env for --format option of explain subcommand
...
The doc comment and the env attribute were copied by mistake.
2023-01-28 07:26:20 -05:00
Martin Fischer
ff3563b8ce
Remove --check alias introduced in eda2be63
...
We do not want to support the --{subcommand} legacy format for new
subcommands ... only for subcommands that used this format previously.
2023-01-28 07:26:20 -05:00
Matt Morris
caada2f8bb
add missing backticks to flake8 plugin urls in README ( #2291 )
2023-01-28 07:16:23 -05:00
messense
0b4cc5ac12
Add readme field to pyproject.toml ( #2293 )
2023-01-28 07:14:58 -05:00
Charlie Marsh
8c70247188
Switch to red MkDocs theme
2023-01-27 23:15:49 -05:00
Charlie Marsh
eaac3cae5e
Add MkDocs version of README ( #2287 )
...
Co-authored-by: Justin Flannery <juftin@juftin.com >
2023-01-27 22:57:42 -05:00
Charlie Marsh
fd56414b2f
Re-add ALL disclaimer
2023-01-27 22:18:20 -05:00
Martin Fischer
9731f96fb4
fix: typo in BREAKING_CHANGES.md & improve wrapping
2023-01-27 21:35:41 -05:00
Charlie Marsh
1a0191f1ac
Add release to breaking changes
2023-01-27 20:34:24 -05:00
Charlie Marsh
249cf73d4e
Tweak some wording in CLI help ( #2285 )
2023-01-27 20:25:58 -05:00
Martin Fischer
eda2be6350
Use subcommands for CLI instead of incompatible boolean flags
...
This commit greatly simplifies the implementation of the CLI,
as well as the user expierence (since --help no longer lists all
options even though many of them are in fact incompatible).
To preserve backwards-compatability as much as possible aliases have
been added for the new subcommands, so for example the following two
commands are equivalent:
ruff explain E402 --format json
ruff --explain E402 --format json
However for this to work the legacy-format double-dash command has to
come first, i.e. the following no longer works:
ruff --format json --explain E402
Since ruff previously had an implicitly default subcommand,
this is preserved for backwards compatibility, i.e. the following two
commands are equivalent:
ruff .
ruff check .
Previously ruff didn't complain about several argument combinations that
should have never been allowed, e.g:
ruff --explain RUF001 --line-length 33
previously worked but now rightfully fails since the explain command
doesn't support a `--line-length` option.
2023-01-27 19:38:17 -05:00
Charlie Marsh
57a68f7c7d
Document the location of the personal config file ( #2283 )
2023-01-27 19:25:55 -05:00
Charlie Marsh
a19dd9237b
Add comparison to type checkers ( #2282 )
2023-01-27 19:18:40 -05:00
Simon Brugman
4f067d806e
add clippy and rust_dev to pre-commit ( #2256 )
...
I presume the reasoning for not including clippy in `pre-commit` was that it passes all files. This can be turned off with `pass_filenames`, in which case it only runs once.
`cargo +nightly dev generate-all` is also added (when excluding `target` is does not give false positives).
(The overhead of these commands is not much when the build is there. People can always choose to run only certain hooks with `pre-commit run [hook] --all-files`)
2023-01-27 18:53:44 -05:00
Samuel Cormier-Iijima
dd15c69181
[flake8-bandit] Add Rule S110 (try/except/pass) ( #2197 )
2023-01-27 18:52:55 -05:00
Charlie Marsh
b692921160
Use rustup show in lieu of actions-rs/toolchain ( #2280 )
2023-01-27 18:51:41 -05:00
Charlie Marsh
b3e8b1b787
Expand heuristic for detecting logging calls ( #2279 )
2023-01-27 18:41:16 -05:00
Charlie Marsh
0b34ca7107
Move off nightly Rust for dev workflows ( #2278 )
2023-01-27 18:35:19 -05:00
Charlie Marsh
df44c5124e
Add missing autofix levels to sometimes-fixable rules
2023-01-27 18:25:23 -05:00
Simon Brugman
0e27f78b3f
feat: include os.getcwdb (bytes) into flake8-use-pathlib ( #2276 )
2023-01-27 18:25:02 -05:00
Florian Best
cd8ad1df08
mark some fixers as sometimes-fixable ( #2271 )
2023-01-27 18:23:32 -05:00
Charlie Marsh
d1aaf16e40
Omit typing module from flake8-type-checking by default ( #2277 )
2023-01-27 18:19:45 -05:00
Ville Skyttä
7320058ce2
Incompatiblity warning updates ( #2272 )
2023-01-27 18:17:23 -05:00
Aarni Koskela
3a8b367b1c
flake8-annotations: Move has_any_typed_arg into correct nested if ( #2269 )
2023-01-27 18:15:46 -05:00
Ville Skyttä
221b87332c
feat: add more DTZ fix suggestions in messages ( #2274 )
2023-01-27 18:14:17 -05:00
Franck Nijhof
8149c8cbc4
Treat attribute constants as constant for yoda-conditions ( #2266 )
...
Accessed attributes that are Python constants should be considered for yoda-conditions
```py
## Error
JediOrder.YODA == age # SIM300
## OK
age == JediOrder.YODA
```
~~PS: This PR will fail CI, as the `main` branch currently failing.~~
2023-01-27 12:55:12 -05:00
Charlie Marsh
2c415016a6
Update F401 snapshots
2023-01-27 12:43:42 -05:00
Sladyn
bb85119ba8
Convert UnusedImport violation to struct fields ( #2141 )
2023-01-27 11:31:39 -05:00
Simon Brugman
94551a203e
feat: pylint PLE0604 and PLE0605 ( #2241 )
2023-01-27 11:26:33 -05:00
Charlie Marsh
64c4e4c6c7
Treat constant tuples as constants for yoda-conditions ( #2265 )
2023-01-27 11:25:57 -05:00
Charlie Marsh
84e4b7c96f
Treat builtins as synthetically used ( #2251 )
2023-01-27 11:25:45 -05:00
Franck Nijhof
ca26f664ec
Fix SIM300 to take Python constants into account ( #2255 )
...
SIM300 currently doesn't take Python constants into account when looking for Yoda conditions, this PR fixes that behavior.
```python
# Errors
YODA == age # SIM300
YODA > age # SIM300
YODA >= age # SIM300
# OK
age == YODA
age < YODA
age <= YODA
```
Ref: <https://github.com/home-assistant/core/pull/86793 >
2023-01-27 11:20:21 -05:00
Aarni Koskela
779b232db9
Fix typo: RelatveImportsOrder ( #2264 )
2023-01-27 11:15:43 -05:00
Charlie Marsh
a316b26b49
Rewrite some string-format violation messages ( #2242 )
2023-01-26 19:42:16 -05:00
Charlie Marsh
685d9ab848
Bump version to 0.0.236
2023-01-26 18:47:00 -05:00
Charlie Marsh
093f9156e1
Wrap return-bool-condition-directly fixes in bool() ( #2240 )
2023-01-26 18:22:34 -05:00
Charlie Marsh
615e62ae24
Clarify E-category rule support ( #2239 )
2023-01-26 18:12:28 -05:00
Charlie Marsh
76a0c45773
Track type-checking blocks during tree traversal ( #2238 )
2023-01-26 18:09:28 -05:00
Charlie Marsh
3ec46f0936
Allow pytest in shebang ( #2237 )
2023-01-26 17:32:23 -05:00
Charlie Marsh
a6ec2eb044
Avoid removing trailing comments on pass statements ( #2235 )
...
This isn't super consistent with some other rules, but... if you have a lone body, with a `pass`, followed by a comment, it's probably surprising if it gets removed. Let's retain the comment.
Closes #2231 .
2023-01-26 17:29:13 -05:00
Simon Brugman
9d3a5530af
refactor: move violations to linters ( #2234 )
2023-01-26 17:28:14 -05:00
Simon Brugman
8766e6a666
docs(readme): add featuretools ( #2236 )
2023-01-26 17:24:45 -05:00
Charlie Marsh
b08367b5a8
Avoid flagging blind exceptions with valid logging ( #2232 )
2023-01-26 17:05:01 -05:00
Charlie Marsh
98a8330124
Add stylist settings to all LibCST invocations ( #2225 )
2023-01-26 16:59:33 -05:00
Charlie Marsh
4d52ea87ef
Implement exempt-modules setting from flake8-type-checking ( #2230 )
2023-01-26 16:55:32 -05:00
Charlie Marsh
291239b9f1
Fix range for try-consider-else ( #2228 )
2023-01-26 16:36:18 -05:00
Charlie Marsh
224334b6d1
Avoid erroneous class autofixes in indented blocks ( #2226 )
2023-01-26 16:24:21 -05:00
Charlie Marsh
0cab3f8437
Preserve indentation when fixing via LibCST ( #2223 )
2023-01-26 16:09:35 -05:00
Charlie Marsh
5f8810e987
Add strictness setting for flake8-typing-imports ( #2221 )
2023-01-26 16:04:21 -05:00
Charlie Marsh
f15c562a1c
Remove unused overridden property ( #2217 )
2023-01-26 14:46:46 -05:00
Martin Fischer
4f3b63edd4
fix: --explain reporting the wrong linter
...
Fixes a regression introduced in 4e4643aa5d .
We want the longest prefixes to be checked first so we of course
have to reverse the sorting when sorting by prefix length.
Fixes #2210 .
2023-01-26 13:53:35 -05:00
Simon Brugman
bab8691132
chore: fix script indent ( #2213 )
2023-01-26 13:53:22 -05:00
Charlie Marsh
50c85fd192
Add a fixable and unfixable example to the docs ( #2211 )
2023-01-26 13:23:21 -05:00
Martin Fischer
23819ae338
Group options in --help output and sort them by importance
...
`ruff --help` previously listed 37 options in no particular order
(with niche options like --isolated being listed before before essential
options such as --select). This commit remedies that and additionally
groups the options by making use of the Clap help_heading feature.
Note that while the source code has previously also referred to
--add-noqa, --show-settings, and --show-files as "subcommands"
this commit intentionally does not list them under the new
Subcommands section since contrary to --explain and --clean
combining them with most of the other options makes sense.
2023-01-26 13:06:29 -05:00
Martin Fischer
4bf2879067
refactor: Move add_noqa if branch up
2023-01-26 13:06:29 -05:00
Martin Fischer
b359f3a9ff
refactor: Get rid of ruff::resolver::FileDiscovery
2023-01-26 13:06:29 -05:00
Martin Fischer
73d0461d55
refactor: Check required_version in Settings::from_configuration
...
The idiomatic way in Rust is to make invalid types unrepresentable
instead of paranoidly calling a validate method everywhere.
2023-01-26 13:06:29 -05:00
Martin Fischer
55bb36fb8b
refactor: Introduce LogLevelArgs
2023-01-26 13:06:29 -05:00
Martin Fischer
cebea16fe4
refactor: Move Args::partition call after panic::set_hook
2023-01-26 13:06:29 -05:00
Charlie Marsh
f7be192f8b
Alphabetize Flake8 plugins in the README ( #2209 )
2023-01-26 13:05:30 -05:00
Edgar R. M
e88275280b
Implement some rules from flake8-logging-format ( #2150 )
2023-01-26 12:58:10 -05:00
Samuel Cormier-Iijima
7370a27c09
Don't flag B009/B010 if identifiers would be mangled ( #2204 )
2023-01-26 12:56:18 -05:00
jvstme
0ad6b8224d
Fix typo in src option docs ( #2201 )
2023-01-26 12:23:09 -05:00
Henry Schreiner
f3aa409d9a
docs(readme): add pypa's build ( #2200 )
2023-01-26 12:18:04 -05:00
Charlie Marsh
adb5c5b150
Fix respect_gitignore reference ( #2196 )
2023-01-26 09:53:17 -05:00
Martin Fischer
b69b6a7ec8
refactor: Move comments before if conditions
2023-01-25 22:08:35 -05:00
Martin Fischer
a7d2def9cd
refactor: Move ruff_cli::resolve to own module
2023-01-25 22:08:35 -05:00
Martin Fischer
d9ead4e6df
refactor: Rename CLI arg structs from Cli to Args
...
Technically the command-line interface (CLI) encompasses both input and
output, so naming the input structs 'Args' is more accurate than 'Cli'.
2023-01-25 22:08:35 -05:00
Charlie Marsh
b346f74915
Run cargo update ( #2185 )
2023-01-25 21:32:44 -05:00
Eric Roberts
708295f4c9
Move violations for pycodestyle rules to rules files ( #2138 )
2023-01-25 20:11:36 -05:00
Charlie Marsh
4190f1045e
Remove manual newline from autofix helpers ( #2184 )
2023-01-25 19:53:26 -05:00
Florian Stasse
353857e2a5
Implement TRY400 ( #2115 )
2023-01-25 19:42:19 -05:00
Denis Gavrilyuk
55b43c8ea7
feat: implement TRY002 and TRY003 ( #2135 )
2023-01-25 19:22:43 -05:00
Anders Kaseorg
6036d1bbe2
flake8_executable: Only match shebang at beginning of line ( #2183 )
...
The Python implementation uses `re.match` for this, which only matches
at the beginning of a line.
https://github.com/xuhdev/flake8-executable/blob/v2.1.3/flake8_executable/__init__.py#L124
We could use `Regex::captures_read_at`, but that’s a more complicated
API; it’s easier to anchor the regex with `^`.
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-25 18:57:09 -05:00
Charlie Marsh
edd0e16a02
Bump version to 0.0.235
2023-01-25 18:28:27 -05:00
Charlie Marsh
fdccb6ec1c
Fix conflicting error message warning ( #2182 )
2023-01-25 18:26:43 -05:00
Anders Kaseorg
c00b8b6d2d
Remove stray parenthesis from fixed errors message ( #2181 )
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-25 18:15:12 -05:00
Simon Brugman
52201422ae
fix: platform-independent newlines
2023-01-25 18:00:39 -05:00
Simon Brugman
d7fe1eeba0
fix: platform-independent paths
2023-01-25 18:00:39 -05:00
Simon Brugman
5835d719c4
ci: enable windows testing in Github Actions
2023-01-25 18:00:39 -05:00
Simon Brugman
c859ac4933
refactor: test ground truth update for new macro
2023-01-25 18:00:39 -05:00
Simon Brugman
e9c1089ddc
refactor: tests use new marco
2023-01-25 18:00:39 -05:00
Simon Brugman
413acdf83c
feat: introduce macro for testing snap files across platforms
2023-01-25 18:00:39 -05:00
Charlie Marsh
16d2ece87d
Restore single-file license ( #2180 )
...
These were split into per-project licenses in #1648 , but I don't like that they're no longer included in the distribution (due to current limitations in the `pyproject.toml` spec).
2023-01-25 17:59:12 -05:00
Anders Kaseorg
823f1c5b6a
Avoid duplicate CI runs triggered by pushes to pull requests ( #2178 )
...
https://github.com/charliermarsh/ruff/pull/2157#discussion_r1087179996
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-25 17:45:07 -05:00
Charlie Marsh
9b07d0bd92
Bump version to 0.0.234
2023-01-25 16:55:57 -05:00
Charlie Marsh
23525a8ea0
Actually, rename TYP rules to TCH ( #2176 )
2023-01-25 16:52:49 -05:00
Charlie Marsh
6ede030700
Allow manual releases for pre-release testing
2023-01-25 16:37:04 -05:00
Charlie Marsh
44f3e5013d
Add flake8-type-checking license
2023-01-25 16:27:18 -05:00
Charlie Marsh
35cf9e242e
Rename TYP rules to TYC ( #2175 )
2023-01-25 16:26:22 -05:00
Charlie Marsh
d5dff11d4b
Avoid reraise-no-cause for explicit reraises ( #2174 )
2023-01-25 15:51:24 -05:00
Charlie Marsh
8e1fac620e
Add flake8-builtins options to README ( #2173 )
2023-01-25 15:43:26 -05:00
Aarni Koskela
0da691c0d5
Add Babel to readme ( #2170 )
2023-01-25 15:21:26 -05:00
Hugo van Kemenade
233415921b
Add colour to CI for readability
2023-01-25 15:21:10 -05:00
Hugo van Kemenade
81141e2a73
Bump GitHub Actions
2023-01-25 15:21:10 -05:00
Hugo van Kemenade
6e255ad53c
Allow testing feature branches
2023-01-25 15:21:10 -05:00
Hugo van Kemenade
6d87adbcc0
Fix singular and plural for error(s)
2023-01-25 15:21:10 -05:00
Florian Best
43a8ce6c89
fix: avoid flagging unused loop variable (B007) with globals(), vars() or eval() ( #2166 )
2023-01-25 15:18:58 -05:00
Charlie Marsh
a978706dce
Re-add error wrapper in main.rs ( #2168 )
2023-01-25 15:11:24 -05:00
Florian Best
dc1aa8dd1d
Suggest input format in error case ( #2167 )
2023-01-25 14:55:04 -05:00
Charlie Marsh
662e29b1ce
Avoid re-resolving settings for repeated paths ( #2165 )
...
After this change:
```shell
> time cargo run -- -n $(find ../django -type f -name '*.py')`
8.85s user 0.20s system 498% cpu 1.814 total
> time cargo run -- -n ../django
8.95s user 0.23s system 507% cpu 1.811 total
```
I also verified that we only hit the creation path once via some manual logging.
Closes #2154 .
2023-01-25 13:38:33 -05:00
Charlie Marsh
6978dcf035
Add an FAQ on autofix ( #2163 )
2023-01-25 13:09:16 -05:00
Charlie Marsh
0e6f513607
Avoid prefer-type-error (TRY004) with intermediary control flow ( #2162 )
2023-01-25 13:00:59 -05:00
Charlie Marsh
02421d02f5
Avoid flagging unused loop variable (B007) with locals() ( #2161 )
2023-01-25 12:53:35 -05:00
Charlie Marsh
38de46ae3c
Treat Python 3.7 as minimum supported version ( #2159 )
2023-01-25 12:36:50 -05:00
Martin Fischer
f6fd702d41
Add #![warn(clippy::pedantic)] to lib.rs and main.rs files
...
We already enforced pedantic clippy lints via the
following command in .github/workflows/ci.yaml:
cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic
Additionally adding #![warn(clippy::pedantic)] to all main.rs and lib.rs
has the benefit that violations of pedantic clippy lints are also
reported when just running `cargo clippy` without any arguments and
are thereby also picked up by LSP[1] servers such as rust-analyzer[2].
However for rust-analyzer to run clippy you'll have to configure:
"rust-analyzer.check.command": "clippy",
in your editor.[3]
[1]: https://microsoft.github.io/language-server-protocol/
[2]: https://rust-analyzer.github.io/
[3]: https://rust-analyzer.github.io/manual.html#configuration
2023-01-25 00:40:29 -05:00
Martin Fischer
2125d0bb54
refactor: Move #![forbid(unsafe_code)] attributes up
...
What's forbidden is more important than which clippy lints are
ignored and more important directives should come first.
2023-01-25 00:40:29 -05:00
Charlie Marsh
63b4f60ba4
Implement typing-only import detection (TYP001, TYP002, TYP003) ( #2147 )
2023-01-24 23:48:11 -05:00
Charlie Marsh
9eb13bc9da
Downgrade recommended pre-commit version to v0.0.231
2023-01-24 23:47:13 -05:00
Charlie Marsh
0758049e49
Implement runtime-import-in-type-checking-block (TYP004) ( #2146 )
2023-01-24 23:33:26 -05:00
Charlie Marsh
deff503932
Avoid generating dirty call paths ( #2144 )
2023-01-24 20:40:38 -05:00
Jonathan Plasse
82d7814101
Update .pre-commit-config.yml ( #2139 )
2023-01-24 19:45:34 -05:00
Eric Roberts
0cac1a0d21
Move is_overlong to helpers ( #2137 )
2023-01-24 12:45:35 -05:00
Charlie Marsh
605416922d
Bump version to 0.0.233
2023-01-24 10:46:49 -05:00
Charlie Marsh
7b81f36e54
Enable executable checks on Windows ( #2133 )
2023-01-24 10:46:27 -05:00
Eric Roberts
ff63da9f52
Move compare to helpers file ( #2131 )
...
From discussion on https://github.com/charliermarsh/ruff/pull/2123
I didn't originally have a helpers file so I put the function in both
places but now that a helpers file exists it seems logical for it to be
there.
2023-01-24 10:30:56 -05:00
Charlie Marsh
d645a19e0a
Bump version to 0.0.232
2023-01-24 09:49:07 -05:00
Charlie Marsh
30ae0d3723
Add Dagger and Great Expectations ( #2130 )
2023-01-24 09:48:00 -05:00
Charlie Marsh
3fb9e76012
Remove unnecessary manual Generator invocations ( #2129 )
2023-01-24 09:38:12 -05:00
Eric Roberts
0f283ae98c
Move pycodestyle rules into individual files ( #2123 )
2023-01-24 09:27:26 -05:00
Martin Fischer
269926cec4
refactor: Move redirects out of RuleCodePrefix
...
This commit removes rule redirects such as ("U" -> "UP") from the
RuleCodePrefix enum because they complicated the generation of that enum
(which we want to change to be prefix-agnostic in the future).
To preserve backwards compatibility redirects are now resolved
before the strum-generated RuleCodePrefix::from_str is invoked.
This change also brings two other advantages:
* Redirects are now only defined once
(previously they had to be defined twice:
once in ruff_macros/src/rule_code_prefix.rs
and a second time in src/registry.rs).
* The deprecated redirects will no longer be suggested in IDE
autocompletion within pyproject.toml since they are now no
longer part of the ruff.schema.json.
2023-01-24 09:26:19 -05:00
Martin Fischer
28018442f6
refactor: Move ALL from RuleCodePrefix to RuleSelector
2023-01-24 09:26:19 -05:00
Martin Fischer
abc9810e2b
refactor: Turn RuleSelector into a newtype around RuleCodePrefix
...
Yet another refactor to let us implement the many-to-many mapping
between codes and rules in a prefix-agnostic way.
We want to break up the RuleCodePrefix[1] enum into smaller enums.
To facilitate that this commit introduces a new wrapping type around
RuleCodePrefix so that we can start breaking it apart.
[1]: Actually `RuleCodePrefix` is the previous name of the autogenerated
enum ... I renamed it in b19258a243 to
RuleSelector since `ALL` isn't a prefix. This commit now renames it back
but only because the new `RuleSelector` wrapper type, introduced in this
commit, will let us move the `ALL` variant from `RuleCodePrefix` to
`RuleSelector` in the next commit.
2023-01-24 09:26:19 -05:00
Charlie Marsh
a20482961b
Add tryceratops to flake8-to-ruff
2023-01-24 08:41:18 -05:00
Charlie Marsh
d97c07818e
Update flake8-to-ruff to include latest plugins ( #2127 )
...
Closes #2124 (along with a release).
2023-01-24 08:39:58 -05:00
Ville Skyttä
7e92485f43
feat: autofix multi-line-summary-*-line ( #2093 )
2023-01-24 08:17:13 -05:00
Charlie Marsh
930c3be69d
Ignore generators in flake8-return rules ( #2126 )
...
We could do a better job of handling them, but they cause too many false-positives right now.
Closes #2119 .
2023-01-24 08:15:26 -05:00
Aarni Koskela
24d0a980c5
flake8-annotations: deduplicate code between functions and methods ( #2125 )
2023-01-24 08:03:33 -05:00
Edgar R. M
f5f0ed280a
Implement EXE001 and EXE002 from flake8-executable ( #2118 )
2023-01-24 08:02:47 -05:00
Martin Fischer
ca58c72fc9
refactor: Convention::codes to rules_to_be_ignored
2023-01-24 07:37:34 -05:00
Martin Fischer
c40f14620a
refactor: Get rid of registry::CATEGORIES
2023-01-24 07:37:34 -05:00
Martin Fischer
04300ce258
refactor: Rename SuffixLength enum to Specificity
2023-01-24 07:37:34 -05:00
Martin Fischer
ead5f948d3
refactor: Move Colorize imports where they're used
2023-01-24 07:37:34 -05:00
Martin Fischer
e93e9fae82
refactor: Make flake8_to_ruff tests even more DRY
2023-01-24 07:37:34 -05:00
Martin Fischer
f5ddec0fb3
refactor: Move resolve_select to converter module
...
The function is only used there and is not plugin-specific
since it also specifies the default rule selectors (F, E, W).
2023-01-24 07:37:34 -05:00
Martin Fischer
3de2a57416
refactor: Use ..Options::default() for tests
2023-01-24 07:37:34 -05:00
Hugo
b29b4084ff
Add apk instructions to README ( #2121 )
2023-01-24 07:29:03 -05:00
Aarni Koskela
c61ca4a953
Add Home Assistant to Readme ( #2120 )
2023-01-24 07:27:45 -05:00
Denis Gavrilyuk
58d5ac08a8
feat: implement TRY301 ( #2113 )
2023-01-24 07:25:26 -05:00
Charlie Marsh
cc63a4be6a
Allow flagging of multiline implicit string concatenations ( #2117 )
...
At present, `ISC001` and `ISC002` flag concatenations like the following:
```py
"a" "b" # ISC001
"a" \
"b" # ISC002
```
However, multiline concatenations are allowed.
This PR adds a setting:
```toml
[tool.ruff.flake8-implicit-str-concat]
allow-multiline = false
```
Which extends `ISC002` to _also_ flag multiline concatenations, like:
```py
(
"a" # ISC002
"b"
)
```
Note that this is backwards compatible, as `allow-multiline` defaults to `true`.
2023-01-24 00:01:01 -05:00
Charlie Marsh
549a5d44bc
Upgrade to toml v0.6.0 ( #2116 )
...
Closes #1894 .
2023-01-23 19:22:42 -05:00
Denis Gavrilyuk
d65ce6308b
feat: implement TRY200 ( #2087 )
...
#2056
2023-01-23 14:12:42 -05:00
Charlie Marsh
b988a268e4
Escape curly braces when converting .format() strings ( #2112 )
...
Closes #2111 .
2023-01-23 14:11:24 -05:00
Charlie Marsh
1c3265ef98
Bump version to 0.0.231
2023-01-23 12:51:09 -05:00
Maksudul Haque
8001a1639c
[flake8-bandit] Added Rule S612 (Use of insecure logging.config.listen) ( #2108 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
2023-01-23 12:37:33 -05:00
Charlie Marsh
7d9c1d7a5a
Add a note on some isort incompatibilities
2023-01-23 12:32:35 -05:00
Thomas MK
c5cebb106e
Fix outdated description of ruff's support of isort settings ( #2106 )
...
Ruff supports more than `known-first-party`, `known-third-party`, `extra-standard-library`, and `src` nowadays.
Not sure if this is the best wording. Suggestions welcome!
2023-01-23 12:29:44 -05:00
Martin Fischer
8c61e8a1ef
Improve #[derive(RuleNamespace)] error handling
2023-01-23 12:20:10 -05:00
Martin Fischer
4f338273a5
refactor: Simplify test_ruff_black_compatibility
2023-01-23 12:20:10 -05:00
Martin Fischer
648191652d
refactor: Collect into Result<Vec<_>, _>
2023-01-23 12:20:10 -05:00
Martin Fischer
90558609c3
refactor: Introduce parse_doc_attr helper function
2023-01-23 12:20:10 -05:00
Martin Fischer
991d3c1ef6
refactor: Move Linter::url and Linter::name generation to proc macro
...
This lets us get rid of the build.rs script and results
in more developer-friendly compile error messages.
2023-01-23 12:20:10 -05:00
Simon Brugman
f472fbc6d4
docs(readme): add pypa cibuildwheel ( #2107 )
2023-01-23 11:39:23 -05:00
Charlie Marsh
09b65a6449
Remove some usages of default format for expressions ( #2100 )
2023-01-22 23:15:43 -05:00
Charlie Marsh
9d2eced941
Add flake8-simplify to CONTRIBUTING.md
2023-01-22 21:46:52 -05:00
Charlie Marsh
be0f6acb40
Change contributing to point to tryceratops
2023-01-22 21:45:20 -05:00
Steve Dignam
0c624af036
Add flake8-pie PIE800: no-unnecessary-spread ( #1881 )
...
Checks for unnecessary spreads, like `{**foo, **{"bar": True}}`
rel: https://github.com/charliermarsh/ruff/issues/1879
rel: https://github.com/charliermarsh/ruff/issues/1543
2023-01-22 21:43:34 -05:00
Steve Dignam
4ca328f964
Add flake8-pie PIE804: no-unnecessary-dict-kwargs ( #1884 )
...
Warn about things like `foo(**{"bar": True})` which is equivalent to `foo(bar=True)`
rel: https://github.com/charliermarsh/ruff/issues/1879
rel: https://github.com/charliermarsh/ruff/issues/1543
2023-01-22 21:32:45 -05:00
Charlie Marsh
07b5bf7030
Remove misleading emoji comment
2023-01-22 21:23:55 -05:00
Charlie Marsh
f40ae943a7
Fix bad documentation message for init option
2023-01-22 19:25:23 -05:00
Charlie Marsh
8d46d3bfa6
Avoid nested-if violations when outer-if has else clause ( #2095 )
...
It looks like we need `do`-`while`-like semantics here with an additional outer check.
Closes #2094 .
2023-01-22 17:40:56 -05:00
alm
4fb0c6e3ad
feat: Implement TRY201 ( #2073 )
2023-01-22 17:08:57 -05:00
Simon Brugman
ebfdefd110
refactor: remove redundant enum ( #2091 )
2023-01-22 15:27:08 -05:00
Simon Brugman
11f06055a0
feat: flake8-use-pathlib PTH100-124 ( #2090 )
2023-01-22 15:17:25 -05:00
Ville Skyttä
6a6a792562
fix: issue D401 only for non-test/property functions and methods ( #2071 )
...
Extend test fixture to verify the targeting.
Includes two "attribute docstrings" which per PEP 257 are not recognized by the Python bytecode compiler or available as runtime object attributes. They are not available for us either at time of writing, but include them for completeness anyway in case they one day are.
2023-01-22 14:24:59 -05:00
Charlie Marsh
23b622943e
Bump version to 0.0.230
2023-01-22 13:58:41 -05:00
Harutaka Kawamura
a7ce8621a9
Update RustPython to fix Dict.keys type ( #2086 )
...
This PR upgrades RustPython to fix the type of `Dict.keys` to `Vec<Option<Expr>>` (see https://github.com/RustPython/RustPython/pull/4449 for why this change was needed) and unblock #1884 .
2023-01-22 13:24:00 -05:00
Shannon Rothe
36fb8f7a63
flake8_to_ruff: support isort options ( #2082 )
...
See: https://github.com/charliermarsh/ruff/issues/1749 .
2023-01-22 13:18:01 -05:00
alm
e11cf1bf65
Update linters PyPI links to latest version ( #2062 )
2023-01-22 13:10:22 -05:00
Maksudul Haque
75e16c0ce5
[pep8-naming][N806] Don't mark TypeVar & NewType Assignment as Errors ( #2085 )
...
closes https://github.com/charliermarsh/ruff/issues/1985
2023-01-22 12:54:13 -05:00
Martin Fischer
1beedf20f9
fix: add_rule.py for --linter ruff
2023-01-22 11:51:29 -05:00
Martin Fischer
4758ee6ac4
refactor: Generate Linter -> RuleSelector mapping via macro
...
To enable ruff_dev to automatically generate the rule Markdown tables in
the README the ruff library contained the following function:
Linter::codes() -> Vec<RuleSelector>
which was slightly changed to `fn prefixes(&self) -> Prefixes` in
9dc66b5a65 to enable ruff_dev to split
up the Markdown tables for linters that have multiple prefixes
(pycodestyle has E & W, Pylint has PLC, PLE, PLR & PLW).
The definition of this method was however largely redundant with the
#[prefix] macro attributes in the Linter enum, which are used to
derive the Linter::parse_code function, used by the --explain command.
This commit removes the redundant Linter::prefixes by introducing a
same-named method with a different signature to the RuleNamespace trait:
fn prefixes(&self) -> &'static [&'static str];
As well as implementing IntoIterator<Rule> for &Linter. We extend the
extisting RuleNamespace proc macro to automatically derive both
implementations from the Linter enum definition.
To support the previously mentioned Markdown table splitting we
introduce a very simple hand-written method to the Linter impl:
fn categories(&self) -> Option<&'static [LinterCategory]>;
2023-01-22 11:51:29 -05:00
Martin Fischer
c3dd1b0e3c
refactor: Rename ParseCode trait to RuleNamespace
...
ParseCode was a fitting name since the trait only contained a single
parse_code method ... since we now however want to introduce an
additional `prefixes` method RuleNamespace is more fitting.
2023-01-22 11:51:29 -05:00
Martin Fischer
87443e6301
Support prefix "PL" to select all of Pylint
2023-01-22 11:51:29 -05:00
Martin Fischer
16d2ceba79
refactor: Avoid unnecessary Map indexing
2023-01-22 11:51:29 -05:00
Martin Fischer
aedee7294e
refactor: Stop using Ident as BTreeMap key
...
Using Ident as the key type is inconvenient since creating an Ident
requires the specification of a Span, which isn't actually used by
the Hash implementation of Ident.
2023-01-22 11:51:29 -05:00
Martin Fischer
4f12b31dc8
refactor: Drop RuleSelector::codes in favor of IntoIterator impl
2023-01-22 11:51:29 -05:00
Martin Fischer
9f14e7c830
refactor: Update some variable/field/method names
2023-01-22 11:51:29 -05:00
Martin Fischer
4cc492a17a
refactor: Encapsulate PerFileIgnore impl details
2023-01-22 11:51:29 -05:00
Martin Fischer
028436af81
refactor: Group Configuration struct fields
2023-01-22 11:51:29 -05:00
Martin Fischer
da4994aa73
refactor: impl From<&Configuration> for RuleTable
2023-01-22 11:51:29 -05:00
Martin Fischer
4dcb491bec
refactor: Avoid some unnecessary allocations
2023-01-22 11:51:29 -05:00
Simon Brugman
6fc6bf0648
feat: enable autofix for TRY004 ( #2084 )
...
functionality was already implemented, just the trait needed to be added
2023-01-22 07:18:56 -05:00
Charlie Marsh
c1cb4796f8
Support decorators in source code generator ( #2081 )
2023-01-21 23:26:32 -05:00
Charlie Marsh
d81620397e
Improve generator precedence operations ( #2080 )
2023-01-21 23:21:37 -05:00
Charlie Marsh
84b1490d03
Base INP check on package inference ( #2079 )
...
If a file doesn't have a `package`, then it must both be in a directory that lacks an `__init__.py`, and a directory that _isn't_ marked as a namespace package.
Closes #2075 .
2023-01-21 19:49:56 -05:00
Simon Brugman
28f05aa6e7
feat: update scripts to new rules structure ( #2078 )
...
- optional `prefix` argument for `add_plugin.py`
- rules directory instead of `rules.rs`
- pathlib syntax
- fix test case where code was added instead of name
Example:
```
python scripts/add_plugin.py --url https://pypi.org/project/example/1.0.0/ example --prefix EXA
python scripts/add_rule.py --name SecondRule --code EXA002 --linter example
python scripts/add_rule.py --name FirstRule --code EXA001 --linter example
python scripts/add_rule.py --name ThirdRule --code EXA003 --linter example
```
Note that it breaks compatibility with 'old style' plugins (generation works fine, but namespaces need to be changed):
```
python scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint
```
2023-01-21 19:19:58 -05:00
Charlie Marsh
325faa8e18
Include package path in cache key ( #2077 )
...
Closes #2075 .
2023-01-21 18:33:35 -05:00
Charlie Marsh
6bfa1804de
Remove remaining ropey usages ( #2076 )
2023-01-21 18:24:10 -05:00
Charlie Marsh
4dcf284a04
Index source code upfront to power (row, column) lookups ( #1990 )
...
## Summary
The problem: given a (row, column) number (e.g., for a token in the AST), we need to be able to map it to a precise byte index in the source code. A while ago, we moved to `ropey` for this, since it was faster in practice (mostly, I think, because it's able to defer indexing). However, at some threshold of accesses, it becomes faster to index the string in advance, as we're doing here.
## Benchmark
It looks like this is ~3.6% slower for the default rule set, but ~9.3% faster for `--select ALL`.
**I suspect there's a strategy that would be strictly faster in both cases**, based on deferring even more computation (right now, we lazily compute these offsets, but we do it for the entire file at once, even if we only need some slice at the top), or caching the `ropey` lookups in some way.
Before:

After:

## Alternatives
I tried tweaking the `Vec::with_capacity` hints, and even trying `Vec::with_capacity(str_indices::lines_crlf::count_breaks(contents))` to do a quick scan of the number of lines, but that turned out to be slower.
2023-01-21 17:56:11 -05:00
Zeddicus414
08fc9b8095
ICN001 check from imports that have no alias ( #2072 )
...
Add tests.
Ensure that these cases are caught by ICN001:
```python
from xml.dom import minidom
from xml.dom.minidom import parseString
```
with config:
```toml
[tool.ruff.flake8-import-conventions.extend-aliases]
"dask.dataframe" = "dd"
"xml.dom.minidom" = "md"
"xml.dom.minidom.parseString" = "pstr"
```
2023-01-21 17:47:08 -05:00
Cosmo
39aed6f11d
Update link to Pylint parity tracking issue ( #2074 )
2023-01-21 17:46:55 -05:00
Zeddicus414
5726118cfe
ICN001 import-alias-is-not-conventional should check "from" imports ( #2070 )
...
Closes https://github.com/charliermarsh/ruff/issues/2047 .
2023-01-21 15:43:51 -05:00
Simon Brugman
67de8ac85e
feat: implementation for TRY004 ( #2066 )
...
See: #2056 .
2023-01-21 14:58:59 -05:00
figsoda
b1bda0de82
fix: pin rustpython to the same revision to fix cargo vendor ( #2069 )
...
I was trying to update ruff in nixpkgs and ran into this error when it was running `cargo vendor`
```
error: failed to sync
Caused by:
found duplicate version of package `rustpython-ast v0.2.0` vendored from two sources:
source 1: https://github.com/RustPython/RustPython.git?rev=62aa942bf506ea3d41ed0503b947b84141fdaa3c#62aa942b
source 2: https://github.com/RustPython/RustPython.git?rev=ff90fe52eea578c8ebdd9d95e078cc041a5959fa#ff90fe52
```
2023-01-21 14:40:00 -05:00
Charlie Marsh
84300e00ff
Bump version to 0.0.229
2023-01-21 13:18:06 -05:00
Charlie Marsh
fbee95a668
Avoid flagging redefined imports as unused in same-scope ( #2065 )
...
This is effectively a revert of #1173 , to favor false-negatives over false-positives in the same-scope case.
Closes #2044 .
2023-01-21 12:50:21 -05:00
Simon Brugman
afcf5c0ee0
feat: plugin scaffold for tryceratops with TRY300 ( #2055 )
...
Renamed to TRY to avoid conflicts, as proposed in https://github.com/guilatrova/tryceratops/pull/55
https://github.com/guilatrova/tryceratops/blob/main/docs/violations/TC300.md
See: #2056
2023-01-21 11:25:10 -05:00
Maksudul Haque
0c30768288
[flake8-builtins] Add builtins-ignorelist Option ( #2061 )
...
Closes #2053 .
2023-01-21 11:09:04 -05:00
Colin Delahunty
80295f335b
Pyupgrade: Printf string formatting ( #1803 )
2023-01-21 09:37:22 -05:00
Charlie Marsh
465943adf7
Revert "Upgrade to toml v0.5.11" ( #2058 )
...
This _did_ fix https://github.com/charliermarsh/ruff/issues/1894 , but was a little premature. `toml` doesn't actually depend on `toml-edit` yet, and `v0.5.11` was mostly about deprecations AFAICT. So upgrading might solve that issue, but could introduce other incompatibilities, and I'd like to minimize churn. I expect that `toml` will have a new release soon, so we can revert this revert.
Reverts charliermarsh/ruff#2040 .
2023-01-21 07:54:56 -05:00
Charlie Marsh
38eed292e4
Avoid removing comments in RUF005 ( #2057 )
...
Closes #2054 .
2023-01-21 07:37:25 -05:00
Harutaka Kawamura
883e650a35
Fix S101 range to only highlight assert ( #2052 )
...
Fix:
```
resources/test/fixtures/flake8_bandit/S101.py:2:1: S101 Use of `assert` detected
|
2 | assert True
| ^^^^^^^^^^^ S101
|
resources/test/fixtures/flake8_bandit/S101.py:8:5: S101 Use of `assert` detected
|
8 | assert x == 1
| ^^^^^^^^^^^^^ S101
|
resources/test/fixtures/flake8_bandit/S101.py:11:5: S101 Use of `assert` detected
|
11 | assert x == 2
| ^^^^^^^^^^^^^ S101
|
Found 3 error(s).
```
to:
```
resources/test/fixtures/flake8_bandit/S101.py:2:1: S101 Use of `assert` detected
|
2 | assert True
| ^^^^^^ S101
|
resources/test/fixtures/flake8_bandit/S101.py:8:5: S101 Use of `assert` detected
|
8 | assert x == 1
| ^^^^^^ S101
|
resources/test/fixtures/flake8_bandit/S101.py:11:5: S101 Use of `assert` detected
|
11 | assert x == 2
| ^^^^^^ S101
|
```
2023-01-21 07:15:00 -05:00
Harutaka Kawamura
eb1b5e5454
De-duplicate SIM102 ( #2050 )
...
The idea is the same as #1867 . Avoids emitting `SIM102` twice for the following code:
```python
if a:
if b:
if c:
d
```
```
resources/test/fixtures/flake8_simplify/SIM102.py:1:1: SIM102 Use a single `if` statement instead of nested `if` statements
resources/test/fixtures/flake8_simplify/SIM102.py:2:5: SIM102 Use a single `if` statement instead of nested `if` statements
```
2023-01-20 23:38:52 -05:00
Charlie Marsh
8e558a3458
Add scaffolding for flake8-type-checking extension ( #2048 )
...
This PR adds the scaffolding files for `flake8-type-checking`, along with the simplest rule (`empty-type-checking-block`), just as an example to get us started.
See: #1785 .
2023-01-20 22:41:36 -05:00
Martin Fischer
4e4643aa5d
refactor: Decouple Rule from linter prefixes
...
543865c96b introduced
RuleCode::origin() -> RuleOrigin generation via a macro, while that
signature now has been renamed to Rule::origin() -> Linter we actually
want to get rid of it since rules and linters shouldn't be this tightly
coupled (since one rule can exist in multiple linters).
Another disadvantage of the previous approach was that the prefixes
had to be defined in ruff_macros/src/prefixes.rs, which was easy to
miss when defining new linters in src/*, case in point
INP001 => violations::ImplicitNamespacePackage has in the meantime been
added without ruff_macros/src/prefixes.rs being updated accordingly
which resulted in `ruff --explain INP001` mistakenly reporting that the
rule belongs to isort (since INP001 starts with the isort prefix "I").
The derive proc macro introduced in this commit requires every variant
to have at least one #[prefix = "..."], eliminating such mistakes.
2023-01-20 20:25:57 -05:00
Martin Fischer
b19258a243
refactor: Rename RuleCodePrefix to RuleSelector
...
More accurate since the enum also encompasses:
* ALL (which isn't a prefix at all)
* fully-qualified rule codes (which aren't prefixes unless you say
they're a prefix to the empty string but that's not intuitive)
2023-01-20 20:25:57 -05:00
Martin Fischer
7fc42f8f85
refactor: Rename RuleOrigin to Linter
...
"origin" was accurate since ruff rules are currently always modeled
after one origin (except the Ruff-specific rules).
Since we however want to introduce a many-to-many mapping between codes
and rules, the term "origin" no longer makes much sense. Rules usually
don't have multiple origins but one linter implements a rule first and
then others implement it later (often inspired from another linter).
But we don't actually care much about where a rule originates from when
mapping multiple rule codes to one rule implementation, so renaming
RuleOrigin to Linter is less confusing with the many-to-many system.
2023-01-20 20:25:57 -05:00
Dmitry Dygalo
babe1eb7be
perf: Reduce allocations ( #2045 )
...
I found a few places where some allocations could be avoided.
2023-01-20 20:06:48 -05:00
Simon Brugman
608b2191aa
[flake8-executable] EXE003-005 ( #2023 )
...
Tracking issue: https://github.com/charliermarsh/ruff/issues/2024
Implementation for EXE003, EXE004 and EXE005 of `flake8-executable`
(shebang should contain "python", not have whitespace before, and should be on the first line)
Please take in mind that this is my first rust contribution.
The remaining EXE-rules are a combination of shebang (`lines.rs`), file permissions (`fs.rs`) and if-conditions (`ast.rs`). I was not able to find other rules that have interactions/dependencies in them. Any advice on how this can be best implemented would be very welcome.
For autofixing `EXE005`, I had in mind to _move_ the shebang line to the top op the file. This could be achieved by a combination of `Fix::insert` and `Fix::delete` (multiple fixes per diagnostic), or by implementing a dedicated `Fix::move`, or perhaps in other ways. For now I've left it out, but keen on hearing what you think would be most consistent with the package, and pointer where to start (if at all).
---
If you care about another testimonial:
`ruff` not only helps staying on top of the many excellent flake8 plugins and other Python code quality tools that are available, it also applies them at baffling speed.
(Planning to implement it soon for github.com/pandas-profiling/pandas-profiling (as largest contributor) and github.com/ing-bank/popmon.)
2023-01-20 18:19:07 -05:00
Eric Roberts
3939c2dbf7
Add support for pycodestyle E101 ( #2038 )
...
Rule described here: https://www.flake8rules.com/rules/E101.html
I tried to follow contributing guidelines closely, I've never worked with Rust before. Stumbled across Ruff a few days ago and would like to use it in our project, but we use a bunch of flake8 rules that are not yet implemented in ruff, so I decided to give it a go.
2023-01-20 17:24:58 -05:00
Charlie Marsh
20a9252e92
Upgrade to toml v0.5.11 ( #2040 )
...
In #1680 , we moved over to `toml_edit`. But it looks like `toml` now uses `toml_edit`, and has implemented some improvements (e.g., this closes #1894 ).
2023-01-20 17:20:45 -05:00
Hugo van Kemenade
a0e3347e43
README: --force-exclude is already set ( #2042 )
...
Re: https://github.com/charliermarsh/ruff-pre-commit/issues/19 / https://github.com/charliermarsh/ruff-pre-commit/pull/20
This is now always set, no need to include it in the README example.
2023-01-20 17:20:22 -05:00
Charlie Marsh
9e704a7c63
Only fix true-false returns for return-bool-condition-directly ( #2037 )
...
Closes #2035 .
2023-01-20 13:17:19 -05:00
Zeddicus414
c9da98e0b7
Fix D404 NoThisPrefix not working with whitespace. ( #2036 )
...
D404 should trigger for """ This is a docstring."""
Add a few tests to ensure the fix worked.
2023-01-20 13:01:31 -05:00
Charlie Marsh
5377d24507
Bump version to 0.0.228
2023-01-20 09:58:56 -05:00
Florian Best
db8e4500ee
fix(pydocstyle): Avoid trimming docstring if starts with leading quote ( #2027 )
...
Fixes : #2017
looks like the other way round is also possible to break:
```""" "foo"""`
2023-01-20 09:57:48 -05:00
Aarni Koskela
bd2de5624e
Move readme dev details to CONTRIBUTING.md and fix contradictions ( #2030 )
...
Following up on #2018/#2019 discussion, this moves the readme's development-related bits to `CONTRIBUTING.md` to avoid duplication, and fixes up the commands accordingly 😄
2023-01-20 09:23:28 -05:00
Aarni Koskela
3a81f893cc
Bump terminfo to remove a whole bunch of unnecessary dependencies ( #2022 )
...
See 6281c6b8f7
```
$ cargo update -p terminfo
Updating crates.io index
Removing cfg-if v0.1.10
Removing dirs v2.0.2
Removing getrandom v0.1.16
Removing phf v0.8.0
Updating phf_codegen v0.8.0 -> v0.11.1
Updating phf_generator v0.8.0 -> v0.11.1
Removing phf_shared v0.8.0
Removing rand v0.7.3
Removing rand_chacha v0.2.2
Removing rand_core v0.5.1
Removing rand_hc v0.2.0
Removing rand_pcg v0.2.1
Updating terminfo v0.7.3 -> v0.7.5
Removing wasi v0.9.0+wasi-snapshot-preview1
```
2023-01-20 09:09:02 -05:00
Charlie Marsh
fd6dc2a343
Use platform-appropriate newline character for LibCST embedding ( #2028 )
...
Closes #2026 .
2023-01-20 09:08:04 -05:00
Martin Fischer
8693236f9e
Make CI test add_*.py scripts
2023-01-20 08:09:54 -05:00
Martin Fischer
44e2b6208a
fix: Update add_rule.py to create new files for rules
2023-01-20 08:09:54 -05:00
Martin Fischer
16c81f75c2
fix: Update add_rule.py to account for 16e79c8d
2023-01-20 08:09:54 -05:00
Martin Fischer
e1d6ac3265
fix: Update add_plugin.py to account for 9dc66b5a
2023-01-20 08:09:54 -05:00
Martin Fischer
3aec1100f5
fix: Update add_plugin.py to account for b78b6f27
2023-01-20 08:09:54 -05:00
Martin Fischer
c00df647e1
fix: Update add_rule.py to account for 81996f1bc
2023-01-20 08:09:54 -05:00
Martin Fischer
f012877be1
Add scripts/pyproject.toml to use ruff for ruff :)
2023-01-20 08:09:54 -05:00
Martin Fischer
ff6defc988
refactor: Introduce get_indent helper for scripts
2023-01-20 08:09:54 -05:00
Martin Fischer
67ca50e9f2
refactor: Reduce code duplication in scripts/
2023-01-20 08:09:54 -05:00
Martin Fischer
6cc160bc2b
Mark scripts/add_*.py as executable
2023-01-20 08:09:54 -05:00
Ville Skyttä
4bdf506d80
Grammar fixes ( #2014 )
2023-01-20 07:44:23 -05:00
Charlie Marsh
4af2353ef9
Avoid trimming docstring if ends in trailing quote ( #2025 )
...
Closes #2017 .
2023-01-20 07:41:58 -05:00
Ville Skyttä
6072edf5bf
Note .astimezone() in call-datetime-strptime-without-zone message ( #2015 )
2023-01-20 07:40:34 -05:00
Martin Fischer
4061eeeb32
Update CI to use MSRV for cargo test and build
...
As per Cargo.toml our minimal supported Rust version is 1.65.0, so we
should be using that version in our CI for cargo test and cargo build.
This was apparently accidentally changed in
79ca66ace5 .
2023-01-20 07:39:40 -05:00
Aarni Koskela
bea6deb0c3
Port pydocstyle code 401 (ImperativeMood) ( #1999 )
...
This adds support for pydocstyle code D401 using the `imperative` crate.
2023-01-20 07:18:27 -05:00
Colin Delahunty
81db00a3c4
Pyupgrade: Extraneous parenthesis ( #1926 )
2023-01-20 00:04:07 -05:00
Charlie Marsh
cf56955ba6
Bump version to 0.0.227
2023-01-19 23:24:52 -05:00
Charlie Marsh
8a8939afd8
Avoid checking row types for single-name @parametrize decorators ( #2013 )
...
Closes #2008 .
2023-01-19 22:13:17 -05:00
Martin Fischer
6acf2accc6
Improve --explain output
...
Previous output for `ruff --explain E711`:
E711 (pycodestyle): Comparison to `None` should be `cond is None`
New output:
none-comparison
Code: E711 (pycodestyle)
Autofix is always available.
Message formats:
* Comparison to `None` should be `cond is None`
* Comparison to `None` should be `cond is not None`
2023-01-19 22:08:00 -05:00
Charlie Marsh
ec0c7647ab
Avoid SIM401 in elif blocks ( #2012 )
...
For now, we're just gonna avoid flagging this for `elif` blocks, following the same reasoning as for ternaries. We can handle all of these cases, but we'll knock out the TODOs as a pair, and this avoids broken code.
Closes #2007 .
2023-01-19 21:57:18 -05:00
Charlie Marsh
045229630e
Upgrade RustPython ( #2011 )
...
This lets us revert the "manual" fix introduced in #1944 .
2023-01-19 21:49:12 -05:00
Martin Fischer
c600991905
Change AsRef<str> impl for Rule to kebab-case
...
As we surface rule names more to users we want
them to be easier to type than PascalCase.
Prior art:
Pylint and ESLint also use kebab-case for their rule names.
Clippy uses snake_case but only for syntactical reasons
(so that the argument to e.g. #![allow(clippy::some_lint)]
can be parsed as a path[1]).
[1]: https://doc.rust-lang.org/reference/paths.html
2023-01-19 21:37:11 -05:00
Charlie Marsh
f6a93a4c3d
Enable autofix for FitsOnOneLine (D200) ( #2006 )
...
Closes #1965 .
2023-01-19 19:24:50 -05:00
Aarni Koskela
de54ff114e
Add RUF005 "unpack instead of concatenating" check ( #1957 )
...
This PR adds a new check that turns expressions such as `[1, 2, 3] + foo` into `[1, 2, 3, *foo]`, since the latter is easier to read and faster:
```
~ $ python3.11 -m timeit -s 'b = [6, 5, 4]' '[1, 2, 3] + b'
5000000 loops, best of 5: 81.4 nsec per loop
~ $ python3.11 -m timeit -s 'b = [6, 5, 4]' '[1, 2, 3, *b]'
5000000 loops, best of 5: 66.2 nsec per loop
```
However there's a couple of gotchas:
* This felt like a `simplify` rule, so I borrowed an unused `SIM` code even if the upstream `flake8-simplify` doesn't do this transform. If it should be assigned some other code, let me know 😄
* **More importantly** this transform could be unsafe if the other operand of the `+` operation has overridden `__add__` to do something else. What's the `ruff` policy around potentially unsafe operations? (I think some of the suggestions other ported rules give could be semantically different from the original code, but I'm not sure.)
* I'm not a very established Rustacean, so there's no doubt my code isn't quite idiomatic. (For instance, is there a neater way to write that four-way `match` statement?)
Thanks for `ruff`, by the way! :)
2023-01-19 17:38:17 -05:00
Charlie Marsh
64b398c72b
Tweak some instructions in CONTRIBUTING.md
2023-01-19 17:17:39 -05:00
Aarni Koskela
c99bd3fa60
Split up pydocstyle rules ( #2003 )
...
As per @not-mAs per @not-my-profile's [comment](https://github.com/charliermarsh/ruff/pull/1999#discussion_r1081579337 ):
> we actually want to break up such rules.rs files into smaller files
this breaks up `pydocstyle/rules.rs` into a directory.y-profile's [comment](https://github.com/charliermarsh/ruff/pull/1999#discussion_r1081579337 ):
> we actually want to break up such rules.rs files into smaller files
this breaks up `pydocstyle/rules.rs` into a directory.
2023-01-19 13:17:25 -05:00
Martin Fischer
8ac930f886
Fix that --explain panics
...
This commit fixes a bug accidentally introduced in
6cf770a692 ,
which resulted every `ruff --explain <code>` invocation to fail with:
thread 'main' panicked at 'Mismatch between definition and access of `explain`.
Could not downcast to ruff::registry::Rule, need to downcast to &ruff::registry::Rule',
ruff_cli/src/cli.rs:184:18
We also add an integration test for --explain to prevent such bugs from
going by unnoticed in the future.
2023-01-19 12:58:44 -05:00
Charlie Marsh
ad80fdc2cd
Avoid SIM201 and SIM202 errors in __ne__ et al ( #2001 )
...
Closes #1986 .
2023-01-19 11:27:27 -05:00
Aarni Koskela
a0ea8fe22f
Apply #[derive(Default)] fixes suggested by Clippy ( #2000 )
...
These were bugging me every time I ran `clippy` 😁
2023-01-19 11:04:43 -05:00
Martin Fischer
3c3da8a88c
derive-msg-formats 5/5: Remove placeholder implementations
...
# This commit has been generated via the following Python script:
# (followed by `cargo +nightly fmt` and `cargo dev generate-all`)
# For the reasoning see the previous commit(s).
import re
import sys
for path in (
'src/violations.rs',
'src/rules/flake8_tidy_imports/banned_api.rs',
'src/rules/flake8_tidy_imports/relative_imports.rs',
):
with open(path) as f:
text = ''
while line := next(f, None):
if line.strip() != 'fn message(&self) -> String {':
text += line
continue
text += ' #[derive_message_formats]\n' + line
body = next(f)
while (line := next(f)) != ' }\n':
body += line
# body = re.sub(r'(?<!code\| |\.push\()format!', 'format!', body)
body = re.sub(
r'("[^"]+")\s*\.to_string\(\)', r'format!(\1)', body, re.DOTALL
)
body = re.sub(
r'(r#".+?"#)\s*\.to_string\(\)', r'format!(\1)', body, re.DOTALL
)
text += body + ' }\n'
while (line := next(f)).strip() != 'fn placeholder() -> Self {':
text += line
while (line := next(f)) != ' }\n':
pass
with open(path, 'w') as f:
f.write(text)
2023-01-19 11:03:32 -05:00
Martin Fischer
16e79c8db6
derive-msg-formats 4/5: Implement #[derive_message_formats]
...
The idea is nice and simple we replace:
fn placeholder() -> Self;
with
fn message_formats() -> &'static [&'static str];
So e.g. if a Violation implementation defines:
fn message(&self) -> String {
format!("Local variable `{name}` is assigned to but never used")
}
it would also have to define:
fn message_formats() -> &'static [&'static str] {
&["Local variable `{name}` is assigned to but never used"]
}
Since we however obviously do not want to duplicate all of our format
strings we simply introduce a new procedural macro attribute
#[derive_message_formats] that can be added to the message method
declaration in order to automatically derive the message_formats
implementation.
This commit implements the macro. The following and final commit
updates violations.rs to use the macro. (The changes have been separated
because the next commit is autogenerated via a Python script.)
2023-01-19 11:03:32 -05:00
Martin Fischer
8f6d8e215c
derive-msg-formats 3/5: Introduce Violation::AUTOFIX associated constant
...
ruff_dev::generate_rules_table previously documented which rules are
autofixable via DiagnosticKind::fixable ... since the DiagnosticKind was
obtained via Rule::kind (and Violation::placeholder) which we both want
to get rid of we have to obtain the autofixability via another way.
This commit implements such another way by adding an AUTOFIX
associated constant to the Violation trait. The constant is of the type
Option<AutoFixkind>, AutofixKind is a new struct containing an
Availability enum { Sometimes, Always}, letting us additionally document
that some autofixes are only available sometimes (which previously
wasn't documented). We intentionally introduce this information in a
struct so that we can easily introduce further autofix metadata in the
future such as autofix applicability[1].
[1]: https://doc.rust-lang.org/stable/nightly-rustc/rustc_errors/enum.Applicability.html
2023-01-19 11:03:32 -05:00
Martin Fischer
8993baab01
derive-msg-formats 2/5: Remove DiagnosticKind::summary
...
While ruff displays the string returned by Violation::message in its
output for detected violations the messages displayed in the README
and in the `--explain <code>` output previously used the
DiagnosticKind::summary() function which for some verbose messages
provided shorter descriptions.
This commit removes DiagnosticKind::summary, and moves the more
extensive documentation into doc comments ... these are not displayed
yet to the user but doing that is very much planned.
2023-01-19 11:03:32 -05:00
Martin Fischer
2568627c4c
derive-msg-formats 1/5: Remove unnecessary usages of Rule::kind
...
This commit series removes the following associated
function from the Violation trait:
fn placeholder() -> Self;
ruff previously used this placeholder approach for the messages it
listed in the README and displayed when invoked with --explain <code>.
This approach is suboptimal for three reasons:
1. The placeholder implementations are completely boring code since they
just initialize the struct with some dummy values.
2. Displaying concrete error messages with arbitrary interpolated values
can be confusing for the user since they might not recognize that the
values are interpolated.
3. Some violations have varying format strings depending on the
violation which could not be documented with the previous approach
(while we could have changed the signature to return Vec<Self> this
would still very much suffer from the previous two points).
We therefore drop Violation::placeholder in favor of a new macro-based
approach, explained in commit 4/5.
Violation::placeholder is only invoked via Rule::kind, so we firstly
have to get rid of all Rule::kind invocations ... this commit starts
removing the trivial cases.
2023-01-19 11:03:32 -05:00
Martin Fischer
9603a024b3
refactor: Move a bunch of pandas-vet logic to rules::pandas_vet
2023-01-19 11:03:32 -05:00
Charlie Marsh
a122d95ef5
Preserve unmatched comparators in SIM109 ( #1998 )
...
Closes #1993 .
2023-01-19 10:23:20 -05:00
Damien Allen
6ddfe50ac4
Added pylint formatter ( #1995 )
...
Fixes : #1953
@charliermarsh thank you for the tips in the issue.
I'm not very familiar with Rust, so please excuse if my string formatting syntax is messy.
In terms of testing, I compared output of `flake8 --format=pylint ` and `cargo run --format=pylint` on the same code and the output syntax seems to check out.
2023-01-19 08:01:27 -05:00
Martin Fischer
26901a78c9
Make define_rule_mapping! set rule code as doc comment of variants
...
Since the UI still relies on the rule codes this improves the developer
experience by letting developers view the code of a Rule enum variant by
hovering over it.
2023-01-19 07:37:16 -05:00
Martin Fischer
6649225167
rule 8/8: Automatically rewrite RuleCode to Rule
...
# This commit was automatically generated by running the following
# script (followed by `cargo +nightly fmt`):
import glob
import re
from typing import NamedTuple
class Rule(NamedTuple):
code: str
name: str
path: str
def rules() -> list[Rule]:
"""Returns all the rules defined in `src/registry.rs`."""
file = open('src/registry.rs')
rules = []
while next(file) != 'ruff_macros::define_rule_mapping!(\n':
continue
while (line := next(file)) != ');\n':
line = line.strip().rstrip(',')
if line.startswith('//'):
continue
code, path = line.split(' => ')
name = path.rsplit('::')[-1]
rules.append(Rule(code, name, path))
return rules
code2name = {r.code: r.name for r in rules()}
for pattern in ('src/**/*.rs', 'ruff_cli/**/*.rs', 'ruff_dev/**/*.rs', 'scripts/add_*.py'):
for name in glob.glob(pattern, recursive=True):
with open(name) as f:
text = f.read()
text = re.sub('Rule(?:Code)?::([A-Z]\w+)', lambda m: 'Rule::' + code2name[m.group(1)], text)
text = re.sub(r'(?<!"<FilePattern>:<)RuleCode\b', 'Rule', text)
text = re.sub('(use crate::registry::{.*, Rule), Rule(.*)', r'\1\2', text) # fix duplicate import
with open(name, 'w') as f:
f.write(text)
2023-01-18 23:51:48 -05:00
Martin Fischer
9e3083aa2c
rule 7/8: Change Rule enum definition
2023-01-18 23:51:48 -05:00
Martin Fischer
6d11ff3822
rule 6/8: Remove Serialize & Deserialize impls for Rule
2023-01-18 23:51:48 -05:00
Martin Fischer
6cf770a692
rule 5/8: Remove FromStr impl for Rule
2023-01-18 23:51:48 -05:00
Martin Fischer
3534e370e1
rule 4/8: Remove Display impl for Rule
2023-01-18 23:51:48 -05:00
Martin Fischer
dbcab5128c
rule 3/8: Remove AsRef<str> impl for Rule
2023-01-18 23:51:48 -05:00
Martin Fischer
3810250bb6
rule 2/8: Rename DiagnosticKind::code to rule
2023-01-18 23:51:48 -05:00
Martin Fischer
3c1c1e1dd3
rule 1/8: Rename RuleCode to Rule (backwards-compatible for now)
...
This commit series refactors ruff to decouple "rules" from "rule codes",
in order to:
1. Make our code more readable by changing e.g.
RuleCode::UP004 to Rule::UselessObjectInheritance.
2. Let us cleanly map multiple codes to one rule, for example:
[UP004] in pyupgrade, [R0205] in pylint and [PIE792] in flake8-pie
all refer to the rule UselessObjectInheritance but ruff currently
only associates that rule with the UP004 code (since the
implementation was initially modeled after pyupgrade).
3. Let us cleanly map one code to multiple rules, for example:
[C0103] from pylint encompasses N801, N802 and N803 from pep8-naming.
The latter two steps are not yet implemented by this commit series
but this refactoring enables us to introduce such a mapping. Such a
mapping would also let us expand flake8_to_ruff to support e.g. pylint.
After the next commit which just does some renaming the following four
commits remove all trait derivations from the Rule (previously RuleCode)
enum that depend on the variant names to guarantee that they are not
used anywhere anymore so that we can rename all of these variants in the
eigth and final commit without breaking anything.
While the plan very much is to also surface these human-friendly names
more in the user interface this is not yet done in this commit series,
which does not change anything about the UI: it's purely a refactor.
[UP004]: pyupgrade doesn't actually assign codes to its messages.
[R0205]: https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/useless-object-inheritance.html
[PIE792]: https://github.com/sbdchd/flake8-pie#pie792-no-inherit-object
[C0103]: https://pylint.pycqa.org/en/latest/user_guide/messages/convention/invalid-name.html
2023-01-18 23:51:48 -05:00
Martin Fischer
5b7bd93b91
refactor: Use Self:: in match arms
2023-01-18 23:51:48 -05:00
Martin Fischer
9e096b4a4c
refactor: Make define_rule_mapping! generate RuleCodePrefix directly
2023-01-18 23:51:48 -05:00
Charlie Marsh
d8645acd1f
Bump version to 0.0.226
2023-01-18 20:54:38 -05:00
Charlie Marsh
92dd073191
Add Pylint settings to lib_wasm.rs
2023-01-18 20:54:03 -05:00
Charlie Marsh
ff96219e62
Exclude None, Bool, and Ellipsis from ConstantType ( #1988 )
...
These have no effect, so it's confusing that they're even settable.
2023-01-18 20:50:09 -05:00
Charlie Marsh
d33424ec9d
Enable suppression of magic values by type ( #1987 )
...
Closes #1949 .
2023-01-18 20:44:24 -05:00
Charlie Marsh
34412a0a01
Avoid removing side effects for boolean simplifications ( #1984 )
...
Closes #1978 .
2023-01-18 19:08:14 -05:00
Charlie Marsh
ceb48d3a32
Use relative paths for INP001 ( #1981 )
2023-01-18 18:45:47 -05:00
Charlie Marsh
969a6f0d53
Replace misplaced-comparison-constant with SIM300 ( #1980 )
...
Closes : #1954 .
2023-01-18 18:42:49 -05:00
Charlie Marsh
7628876ff2
Invert order of yoda-conditions message ( #1979 )
...
The suggestion was wrong!
2023-01-18 18:27:36 -05:00
Charlie Marsh
ef355e5c2c
Remove artificial wraps from GitHub messages ( #1977 )
2023-01-18 18:20:56 -05:00
Charlie Marsh
97f55b8e97
Convert remaining call path sites to use SmallVec ( #1972 )
2023-01-18 14:50:33 -05:00
Aarni Koskela
ff2be35f51
Run cargo fmt in pre-commit ( #1968 )
...
Since `cargo fmt` is a required CI check, we could just as well run it in `pre-commit`.
2023-01-18 13:14:51 -05:00
Anders Kaseorg
1e803f7108
README: Link “Flake8” for consistency with the rest of the list ( #1969 )
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 13:07:21 -05:00
Charlie Marsh
1ab0273aa7
Strip whitespace when injecting D209 newline ( #1967 )
...
Closes #1963 .
2023-01-18 12:09:17 -05:00
Charlie Marsh
5a7d8c25f4
Treat subscript accesses as unsafe effects for autofix ( #1966 )
...
See: #1809 .
2023-01-18 11:46:12 -05:00
Charlie Marsh
26d6414558
Fix UP003 check from rebase
2023-01-18 11:39:39 -05:00
Charlie Marsh
dae95626ae
Use smallvec for call path representation ( #1960 )
...
This provides a ~10% speed-up for large codebases with `--select ALL`:

2023-01-18 11:29:05 -05:00
Maksudul Haque
9a3e525930
[isort] Add no-lines-before Option ( #1955 )
...
Closes https://github.com/charliermarsh/ruff/issues/1916 .
2023-01-18 11:09:47 -05:00
Anders Kaseorg
b9c6cfc0ab
Autofix SIM117 (MultipleWithStatements) ( #1961 )
...
This is slightly buggy due to Instagram/LibCST#855 ; it will complain `[ERROR] Failed to fix nested with: Failed to extract CST from source` when trying to fix nested parenthesized `with` statements lacking trailing commas. But presumably people who write parenthesized `with` statements already knew that they don’t need to nest them.
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 11:06:04 -05:00
Charlie Marsh
b1f10c8339
Confine type-of-primitive checks to builtin type calls ( #1962 )
...
Closes #1958 .
2023-01-18 10:53:50 -05:00
Anders Kaseorg
83346de6e0
Autofix SIM102 (NestedIfStatements)
...
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 07:37:27 -05:00
Anders Kaseorg
b23cc31863
Change ast::helpers::has_coments to accept a Range
...
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 07:37:27 -05:00
Anders Kaseorg
462d81beb7
Ensure ast::whitespace::indentation extracts whitespace
...
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 07:37:27 -05:00
Anders Kaseorg
715ea2d374
Accept a Locator for ast::whitespace::indentation
...
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 07:37:27 -05:00
skykasko
6c7e60b4f9
Fix bad link for flake8-no-pep420 ( #1952 )
...
See https://github.com/charliermarsh/ruff/pull/1942 .
2023-01-18 07:36:05 -05:00
Maksudul Haque
868d0b3e29
[isort] Add constants and variables Options ( #1951 )
...
closes https://github.com/charliermarsh/ruff/issues/1819
2023-01-18 07:30:51 -05:00
Charlie Marsh
cdb4700813
Bump version to 0.0.225
2023-01-18 00:22:48 -05:00
Anders Kaseorg
ea4d54a90f
Restrict SIM105 to try blocks with a body of one simple statement ( #1948 )
...
If a `try` block has multiple statements, a compound statement, or
control flow, rewriting it with `contextlib.suppress` would obfuscate
the fact that the exception still short-circuits further statements in
the block.
Fixes #1947 .
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-18 00:22:22 -05:00
Charlie Marsh
51b917cfbf
Exempt contextlib.ExitStack() for SIM115 rules ( #1946 )
...
Since our binding tracking is somewhat limited, I opted to favor false negatives over false positives. So, e.g., this won't trigger SIM115:
```py
with contextlib.ExitStack():
f = exit_stack.enter_context(open("filename"))
```
(Notice that `exit_stack` is unbound.)
The alternative strategy required us to incorrectly trigger SIM115 on this:
```py
with contextlib.ExitStack() as exit_stack:
exit_stack_ = exit_stack
f = exit_stack_.enter_context(open("filename"))
```
Closes #1945 .
2023-01-17 22:39:54 -05:00
Edgar R. M
c880d744fd
Implement flake8-no-pep420 ( #1942 )
...
Closes https://github.com/charliermarsh/ruff/issues/1844 .
2023-01-17 22:10:32 -05:00
Charlie Marsh
84d1df08be
Avoid broken autofix for SIM103 with elif ( #1944 )
...
Also adjusts the generator to avoid the extra parentheses (and skips commented `if` statements).
Closes #1943 .
2023-01-17 22:03:17 -05:00
Charlie Marsh
b9bb5acff8
Remove unnecessary setuptools block
2023-01-17 21:17:37 -05:00
Charlie Marsh
ca7c3c2175
Avoid autofixing comma rules when --fix is not set ( #1940 )
...
Closes #1939 .
2023-01-17 20:09:01 -05:00
Charlie Marsh
8891e2e62b
Fix name of ruff-pre-commit event
2023-01-17 17:25:02 -05:00
Martin Fischer
53265e0ed4
cli: Catch panics to tell the user to report them ( #1928 )
2023-01-17 17:17:09 -05:00
Charlie Marsh
072849a8a9
Move @functools.cache rewrites to their own rule ( #1938 )
...
Closes #1934 .
2023-01-17 15:12:40 -05:00
Charlie Marsh
70ea4b25e8
Allow duplicate enum values for enum.auto() ( #1933 )
...
Closes #1932 .
2023-01-17 11:14:11 -05:00
Martin Fischer
30e133f3d8
refactor: Declare defaults once in settings::defaults
2023-01-17 09:20:57 -05:00
Martin Fischer
aa812de07e
refactor: Implement Default for Settings
2023-01-17 09:20:57 -05:00
Martin Fischer
57ac6a8444
refactor: Make resolve_codes take IntoIterator instead of Iterator
2023-01-17 09:20:57 -05:00
Martin Fischer
a6566b1b34
refactor: Merge Settings.enabled and Settings.fixable
...
The Settings struct previously contained the fields:
pub enabled: HashableHashSet<RuleCode>,
pub fixable: HashableHashSet<RuleCode>,
This commit merges both fields into one by introducing a new
RuleTable type, wrapping HashableHashMap<RuleCode, bool>,
which has the following benefits:
1. It makes the invalid state that a rule is
disabled but fixable unrepresentable.
2. It encapsulates the implementation details of the table.
(It currently uses an FxHashMap but that may change.)
3. It results in more readable code.
settings.rules.enabled(rule)
settings.rules.should_fix(rule)
is more readable than:
settings.enabled.contains(rule)
settings.fixable.contains(rule)
2023-01-17 09:20:57 -05:00
Martin Fischer
580da1fa6b
refactor: Group Settings fields
2023-01-17 09:20:57 -05:00
Martin Fischer
b78b6f275e
refactor: Define origin names & URLs within doc comments
2023-01-17 07:44:40 -05:00
Martin Fischer
6868bb46f5
refactor: Get rid of Platform enum
2023-01-17 07:44:40 -05:00
Martin Fischer
601848d9a8
refactor: Rename RuleOrigin::title to RuleOrigin::name
2023-01-17 07:44:40 -05:00
Martin Fischer
f4da7635f0
Add missing url for flake8-import-conventions
2023-01-17 07:44:40 -05:00
Charlie Marsh
74a8a218f3
Bump version to 0.0.224
2023-01-16 23:43:14 -05:00
Colin Delahunty
1730f2a603
[pyupgrade] Automatically rewrite format-strings to f-strings ( #1905 )
2023-01-16 23:06:39 -05:00
Charlie Marsh
a4862857de
Update PIE796 fixture
2023-01-16 19:29:14 -05:00
Leonardo Esparis
6e88c60c46
Add flake8-pie PIE796: prefer-unique-enum ( #1923 )
...
I accept any suggestion. By the way, I have a doubt, I have checked and all flake8-pie plugins can be fixed by ruff, but is it necessary that this one is also fixed automatically ?
rel #1543
2023-01-16 19:27:34 -05:00
Charlie Marsh
2ed1f78873
Add benchmark scripts for no-IO ( #1925 )
2023-01-16 17:38:40 -05:00
Charlie Marsh
f3bf008aed
Avoid removing statements that contain side-effects ( #1920 )
...
Closes #1917 .
2023-01-16 14:45:02 -05:00
Charlie Marsh
3b4aaa53c1
Add some new testimonials ( #1921 )
2023-01-16 14:44:52 -05:00
Charlie Marsh
6abf71639f
Avoid syntax errors when fixing parenthesized unused variables ( #1919 )
...
Closes #1917 .
2023-01-16 14:27:41 -05:00
Charlie Marsh
c0845a8c28
Rewrite lru_cache to cache on Python 3.9+ ( #1918 )
...
Closes #1913 .
2023-01-16 13:14:27 -05:00
Paul Barrett
019ecc4add
Trigger update to pre-commit mirror after pypi publish ( #1910 )
2023-01-16 13:14:18 -05:00
Martin Fischer
f4cf48d885
refactor: Move rule-specific details out of mod.rs via type aliases
2023-01-16 11:27:24 -05:00
Martin Fischer
005f5d7911
refactor: Make flake8_tidy_imports::Settings derive Default
2023-01-16 11:27:24 -05:00
Martin Fischer
2fce580693
refactor: Move flake8_tidy_imports Settings to mod.rs
2023-01-16 11:27:24 -05:00
Martin Fischer
8862565a0f
refactor: Split ruff::rules::flake8_tidy_imports::rules
2023-01-16 11:27:24 -05:00
Martin Fischer
5bf6da0db7
refactor: Rename BannedRelativeImport to RelativeImports
...
The idea is to follow the Rust naming convention for lints[1]:
> the lint name should make sense when read as
> "allow lint-name" or "allow lint-name items"
Following that convention prefixing "Banned" is
redundant as it could be prefixed to any lint name.
[1]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
2023-01-16 11:27:24 -05:00
Martin Fischer
ee655c1a88
refactor: Rename BannedApi to ApiBan to distinguish it from the violation struct
2023-01-16 11:27:24 -05:00
Harutaka Kawamura
2236b4bd59
Add backticks to B904's message ( #1914 )
...
This PR adds backticks to B904's message to improve readability.
Without backticks:
<img width="1480" alt="image" src="https://user-images.githubusercontent.com/17039389/212682457-71f13de9-e3dd-4ead-a82b-98e5b60653c2.png ">
With backticks:
<img width="1480" alt="image" src="https://user-images.githubusercontent.com/17039389/212682775-36868401-b63e-47d1-ae25-b43b61866b6c.png ">
2023-01-16 11:12:43 -05:00
Charlie Marsh
fbf311f7d5
Add instructions for Pyupgrade benchmark
2023-01-16 03:21:31 -05:00
Martin Fischer
8c18b28bc4
Derive Hash instead of implementing it by hand
...
The caching mechanism of the CLI (ruff_cli::cache) relies on
ruff::settings::Settings implementing the Hash trait.
The ruff::settings::Settings struct previously couldn't automatically
derive the Hash implementation via the #[derive(Hash)] macro attribute
since some of its field types intentionally[1][2] don't implement Hash
(namely regex::Regex, globset::GlobMatcher and globset::GlobSet and
HashMap and HashSet from the standard library).
The code therefore previously implemented the Hash trait by hand for the
whole struct. Implementing Hash by hand for structs that are subject to
change is a bad idea since it's very easy to forget to update the Hash
implementation when adding a new field to the struct. And the Hash
implementation indeed was already incorrect by omitting several fields
from the hash.
This commit introduces wrapper types for Regex, GlobMatcher, GlobSet,
HashSet & HashMap that implement Hash so that we can still add
#[derive(Hash)] to the Settings struct, guaranteeing a correct hash
implementation.
[1]: https://github.com/rust-lang/regex/issues/364#issuecomment-301082076
[2]: The standard library doesn't impl<T: Hash + Ord> Hash for HashSet<T>
presumably since sorted() requires an allocation and Hash
implementations are generally expected to work without allocations.
2023-01-16 01:42:55 -05:00
Charlie Marsh
42031b8574
Re-run benchmark and update documentation ( #1907 )
...
Closes #269 .
2023-01-16 01:38:58 -05:00
Charlie Marsh
3a3a5fcd81
Remove -dev suffix from flake8_to_ruff
2023-01-15 22:45:14 -05:00
Charlie Marsh
e8577d5e26
Bump version to 0.0.223
2023-01-15 22:44:01 -05:00
Charlie Marsh
bcb1e6ba20
Add flake8-commas to the README
2023-01-15 22:43:29 -05:00
Charlie Marsh
15403522c1
Avoid triggering SIM117 for async with statements ( #1903 )
...
Actually, it looks like _none_ of the existing rules should be triggered on async `with` statements.
Closes #1902 .
2023-01-15 21:42:36 -05:00
messense
cb4f305ced
Lock stdout once when printing diagnostics ( #1901 )
...
https://doc.rust-lang.org/stable/std/io/struct.Stdout.html
> Each handle shares a global buffer of data to be written to the standard output stream.
> Access is also synchronized via a lock and
> explicit control over locking is available via the [`lock`](https://doc.rust-lang.org/stable/std/io/struct.Stdout.html#method.lock ) method.
2023-01-15 21:04:00 -05:00
Charlie Marsh
d71a615b18
Buffer diagnostic writes to stdout ( #1900 )
2023-01-15 19:34:15 -05:00
Charlie Marsh
dfc2a34878
Remove rogue println
2023-01-15 18:59:59 -05:00
Charlie Marsh
7608087776
Don't require docstrings for setters and deleters ( #1899 )
2023-01-15 18:57:38 -05:00
Charlie Marsh
228f033e15
Skip noqa checker if no diagnostics are found ( #1898 )
2023-01-15 18:53:00 -05:00
Martin Fischer
d75d6d7c7c
refactor: Split CliSettings from Settings
...
We want to automatically derive Hash for the library settings, which
requires us to split off all the settings unused by the library
(since these shouldn't affect the hash used by ruff_cli::cache).
2023-01-15 15:19:42 -05:00
Martin Fischer
ef80ab205c
Mark Settings::for_rule(s) as test-only
2023-01-15 15:19:42 -05:00
Ran Benita
d3041587ad
Implement flake8-commas ( #1872 )
...
Implements [flake8-commas](https://github.com/PyCQA/flake8-commas ). Fixes #1058 .
The plugin is mostly redundant with Black (and also deprecated upstream), but very useful for projects which can't/won't use an auto-formatter.
This linter works on tokens. Before porting to Rust, I cleaned up the Python code ([link](https://gist.github.com/bluetech/7c5dcbdec4a73dd5a74d4bc09c72b8b9 )) and made sure the tests pass. In the Rust version I tried to add explanatory comments, to the best of my understanding of the original logic.
Some changes I did make:
- Got rid of rule C814 - "missing trailing comma in Python 2". Ruff doesn't support Python 2.
- Merged rules C815 - "missing trailing comma in Python 3.5+" and C816 - "missing trailing comma in Python 3.6+" into C812 - "missing trailing comma". These Python versions are outdated, didn't think it was worth the complication.
- Added autofixes for C812 and C819.
Autofix is missing for C818 - "trailing comma on bare tuple prohibited". It needs to turn e.g. `x = 1,` into `x = (1, )`, it's a bit difficult to do with tokens only, so I skipped it for now.
I ran the rules on cpython/Lib and on a big internal code base and it works as intended (though I only sampled the diffs).
2023-01-15 14:03:32 -05:00
Harutaka Kawamura
8d912404b7
Use more precise error ranges for RET505~508 ( #1895 )
2023-01-15 13:54:24 -05:00
Tom Fryers
85bdb45eca
Improve magic value message wording ( #1892 )
...
The message previously specified 'number', but the error applies to more types.
2023-01-15 12:53:02 -05:00
messense
c7d0d26981
Update add plugin/rule scripts ( #1889 )
...
Adjusted some file locations and changed to use [`pathlib`](https://docs.python.org/3/library/pathlib.html ) instead of `os.path`.
2023-01-15 12:49:42 -05:00
Charlie Marsh
5c6753e69e
Remove some Clippy allows ( #1888 )
2023-01-15 02:32:36 -05:00
Charlie Marsh
3791ca721a
Add a dedicated token indexer for continuations and comments ( #1886 )
...
The primary motivation is that we can now robustly detect `\` continuations due to the addition of `Tok::NonLogicalNewline`. This PR generalizes the approach we took to comments (track all lines that contain any comments), and applies it to continuations too.
2023-01-15 01:57:31 -05:00
Charlie Marsh
2c644619e0
Convert confusable violations to named fields ( #1887 )
...
See: #1871 .
2023-01-15 01:56:18 -05:00
Martin Fischer
81996f1bcc
Convert define_rule_mapping! to a procedural macro
...
define_rule_mapping! was previously implemented as a declarative macro,
which was however partially relying on an origin_by_code! proc macro
because declarative macros cannot match on substrings of identifiers.
Currently all define_rule_mapping! lines look like the following:
TID251 => violations::BannedApi,
TID252 => violations::BannedRelativeImport,
We want to break up violations.rs, moving the violation definitions to
the respective rule modules. To do this we want to change the previous
lines to:
TID251 => rules::flake8_tidy_imports::banned_api::BannedApi,
TID252 => rules::flake8_tidy_imports::relative_imports::RelativeImport,
This however doesn't work because the define_rule_mapping! macro is
currently defined as:
($($code:ident => $mod:ident::$name:ident,)+) => { ... }
That is it only supported $module::$name but not longer paths with
multiple modules. While we could define `=> $path:path`[1] then we
could no longer access the last path segment, which we need because
we use it for the DiagnosticKind variant names. And
`$path:path::$last:ident` doesn't work either because it would be
ambiguous (Rust wouldn't know where the path ends ... so path fragments
have to be followed by some punctuation/keyword that may not be part of
paths). And we also cannot just introduce a procedural macro like
path_basename!(...) because the following is not valid Rust code:
enum Foo { foo!(...), }
(macros cannot be called in the place where you define variants.)
So we have to convert define_rule_mapping! into a proc macro in order to
support paths of arbitrary length and this commit implements that.
[1]: https://doc.rust-lang.org/reference/macros-by-example.html#metavariables
2023-01-15 01:54:57 -05:00
Charlie Marsh
e3cc918b93
Bump version to 0.0.222
2023-01-14 23:34:53 -05:00
Charlie Marsh
d864477876
Turn doc references into links ( #1878 )
2023-01-14 23:27:45 -05:00
Charlie Marsh
e1ced89624
Document breaking --max-complexity change
2023-01-14 23:22:38 -05:00
Martin Fischer
4470d7ba04
Make the CI check for broken links in the Rust docs ( #1883 )
2023-01-14 23:18:17 -05:00
Harutaka Kawamura
2a1601749f
Fix range of SIM201, 202, and 208 ( #1880 )
...
Before
```
resources/test/fixtures/flake8_simplify/SIM208.py:1:13: SIM208 Use `a` instead of `not (not a)`
|
1 | if not (not a): # SIM208
| ^ SIM208
|
= help: Replace with `a`
resources/test/fixtures/flake8_simplify/SIM208.py:4:14: SIM208 Use `a == b` instead of `not (not a == b)`
|
4 | if not (not (a == b)): # SIM208
| ^^^^^^ SIM208
|
= help: Replace with `a == b`
```
After
```
resources/test/fixtures/flake8_simplify/SIM208.py:1:4: SIM208 Use `a` instead of `not (not a)`
|
1 | if not (not a): # SIM208
| ^^^^^^^^^^^ SIM208
|
= help: Replace with `a`
resources/test/fixtures/flake8_simplify/SIM208.py:4:4: SIM208 Use `a == b` instead of `not (not a == b)`
|
4 | if not (not (a == b)): # SIM208
| ^^^^^^^^^^^^^^^^^^ SIM208
|
= help: Replace with `a == b`
```
2023-01-14 21:17:32 -05:00
Charlie Marsh
a01edad1c4
Remove --max-complexity from the CLI ( #1877 )
2023-01-14 18:27:23 -05:00
Martin Fischer
a81ac6705d
Make ruff::source_code::{Generator, Locator, Stylist} private
2023-01-14 18:23:59 -05:00
Martin Fischer
d77675f30d
Make ruff::{ast, autofix, directives, rustpython_helpers} private
2023-01-14 18:23:59 -05:00
Martin Fischer
fe7658199d
Make ruff::violations private
2023-01-14 18:23:59 -05:00
Martin Fischer
cfa25ea4b0
Make ruff::rules private
2023-01-14 18:23:59 -05:00
Martin Fischer
c7f0f3b237
Regenerate insta snapshots
2023-01-14 11:48:02 -05:00
Martin Fischer
3b36030461
Introduce ruff::rules module
...
Resolves #1547 .
2023-01-14 11:48:02 -05:00
Charlie Marsh
812df77246
Add Dagster and SnowCLI
2023-01-14 10:45:16 -05:00
Martin Fischer
69b356e9b9
Add top-level doc comments for crates
...
Test by running:
cargo doc --no-deps --all --open
2023-01-14 10:11:30 -05:00
Martin Fischer
033d7d7e91
Disable doc generation for the ruff_cli binary
2023-01-14 10:11:30 -05:00
Martin Fischer
a181ca7a3d
Reduce the API of ruff_cli to ruff_cli::help()
2023-01-14 10:11:30 -05:00
Martin Fischer
92124001d5
Turn ruff_dev into a bin-only crate
2023-01-14 10:11:30 -05:00
Martin Fischer
06b389c5bc
Turn flake8_to_ruff into a bin-only crate
2023-01-14 10:11:30 -05:00
Thomas MK
9dc66b5a65
Split up the table corresponding to the pylint rules ( #1868 )
...
This makes it easier to see which rules you're enabling when selecting
one of the pylint codes (like `PLC`). This also makes it clearer what
those abbreviations stand for. When I first saw the pylint section, I
was very confused by that, so other might be as well.
See it rendered here:
https://github.com/thomkeh/ruff/blob/patch-1/README.md#pylint-plc-ple-plr-plw
2023-01-14 08:07:02 -05:00
Ran Benita
3447dd3615
Bump RustPython ( #1836 )
...
This bumps RustPython so we can use the new `NonLogicalNewline` token.
A couple of rules needed a fix due to the new token. There might be more
that are not caught by tests (anything working with tokens directly with
lookaheads), I hope not.
2023-01-14 08:03:27 -05:00
Harutaka Kawamura
42cb106377
Improve SIM117 ( #1867 )
...
This PR makes the following changes to improve `SIM117`:
- Avoid emitting `SIM117` multiple times within the same `with`
statement:
- Adjust the error range.
## Example
```python
with A() as a: # SIM117
with B() as b:
with C() as c:
print("hello")
```
### Current
```
resources/test/fixtures/flake8_simplify/SIM117.py:5:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements
|
5 | / with A() as a: # SIM117
6 | | with B() as b:
7 | | with C() as c:
8 | | print("hello")
| |__________________________^ SIM117
|
resources/test/fixtures/flake8_simplify/SIM117.py:6:5: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements
|
6 | with B() as b:
| _____^
7 | | with C() as c:
8 | | print("hello")
| |__________________________^ SIM117
|
```
### Improved
```
resources/test/fixtures/flake8_simplify/SIM117.py:5:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements
|
5 | / with A() as a: # SIM117
6 | | with B() as b:
7 | | with C() as c:
| |______________________^ SIM117
|
```
Signed-off-by: harupy <hkawamura0130@gmail.com >
2023-01-14 07:59:24 -05:00
Charlie Marsh
027382f891
Add support for namespace packages ( #1859 )
...
Closes #1817 .
2023-01-14 07:31:57 -05:00
Charlie Marsh
931d41bff1
Revert "Bump version to 0.0.222"
...
This reverts commit 852aab5758 .
2023-01-13 23:56:29 -05:00
Charlie Marsh
852aab5758
Bump version to 0.0.222
2023-01-13 23:50:08 -05:00
Charlie Marsh
27fe4873f2
Fix placement of update feature flag
2023-01-13 23:46:32 -05:00
Charlie Marsh
ee6c81d02a
Bump version to 0.0.221
2023-01-13 23:33:15 -05:00
Charlie Marsh
59542344e2
Avoid unnecessary allocations for module names ( #1863 )
2023-01-13 23:26:34 -05:00
Martin Fischer
7b1ce72f86
Actually fix wasm-pack build command ( #1862 )
...
I initially attempted to run `wasm-pack build -p ruff` which gave the
error message:
Error: crate directory is missing a `Cargo.toml` file; is `-p` the wrong
directory?
I interpreted that as wasm-pack looking for the "ruff" directory because
I specified -p ruff, however actually the wasm-pack build usage is:
wasm-pack build [FLAGS] [OPTIONS] <path> <cargo-build-options>
And I was missing the `<path>` argument. So this actually wasn't at all
a bug in wasm-pack but just a confusing error message. And the symlink
hack I introduced in the previous commit didn't actually work ... I only
accidentally omitted the `-p` when testing (which ended up as `ruff`
being the <path> argument) ... CLIs are fun.
2023-01-13 23:20:20 -05:00
Martin Fischer
156e09536e
Add workaround for wasm-pack bug to fix the playground CI ( #1861 )
...
Fixes #1860 .
2023-01-13 22:46:51 -05:00
Charlie Marsh
22341c4ae4
Move repology down
2023-01-13 22:29:26 -05:00
Colin Delahunty
e4993bd7e2
Added ALE ( #1857 )
...
Fixes the sub issue I brought up in #1829 .
2023-01-13 21:39:51 -05:00
Martin Fischer
82aff5f9ec
Split off ruff_cli crate from ruff library
...
This lets you test the ruff linters or use the ruff library
without having to compile the ~100 additional dependencies
that are needed by the CLI.
Because we set the following in the [workspace] section of Cargo.toml:
default-members = [".", "ruff_cli"]
`cargo run` still runs the CLI and `cargo test` still tests
the code in src/ as well as the code in the new ruff_cli crate.
(But you can now also run `cargo test -p ruff` to only test the linters.)
2023-01-13 21:37:54 -05:00
Charlie Marsh
403a004e03
Refactor import-tracking to leverage existing AST bindings ( #1856 )
...
This PR refactors our import-tracking logic to leverage our existing
logic for tracking bindings. It's both a significant simplification, a
significant improvement (as we can now track reassignments), and closes
out a bunch of subtle bugs.
Though the AST tracks all bindings (e.g., when parsing `import os as
foo`, we bind the name `foo` to a `BindingKind::Importation` that points
to the `os` module), when I went to implement import tracking (e.g., to
ensure that if the user references `List`, it's actually `typing.List`),
I added a parallel system specifically for this use-case.
That was a mistake, for a few reasons:
1. It didn't track reassignments, so if you had `from typing import
List`, but `List` was later overridden, we'd still consider any
reference to `List` to be `typing.List`.
2. It required a bunch of extra logic, include complex logic to try and
optimize the lookups, since it's such a hot codepath.
3. There were a few bugs in the implementation that were just hard to
correct under the existing abstractions (e.g., if you did `from typing
import Optional as Foo`, then we'd treat any reference to `Foo` _or_
`Optional` as `typing.Optional` (even though, in that case, `Optional`
was really unbound).
The new implementation goes through our existing binding tracking: when
we get a reference, we find the appropriate binding given the current
scope stack, and normalize it back to its original target.
Closes #1690 .
Closes #1790 .
2023-01-13 20:39:54 -05:00
Charlie Marsh
0b92849996
Improve spacing preservation for C405 fixes ( #1855 )
...
We now preserve the spacing of the more common form:
```py
set((
1,
))
```
Rather than the less common form:
```py
set(
(1,)
)
```
2023-01-13 13:11:08 -05:00
Charlie Marsh
12440ede9c
Remove non-magic trailing comma from tuple ( #1854 )
...
Closes #1821 .
2023-01-13 12:56:42 -05:00
max0x53
fc3f722df5
Implement PLR0133 (ComparisonOfConstants) ( #1841 )
...
This PR adds [Pylint
`R0133`](https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/comparison-of-constants.html )
Feel free to suggest changes and additions, I have tried to maintain
parity with the Pylint implementation
[`comparison_checker.py`](https://github.com/PyCQA/pylint/blob/main/pylint/checkers/base/comparison_checker.py#L247 )
See #970
2023-01-13 12:14:35 -05:00
Maksudul Haque
84ef7a0171
[isort] Add classes Config Option ( #1849 )
...
ref https://github.com/charliermarsh/ruff/issues/1819
2023-01-13 12:13:01 -05:00
Nicola Soranzo
66b1d09362
Clarify that some flake8-bugbear opinionated rules are already implemented ( #1847 )
...
E.g. B904 and B905.
2023-01-13 11:49:05 -05:00
Maksudul Haque
3ae01db226
[flake8-bugbear] Fix False Positives for B024 & B027 ( #1851 )
...
closes https://github.com/charliermarsh/ruff/issues/1848
2023-01-13 11:46:17 -05:00
Charlie Marsh
048e5774e8
Use absolute paths for --stdin-filename matching ( #1843 )
...
Non-basename glob matches (e.g., for `--per-file-ignores`) assume that
the path has been converted to an absolute path. (We do this for
filenames as part of the directory traversal.) For filenames passed via
stdin, though, we're missing this conversion. So `--per-file-ignores`
that rely on the _basename_ worked as expected, but directory paths did
not.
Closes #1840 .
2023-01-12 21:01:05 -05:00
max0x53
b47e8e6770
Implement PLR2004 (MagicValueComparison) ( #1828 )
...
This PR adds [Pylint
`R2004`](https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/magic-value-comparison.html#magic-value-comparison-r2004 )
Feel free to suggest changes and additions, I have tried to maintain
parity with the Pylint implementation
[`magic_value.py`](https://github.com/PyCQA/pylint/blob/main/pylint/extensions/magic_value.py )
See #970
2023-01-12 19:44:18 -05:00
Jan Katins
ef17c82998
Document the way extend-ignore/select are applied ( #1839 )
...
Closes: https://github.com/charliermarsh/ruff/issues/1838
2023-01-12 19:44:03 -05:00
Charlie Marsh
9aeb5df5fe
Bump version to 0.0.220
2023-01-12 17:57:04 -05:00
Charlie Marsh
7ffba7b552
Use absolute paths for GitHub and Gitlab annotations ( #1837 )
...
Note that the _annotation path_ is absolute, while the path encoded in
the message remains relative.

Closes #1835 .
2023-01-12 17:54:34 -05:00
Charlie Marsh
06473bb1b5
Support for-else loops in SIM110 and SIM111 ( #1834 )
...
This PR adds support for `SIM110` and `SIM111` simplifications of the
form:
```py
def f():
# SIM110
for x in iterable:
if check(x):
return True
else:
return False
```
2023-01-12 17:04:58 -05:00
Ash Berlin-Taylor
bf5c048502
Airflow is now using ruff ( #1833 )
...
😀
2023-01-12 16:50:01 -05:00
Charlie Marsh
eaed08ae79
Skip SIM110/SIM111 fixes that create long lines
2023-01-12 16:21:54 -05:00
Charlie Marsh
e0fdc4c5e8
Avoid SIM110/SIM110 errors with else statements ( #1832 )
...
Closes #1831 .
2023-01-12 16:17:27 -05:00
Charlie Marsh
590bec57f4
Fix typo in relative-imports-order option name
2023-01-12 15:57:58 -05:00
Charlie Marsh
3110d342c7
Implement isort's reverse_relative setting ( #1826 )
...
This PR implements `reverse-relative`, from isort, but renames it to
`relative-imports-order` with the respected value `closest-to-furthest`
and `furthest-to-closest`, and the latter being the default.
Closes #1813 .
2023-01-12 15:48:40 -05:00
nefrob
39aae28eb4
📝 Update readme example for adding isort required imports ( #1824 )
...
Fixes use of isort name to the ruff name.
2023-01-12 13:18:06 -05:00
Charlie Marsh
dcccfe2591
Avoid parsing pyproject.toml files when settings are fixed ( #1827 )
...
Apart from being wasteful, this can also cause problems (see the linked
issue).
Resolves #1812 .
2023-01-12 13:15:44 -05:00
Martin Fischer
38f5e8f423
Decouple linter module from cache module
2023-01-12 13:09:59 -05:00
Martin Fischer
74f14182ea
Decouple resolver module from cli::Overrides
2023-01-12 13:09:59 -05:00
Charlie Marsh
bbc1e7804e
Don't trigger SIM401 for complex default values ( #1825 )
...
Resolves #1809 .
2023-01-12 12:51:23 -05:00
messense
c6320b29e4
Implement autofix for flake8-quotes ( #1810 )
...
Resolves #1789
2023-01-12 12:42:28 -05:00
Maksudul Haque
1a90408e8c
[flake8-bandit] Add Rule for S701 (jinja2 autoescape false) ( #1815 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-12 11:59:20 -05:00
Jeroen Van Goey
07134c50c8
Add usage of ruff in pandas to README ( #1811 )
...
pandas now uses ruff for linting, see
https://github.com/pandas-dev/pandas/pull/50160
2023-01-12 10:55:21 -05:00
Charlie Marsh
b36d4a15b0
Modify visibility and shuffle around some modules ( #1807 )
2023-01-11 23:57:05 -05:00
Charlie Marsh
d8162ce79d
Bump version to 0.0.219
2023-01-11 23:46:01 -05:00
Charlie Marsh
e11ef54bda
Improve globset documentation and help message ( #1808 )
...
Closes #1545 .
2023-01-11 23:41:56 -05:00
messense
9a07b0623e
Move top level ruff into python folder ( #1806 )
...
https://maturin.rs/project_layout.html#mixed-rustpython-project
Resolves #1805
2023-01-11 23:12:55 -05:00
Charlie Marsh
f450e2e79d
Implement doc line length enforcement ( #1804 )
...
This PR implements `W505` (`DocLineTooLong`), which is similar to `E501`
(`LineTooLong`) but confined to doc lines.
I based the "doc line" definition on pycodestyle, which defines a doc
line as a standalone comment or string statement. Our definition is a
bit more liberal, since we consider any string statement a doc line
(even if it's part of a multi-line statement) -- but that seems fine to
me.
Note that, unusually, this rule requires custom extraction from both the
token stream (to find standalone comments) and the AST (to find string
statements).
Closes #1784 .
2023-01-11 22:32:14 -05:00
Colin Delahunty
329946f162
Avoid erroneous Q002 error message for single-quote docstrings ( #1777 )
...
Fixes #1775 . Before implementing your solution I thought of a slightly
simpler one. However, it will let this function pass:
```
def double_inside_single(a):
'Double inside "single "'
```
If we want function to pass, my implementation works. But if we do not,
then I can go with how you suggested I implemented this (I left how I
would begin to handle it commented out). The bottom of the flake8-quotes
documentation seems to suggest that this should pass:
https://pypi.org/project/flake8-quotes/
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-11 20:01:54 -05:00
Charlie Marsh
588399e415
Fix Clippy error
2023-01-11 19:59:00 -05:00
Chammika Mannakkara
4523885268
flake8_simplify : SIM401 ( #1778 )
...
Ref #998
- Implements SIM401 with fix
- Added tests
Notes:
- only recognize simple ExprKind::Name variables in expr patterns for
now
- bug-fix from reference implementation: check 3-conditions (dict-key,
target-variable, dict-name) to be equal, `flake8_simplify` only test
first two (only first in second pattern)
2023-01-11 19:51:37 -05:00
Maksudul Haque
de81b0cd38
[flake8-simplify] Add Rule for SIM115 (Use context handler for opening files) ( #1782 )
...
ref: https://github.com/charliermarsh/ruff/issues/998
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-11 19:28:05 -05:00
Charlie Marsh
4fce296e3f
Skip SIM108 violations for complex if-statements ( #1802 )
...
We now skip SIM108 violations if: the resulting statement would exceed
the user-specified line length, or the `if` statement contains comments.
Closes #1719 .
Closes #1766 .
2023-01-11 19:21:30 -05:00
Charlie Marsh
9d48d7bbd1
Skip unused argument checks for magic methods ( #1801 )
...
We still check `__init__`, `__call__`, and `__new__`.
Closes #1796 .
2023-01-11 19:02:20 -05:00
Charlie Marsh
c56f263618
Avoid flagging builtins for OSError rewrites ( #1800 )
...
Related to (but does not fix) #1790 .
2023-01-11 18:49:25 -05:00
Grzegorz Bokota
fb2382fbc3
Update readme to reflect #1763 ( #1780 )
...
When checking changes in the 0.0.218 release I noticed that auto fixing
PT004 and PT005 was disabled but this change was not reflected in
README. So I create this small PR to do this.
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-11 18:37:41 -05:00
Charlie Marsh
c92a5a8704
Avoid rewriting flake8-comprehensions expressions for builtin overrides ( #1799 )
...
Closes #1788 .
2023-01-11 18:33:55 -05:00
Charlie Marsh
d7cf3147b7
Refactor flake8-comprehensions rules to take fewer arguments ( #1797 )
2023-01-11 18:21:18 -05:00
Charlie Marsh
bf4d35c705
Convert flake8-comprehensions checks to Checker style ( #1795 )
2023-01-11 18:11:20 -05:00
Charlie Marsh
4e97e9c7cf
Improve PIE794 autofix behavior ( #1794 )
...
We now: (1) trigger PIE794 for objects without bases (not sure why this
was omitted before); and (2) remove the entire line, rather than leaving
behind trailing whitespace.
Resolves #1787 .
2023-01-11 18:01:29 -05:00
Charlie Marsh
a3fcc3b28d
Disable update check by default ( #1786 )
...
This has received enough criticism that I'm comfortable making it
opt-in.
2023-01-11 13:47:40 -05:00
Charlie Marsh
cfbd068dd5
Bump version to 0.0.218
2023-01-10 21:28:23 -05:00
Charlie Marsh
8aed23fe0a
Avoid B023 false-positives for some common builtins ( #1776 )
...
This is based on the upstream work in
https://github.com/PyCQA/flake8-bugbear/pull/303 and
https://github.com/PyCQA/flake8-bugbear/pull/305/files .
Resolves #1686 .
2023-01-10 21:23:48 -05:00
Colin Delahunty
c016c41c71
Pyupgrade: Format specifiers ( #1594 )
...
A part of #827 . Posting this for visibility. Still has some work to do
to be done.
Things that still need done before this is ready:
- [x] Does not work when the item is being assigned to a variable
- [x] Does not work if being used in a function call
- [x] Fix incorrectly removed calls in the function
- [x] Has not been tested with pyupgrade negative test cases
Tests from pyupgrade can be seen here:
https://github.com/asottile/pyupgrade/blob/main/tests/features/format_literals_test.py
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-10 20:21:04 -05:00
Charlie Marsh
f1a5e53f06
Enable isort-style required-imports enforcement ( #1762 )
...
In isort, this is called `add-imports`, but I prefer the declarative
name.
The idea is that by adding the following to your `pyproject.toml`, you
can ensure that the import is included in all files:
```toml
[tool.ruff.isort]
required-imports = ["from __future__ import annotations"]
```
I mostly reverse-engineered isort's logic for making decisions, though I
made some slight tweaks that I think are preferable. A few comments:
- Like isort, we don't enforce this on empty files (like empty
`__init__.py`).
- Like isort, we require that the import is at the top-level.
- isort will skip any docstrings, and any comments on the first three
lines (I think, based on testing). Ruff places the import after the last
docstring or comment in the file preamble (that is: after the last
docstring or comment that comes before the _first_ non-docstring and
non-comment).
Resolves #1700 .
2023-01-10 18:12:57 -05:00
Charlie Marsh
1e94e0221f
Disable doctests ( #1772 )
...
We don't have any doctests, but `cargo test --all` spends more than half
the time on doctests? A little confusing, but this brings the test time
from > 4s to < 2s on my machine.
2023-01-10 15:10:16 -05:00
Martin Fischer
543865c96b
Generate RuleCode::origin() via macro ( #1770 )
2023-01-10 13:20:43 -05:00
Maksudul Haque
b8e3f0bc13
[flake8-bandit] Add Rule for S508 (snmp insecure version) & S509 (snmp weak cryptography) ( #1771 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
Co-authored-by: messense <messense@icloud.com >
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-10 13:13:54 -05:00
Charlie Marsh
643cedb200
Move CONTRIBUTING.md to top-level ( #1768 )
2023-01-10 07:38:12 -05:00
Charlie Marsh
91620c378a
Disable release builds on CI ( #1761 )
2023-01-10 07:33:03 -05:00
Harutaka Kawamura
b732135795
Do not autofix PT004 and PT005 ( #1763 )
...
As @edgarrmondragon commented in
https://github.com/charliermarsh/ruff/pull/1740#issuecomment-1376230550 ,
just renaming fixture doesn't work.
2023-01-10 07:24:16 -05:00
messense
9384a081f9
Implement flake8-simplify SIM112 ( #1764 )
...
Ref #998
2023-01-10 07:24:01 -05:00
Charlie Marsh
edab268d50
Bump version to 0.0.217
2023-01-09 23:26:22 -05:00
Charlie Marsh
e4fad70a57
Update documentation to match latest terminology ( #1760 )
...
Closes #1759 .
2023-01-09 21:10:47 -05:00
Charlie Marsh
1a09fff991
Update rule-generation scripts to match latest conventions ( #1758 )
...
Resolves #1755 .
2023-01-09 19:55:46 -05:00
Charlie Marsh
b85105d2ec
Add a helper for any-like operations ( #1757 )
2023-01-09 19:34:33 -05:00
Charlie Marsh
f7ac28a935
Omit sys.version_info and sys.platform checks from ternary rule ( #1756 )
...
Resolves #1753 .
2023-01-09 19:22:34 -05:00
Charlie Marsh
9532f342a6
Enable project-specific typing module re-exports ( #1754 )
...
Resolves #1744 .
2023-01-09 18:17:50 -05:00
Mohamed Daahir
0ee37aa0aa
Cache build artifacts using Swatinem/rust-cache@v1 ( #1750 )
...
This GitHub Action caches build artifacts in addition to dependencies
which halves the CI duration time.
Resolves #1752 .
2023-01-09 15:35:32 -05:00
Charlie Marsh
8a26c8b4e0
Fix wasm builds
2023-01-09 12:58:07 -05:00
Charlie Marsh
2cb59b0f45
Use dedicated warnings for flake8-to-ruff ( #1748 )
2023-01-09 12:48:06 -05:00
Charlie Marsh
2729f3d207
Add support for defining extra builtins ( #1747 )
...
Resolves #1745 .
2023-01-09 12:24:28 -05:00
Charlie Marsh
59155ce9f6
Rename checks and plugins to rules ( #1739 )
2023-01-09 01:39:51 -05:00
Charlie Marsh
caf6c65de7
Bump version to 0.0.216
2023-01-09 01:14:28 -05:00
Matt Oberle
147d594b38
Add isort.force-sort-within-sections setting ( #1635 )
...
This commit is a first attempt at addressing issue #1003 .
The default `isort` behavior is `force-sort-within-sections = false`,
which places `from X import Y` statements after `import X` statements.
When `force-sort-within-sections = true` all imports are sorted by
module name.
When module names are equivalent, the `import` statement comes before
the `from` statement.
2023-01-09 01:06:48 -05:00
Charlie Marsh
f18078a1eb
Allow unused arguments for empty methods with docstrings ( #1742 )
...
Resolves #1741 .
2023-01-09 00:34:07 -05:00
Harutaka Kawamura
fe4eb13601
Autofix PT004, PT005, PT024, and PT025 ( #1740 )
2023-01-08 22:41:00 -05:00
Charlie Marsh
161ab05533
Rename more local usages of check to diagnostic ( #1738 )
2023-01-08 18:10:08 -05:00
Charlie Marsh
2c537e24cc
Move violation structs out of registry.rs ( #1728 )
2023-01-08 17:54:20 -05:00
Charlie Marsh
0fe349b5f8
Rename CheckCategory to RuleOrigin ( #1726 )
2023-01-08 17:50:18 -05:00
Charlie Marsh
09dc3c7225
Rename Check to Diagnostic ( #1725 )
...
Along with:
- `CheckKind` -> `DiagnosticKind`
- `CheckCode` -> `RuleCode`
- `CheckCodePrefix` -> `RuleCodePrefix`
2023-01-08 17:46:20 -05:00
Harutaka Kawamura
498134b7ee
Audit unittest assert methods ( #1736 )
...
I ran the following code in Python 3.10 to automatically generate a list
of enums.
```python
import unittest
print(
",\n".join(
sorted(
m.removeprefix("assert") if m != "assert_" else "Underscore"
for m in dir(unittest.TestCase)
if m.startswith("assert")
)
)
)
```
2023-01-08 16:21:34 -05:00
Charlie Marsh
0152814a00
Bump version to 0.0.215
2023-01-07 22:17:29 -05:00
Harutaka Kawamura
0b3fab256b
Remove assertNotContains ( #1729 )
...
`unittest.TestCase` doens't have a method named `assertNotContains`.
2023-01-07 22:15:48 -05:00
Chammika Mannakkara
212ce4d331
buf-fix: flake8_simplify SIM212 ( #1732 )
...
bug-fix in #1717
Use the correct `IfExprWithTwistedArms` struct.
2023-01-07 22:03:48 -05:00
Charlie Marsh
491b1e4968
Move RUFF_CACHE_DIR to Clap's env support ( #1733 )
2023-01-07 22:01:27 -05:00
Charlie Marsh
8b01b53d89
Move RUFF_CACHE_DIR to Clap's env support ( #1733 )
2023-01-07 22:01:20 -05:00
messense
f9a5867d3e
Add RUFF_FORMAT environment variable support ( #1731 )
...
Resolves #1716
2023-01-07 21:54:19 -05:00
Harutaka Kawamura
4149627f19
Add more unittest assert methods to PT009 ( #1730 )
2023-01-07 21:52:48 -05:00
Charlie Marsh
7d24146df7
Implement --isolated CLI flag ( #1727 )
...
Closes #1724 .
2023-01-07 18:43:58 -05:00
Charlie Marsh
1c6ef3666c
Treat failures to fix TypedDict conversions as debug logs ( #1723 )
...
This also allows us to flag the error, even if we can't fix it.
Closes #1212 .
2023-01-07 17:51:45 -05:00
Charlie Marsh
16d933fcf5
Respect isort:skip action comment ( #1722 )
...
Resolves : #1718 .
2023-01-07 17:30:18 -05:00
Charlie Marsh
a9cc56b2ac
Add ComparableExpr hierarchy for comparing expressions ( #1721 )
2023-01-07 17:29:21 -05:00
Charlie Marsh
4de6c26ff9
Automatically remove duplicate dictionary keys ( #1710 )
...
For now, to be safe, we're only removing keys with duplicate _values_.
See: #1647 .
2023-01-07 16:16:42 -05:00
Charlie Marsh
98856e05d6
Fix clippy errors
2023-01-07 15:49:59 -05:00
Charlie Marsh
edf46c06d0
Bump version to 0.0.214
2023-01-07 15:34:45 -05:00
Chammika Mannakkara
9cfce61f36
flake8_simplify : SIM210, SIM211, SIM212 ( #1717 )
2023-01-07 15:32:34 -05:00
Charlie Marsh
bdb9a4d1a7
Update CONTRIBUTING.md to point to violations.rs ( #1720 )
2023-01-07 15:20:21 -05:00
Martin Fischer
82e0c0ced6
structs 9/9: Run cargo test and cargo insta accept
2023-01-07 15:14:58 -05:00
Martin Fischer
6a723b50c7
structs 8/9: Run cargo fix and cargo fmt
2023-01-07 15:14:58 -05:00
Martin Fischer
6208eb7bbf
structs 7/9: Manually fix errors introduced in the previous commit
2023-01-07 15:14:58 -05:00
Martin Fischer
43db446dfa
structs 6/9: Automatically change CheckKind::* to violations::*
...
The changes in this commit were generated by running:
for f in $(find src -name '*.rs'); do sed -Ei 's/use crate::registry::.*;/\0use crate::violations;/g' $f; done
for f in $(find src -name '*.rs'); do sed -Ei 's/CheckKind::([A-Z])/violations::\1/g' $f; done
git checkout src/registry.rs src/lib.rs src/lib_wasm.rs src/violations.rs
cargo +nightly fmt
2023-01-07 15:14:58 -05:00
Martin Fischer
3c8fdbf107
structs 5/9: Make Check::new call into() on the passed kind
2023-01-07 15:14:58 -05:00
Martin Fischer
54fb47ea6a
structs 4/9: Implement define_rule_mapping!
2023-01-07 15:14:58 -05:00
Martin Fischer
efadfeda96
structs 3/9: Manually implement autofix_formatter for conditional autofixes
2023-01-07 15:14:58 -05:00
Martin Fischer
90198f7563
structs 2/9: Generate violations.rs from registry.rs
...
# The changes of this commit were generated using the following code:
# (followed by cargo +nightly fmt)
import re
import subprocess
import io
indent = ' ' * 4
def split_words(s):
return re.split(r'\b', s)
def checkkind_match_arms(f, strip_some=False):
bodies = {}
while (line := next(f).rstrip()) != indent * 2 + '}':
if line.lstrip().startswith('//'):
continue
if line.strip() == '':
continue
parts = line.split('=>', maxsplit=1)
if parts[0].strip() == '_':
break
left, body = parts
left = left.strip()
body = body.strip()
if body == '{':
body = ''
while (line := next(f).rstrip()) != indent * 3 + '}':
body += line + '\n'
else:
body = body.rstrip(',')
kind = split_words(left)[3]
if strip_some:
body = re.sub('\)$', '', re.sub(r'Some\(', '', body, 1).rstrip(), 1)
if ('(' in left and not '(..)' in left) or '{' in left:
body = (
'let '
+ left.replace('CheckKind::', '').replace('CheckCode::', '')
+ ' = self;\n'
+ body
)
bodies[kind] = body
return bodies
with open('src/registry.rs') as f:
orig_registry_code = f.read()
# simplify the parsing of multiline match arms
registry_code = subprocess.check_output(
['rustfmt', '+nightly', '--config', 'force_multiline_blocks=true'],
encoding='utf-8',
input=orig_registry_code,
)
f = io.StringIO(registry_code)
# 1. Parse the CheckCode enum
while next(f).strip() != 'pub enum CheckCode {':
pass
checkcode_lines = []
while (line := next(f).strip().rstrip(',')) != '}':
checkcode_lines.append(line)
# 2. Parse the CheckKind enum
while next(f).strip() != 'pub enum CheckKind {':
pass
struct_defs = {}
while (line := next(f).strip()) != '}':
if line.startswith('//'):
continue
line = line.rstrip(',')
line = re.sub(r'{', '{ pub ', line)
line = re.sub(r'\(', '(pub ', line)
line = re.sub(',', ', pub', line)
kind = split_words(line)[1]
struct_defs[kind] = 'pub struct ' + line + (';' * (line[-1] != '}'))
# 3. parse the kind() impl for CheckKind
while next(f).rstrip() != " pub fn kind(&self) -> CheckKind {":
pass
assert next(f).strip() == 'match self {'
placeholders = checkkind_match_arms(f)
# 4. parse the CheckKind -> CheckCode mapping
while next(f).strip() != "pub fn code(&self) -> &'static CheckCode {":
pass
assert next(f).strip() == 'match self {'
kind2code = {}
while (line := next(f).strip().rstrip(',')) != '}':
if line.startswith('//'):
continue
parts = re.split(r'\b', line)
kind2code[parts[3]] = parts[-2]
code2kind = {code: kind for kind, code in kind2code.items()}
# 5. parse the body() impl for CheckKind
while next(f).rstrip() != " pub fn body(&self) -> String {":
pass
assert next(f).strip() == 'match self {'
bodies = checkkind_match_arms(f)
# 6. find fixable
always_fixable = []
sometimes_fixable = []
while next(f).strip() != "// Always-fixable checks.":
pass
while (line := next(f).strip()) != '// Conditionally-fixable checks.':
always_fixable.append(split_words(line)[3])
while (line := next(f).strip()) != '// Non-fixable checks.':
sometimes_fixable.append(split_words(line)[3])
# 7. find autofix message
while next(f).rstrip() != indent + "pub fn commit(&self) -> Option<String> {":
pass
assert next(f).strip() == 'match self {'
autofix_msg = checkkind_match_arms(f, strip_some=True)
reg = '''\
macro_rules! define_rule_mapping {
($($code:ident => $mod:ident::$name:ident,)+) => {
// TODO: implement
};
}
define_rule_mapping!(
'''
for line in checkcode_lines:
if line.startswith('//'):
reg += indent + line + '\n'
continue
code = line
reg += indent + code + ' => violations::' + code2kind[code] + ',\n'
reg += ');\n\n'
with open('src/registry.rs', 'w') as f:
marker = '#[derive'
f.write(orig_registry_code.replace(marker, reg + marker, 1))
out = '''\
use itertools::Itertools;
use crate::define_violation;
use crate::flake8_debugger::types::DebuggerUsingType;
use crate::flake8_pytest_style::types::{ParametrizeNameType, ParametrizeValuesType, ParametrizeValuesRowType};
use crate::flake8_quotes::settings::Quote;
use crate::flake8_tidy_imports::settings::Strictness;
use crate::pyupgrade::types::Primitive;
use crate::registry::{
Branch, DeferralKeyword, EqCmpop, IsCmpop, LiteralType, MockReference, UnusedCodes,
};
use crate::violation::{AlwaysAutofixableViolation, Violation};
'''
for line in checkcode_lines:
if line.startswith('//'):
out += '\n' + line + '\n\n'
continue
code = line
kind = code2kind[code]
out += 'define_violation!(' + struct_defs[kind] + ');\n'
if kind in always_fixable:
out += f'impl AlwaysAutofixableViolation for {kind} {{\n'
else:
out += f'impl Violation for {kind} {{\n'
out += 'fn message(&self) -> String {'
out += bodies[kind]
out += '}'
if kind in always_fixable:
out += 'fn autofix_title(&self) -> String {'
out += autofix_msg[kind]
out += '}'
elif kind in sometimes_fixable:
out += 'fn autofix_title_formatter(&self) -> Option<fn(&Self) -> String> {'
out += 'todo!()'
out += '}'
out += 'fn placeholder() -> Self {'
out += placeholders[code].replace('CheckKind::', '')
out += '}'
out += '}\n\n'
with open('src/violations.rs', 'w') as f:
f.write(out)
with open('src/lib.rs', 'r') as f:
mod = f.read()
with open('src/lib.rs', 'w') as f:
marker = 'mod violation;'
f.write(mod.replace(marker, marker + '\nmod violations;'))
2023-01-07 15:14:58 -05:00
Martin Fischer
15084dff9d
structs 1/9: Manually preprocess registry.rs
2023-01-07 15:14:58 -05:00
Martin Fischer
eea1379a74
structs 0/9: Introduce Violation trait
...
For every available rule registry.rs currently defines:
1. A CheckCode variant to identify the rule.
2. A CheckKind variant to represent violations of the rule.
3. A mapping from the CheckCode variant to a placeholder CheckKind instance.
4. A mapping from the CheckKind variant to CheckCode.
5. A mapping from the CheckKind to a string description.
6. A mapping from the CheckKind to a boolean indicating if autofix is available.
7. A mapping from the CheckKind to a string describing the autofix if available.
Since registry.rs defines all of this for every single rule and
ruff has hundreds of rules, this results in the lines specific to
a particular rule to be hundreds of lines apart, making the code
cumbersome to read and edit.
This commit introduces a new Violation trait so that the rule-specific
details of the above steps 5.-7. can be defined next to the rule
implementation. The idea is that once all CheckCode/CheckKind variants
have been converted to this new approach then the steps 1.-4. in
registry.rs could simply be generated via a declarative macro, e.g:
define_rule_mapping!(
E501 => pycodestyle::LineTooLong,
...
);
(where `pycodestyle::LineTooLong` would be a struct that implements the
new Violation trait).
The define_rule_mapping! macro would then take care of generating the
CheckCode and CheckKind enums, as well as all of the implementations for
the previously mentioned mappings, by simply calling the methods of the
new Violation trait.
There is another nice benefit from this approach: We want to introduce
more thorough documentation for rules and we want the documentation of a
rule to be defined close by the implementation (so that it's easier to
check if they match and that they're less likely to become out of sync).
Since these new Violation structs can be defined close by the
implementation of a rule we can also use them as an anchor point for the
documentation of a rule by simply adding the documentation in the form
of a Rust doc comment to the struct.
2023-01-07 15:14:58 -05:00
Charlie Marsh
3e80c0d43e
Fix clippy errors
2023-01-07 12:53:36 -05:00
Harutaka Kawamura
76a366e05a
Trim trailing whitespace when extracting isort directives ( #1715 )
2023-01-07 12:39:31 -05:00
Harutaka Kawamura
07f72990a9
Implement autofix for PT009 ( #1713 )
2023-01-07 12:28:25 -05:00
messense
402feffe85
Implement flake8-simplify SIM103 ( #1712 )
...
Ref #998
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-07 07:33:24 -05:00
Harutaka Kawamura
5cdd7ccdb8
Use text in comment token ( #1714 )
...
https://github.com/RustPython/RustPython/pull/4426 has been merged. We
can simplify code using text in comment tokens.
2023-01-07 07:29:04 -05:00
Charlie Marsh
f1c3ebfe0f
Bump version to 0.0.213
2023-01-07 00:30:56 -05:00
Charlie Marsh
c7e4e41a7a
Revert "Include list of fixed files in stderr output ( #1701 )" ( #1711 )
...
This reverts commit 53ed52dc59 .
I want to get some feedback on this before I send it out.
2023-01-07 00:30:25 -05:00
Charlie Marsh
311a823a4a
Increase blackd wait time ( #1709 )
...
Resolves #1511 .
2023-01-06 23:08:25 -05:00
Harutaka Kawamura
8c836aeecf
Add more backticks to flake8-pytest-style error messages ( #1707 )
2023-01-06 22:55:24 -05:00
Charlie Marsh
3abd205f94
Lazily compute ranges for class and function bindings ( #1708 )
...
This has a fairly significant performance impact (~320ms to ~307ms on
the CPython benchmark).
2023-01-06 22:55:13 -05:00
Charlie Marsh
0527fb9335
Automatically remove unused variables ( #1683 )
...
Closes #1460 .
2023-01-06 22:06:04 -05:00
Harutaka Kawamura
d5256f89b6
Use trim_end when checking line continutation ( #1706 )
...
Just a minor optimization.
Signed-off-by: harupy <hkawamura0130@gmail.com >
2023-01-06 21:59:35 -05:00
Charlie Marsh
3f84746d66
Remove add_check methods ( #1705 )
2023-01-06 21:58:21 -05:00
Anders Kaseorg
c39f687fca
Switch SourceCodeGenerator.buffer from Vec<u8> to String ( #1702 )
...
This is the real issue underneath the `unsafe`/`unwrap` quandry in
#1677 .
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-06 20:26:23 -05:00
Anders Kaseorg
dd35e724dd
Forbid unsafe code ( #1704 )
...
We can reverse this later if it really becomes necessary, but I expect
safe Rust to be sufficient for all our needs.
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-06 20:25:59 -05:00
Anders Kaseorg
43599a9e78
Remove redundant #![allow()] from main_native ( #1703 )
...
`main_native.rs` is a module of `main.rs`, so the `#![allow()]`s in the
latter apply to the former automatically.
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-06 20:25:46 -05:00
Charlie Marsh
53ed52dc59
Include list of fixed files in stderr output ( #1701 )
...
This PR adds the list of fixed files to Ruff's output (send to `stderr`,
and omitted for `--silent` and `--quiet` settings):

Closes #1667 .
2023-01-06 19:51:11 -05:00
Charlie Marsh
24999019e0
Include error location in GitHub Action diagnostic messages ( #1696 )
...
This ensures that if you look at the GitHub Actions _logs_, you see the
entire message, including the location:

The downside is that the location gets repeated inline:

See: #1693 .
2023-01-06 15:58:16 -05:00
Charlie Marsh
12d2526edb
Require explicit opt-in for GitHub and Gitlab formats ( #1697 )
2023-01-06 15:57:56 -05:00
Charlie Marsh
81b812d94c
Delete unreferenced snapshot
2023-01-06 15:56:47 -05:00
Maksudul Haque
9409b49ea2
[flake8-bandit] Add Rule for S501 (request call with verify=False) ( #1695 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
2023-01-06 11:44:19 -05:00
Chammika Mannakkara
1392170dbf
Simplify SIM201, SIM202, SIM208 ( #1666 )
...
Flake8 simplify #998
SIM201, SIM202 and SIM208 is done here with fixes.
Note: SIM203 == E713
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-06 10:47:48 -05:00
messense
0a940b3cb4
Implement flake8-simplify SIM109 ( #1687 )
...
Ref #998
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-06 10:29:49 -05:00
Maksudul Haque
6aba43a9b0
[flake8-bandit] Add Rule for S113 (requests call without timeout) ( #1692 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-06 10:26:08 -05:00
Charlie Marsh
8a3a6a901a
Avoiding flagging elif statements as potential ternaries ( #1694 )
2023-01-06 10:20:45 -05:00
Charlie Marsh
18a301a214
Add specialized conversions for RefEquality ( #1689 )
2023-01-06 10:02:17 -05:00
Harutaka Kawamura
53157bc634
Remove TODO comment ( #1691 )
2023-01-06 10:02:07 -05:00
messense
76a9dc61f0
Implement flake8-simplify SIM108 ( #1684 )
...
Ref #998
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-06 08:28:51 -05:00
Maksudul Haque
16d7e13c72
Update CONTRIBUTING.md location on README.md ( #1688 )
2023-01-06 08:05:24 -05:00
Charlie Marsh
5ed58ae595
Add requested context to issue template ( #1679 )
2023-01-06 07:29:08 -05:00
Charlie Marsh
cecd4b166c
Don't mark D205 as fixable in more-lines case ( #1682 )
...
Closes #1672 .
2023-01-05 23:20:14 -05:00
Charlie Marsh
4ddcdd02d6
Tweak badge logo ( #1681 )
2023-01-05 23:07:21 -05:00
messense
43575da537
Replace toml with toml_edit ( #1680 )
...
The `toml` crate doesn't support TOML 1.0, but `toml_edit` does. While
there is a plan to [migrate `toml` to be on
`toml_edit`](https://github.com/toml-rs/toml/issues/340 ), it's not ready
yet and it's very easy to switch back to `toml` when it's ready.
2023-01-05 22:08:23 -05:00
Charlie Marsh
fe67a0d239
Implement From conversion for style detector-to-generator ( #1678 )
2023-01-05 21:47:48 -05:00
Charlie Marsh
8caa73df6a
Remove Result from SourceCodeGenerator signature ( #1677 )
...
We populate this buffer ourselves, so I believe it's fine for us to use
an unchecked UTF-8 cast here. It _dramatically_ simplifies so much
downstream code.
2023-01-05 21:41:26 -05:00
Charlie Marsh
ee4cae97d5
Bump version to 0.0.212
2023-01-05 21:25:42 -05:00
Anders Kaseorg
2e3787adff
Remove an unneeded .to_string() in tokenize_files_to_codes_mapping ( #1676 )
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-05 20:56:11 -05:00
Anders Kaseorg
81b211d1b7
Simplify Option<String> → Option<&str> conversion using as_deref ( #1675 )
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-05 20:55:59 -05:00
Anders Kaseorg
1ad72261f1
Replace &String with &str in AnnotatedImport::ImportFrom ( #1674 )
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2023-01-05 20:55:46 -05:00
Charlie Marsh
914287d31b
Fix format and lint errors
2023-01-05 20:30:01 -05:00
Charlie Marsh
75bb6ad456
Implement duplicate isinstance detection (SIM101) ( #1673 )
...
See: #998 .
2023-01-05 20:21:40 -05:00
Charlie Marsh
04111da3f3
Improve Pandas call and attribute detection ( #1671 )
...
This PR adds some guardrails to avoid common false positives in our
`pandas-vet` rules. Specifically, we now avoid triggering `pandas-vet`
rules if the target of the call or attribute (i.e., the `x` in
`x.stack(...)`) is unbound, or bound to something that couldn't be a
DataFrame (like an import that _isn't_ `pandas`, or a class definition).
This lets us avoid common false positives like `np.stack(...)`.
Resolves #1659 .
2023-01-05 19:30:54 -05:00
Charlie Marsh
2464cf6fe9
Fix some &String, &Option, and &Vec usages ( #1670 )
2023-01-05 18:56:03 -05:00
Charlie Marsh
d34e6c02a1
Allow overhang in Google-style docstring arguments ( #1668 )
...
Resolves #1662 .
2023-01-05 14:36:19 -05:00
Diego Palacios
e6611c4830
Fix flake8-import-conventions configuration examples ( #1660 )
2023-01-05 13:37:25 -05:00
Maksudul Haque
2d23b1ae69
[flake8-bandit] Add Rule for S506 (unsafe use of yaml load) ( #1664 )
...
See: https://github.com/charliermarsh/ruff/issues/1646 .
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-05 13:35:01 -05:00
Charlie Marsh
5eb03d5e09
Avoid false-positives for yields with non-identical references ( #1665 )
...
Resolves #1663 .
2023-01-05 12:14:15 -05:00
Maksudul Haque
9f8ef1737e
[flake8-bandit] Add Rule for S324 (Insecure hash functions in hashlib) ( #1661 )
...
ref: https://github.com/charliermarsh/ruff/issues/1646
2023-01-05 11:45:47 -05:00
messense
1991d618a3
Add proc-macro to derive CheckCodePrefix ( #1656 )
...
IMO a derive macro is a natural way to generate new code, and it reduces
the chance of merge conflicts.
2023-01-05 11:39:16 -05:00
Martin Fischer
2045b739a9
Stop highlighting --help output in README as shell ( #1655 )
...
This PR is meant to address the following obviously unintended GitHub
rendering:

2023-01-05 09:46:49 -05:00
Martin Fischer
53e3dd8548
Add ignore-overlong-task-comments setting
...
Imagine a .py file containing the following comment:
# TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
# do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Since `git grep` only matches individual lines `git grep TODO` would
only output the first line of the comment, cutting off potentially
important information. (git grep currently doesn't support multiline
grepping). Projects using such a workflow therefore probably format
the comment in a single line instead:
# TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
This commit introduces a setting to accomdate this workflow by making
the line-length checks (`E501`) optionally ignore overlong lines
if they start with a recognized task tag.
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-04 23:54:50 -05:00
Martin Fischer
78c9056173
Add pycodestyle::settings
...
This step is split up into a separate commit so
that the following commit has a cleaner diff.
2023-01-04 23:54:50 -05:00
Martin Fischer
8d56e412ef
Add task-tags setting
...
Programmers often leave comments to themselves and others such as:
# TODO: Use a faster algorithm?
The keywords used to prefix such comments are just a convention and vary
from project to project. Other common keywords include FIXME and HACK.
The keywords in use for the codebase are of interest to ruff because
ruff does also lint comments. For example the ERA lint detects
commented-out code but ignores comments starting with such a keyword.
Previously the ERA lint simply hardcoded the regular expression
TODO|FIXME|XXX to achieve that. This commit introduces a new `task-tags`
setting to make this configurable (and to allow other comment lints to
recognize the same set of keywords).
The term "task tags" has probably been popularized by the Eclipse
IDE.[1] For Python there has been the proposal PEP 350[2], which
referred to such keywords as "codetags". That proposal however has been
rejected. We are choosing the term "task tags" over "code tags" because
the former is more descriptive: a task tag describes a task.
While according to the PEP 350 such keywords are also sometimes used for
non-tasks e.g. NOBUG to describe a well-known problem that will never be
addressed due to design problems or domain limitations, such keywords
are so rare that we are neglecting them here in favor of more
descriptive terminology. The vast majority of such keywords does
describe tasks, so naming the setting "task-tags" is apt.
[1]: https://www.eclipse.org/pdt/help/html/task_tags.htm
[2]: https://peps.python.org/pep-0350/
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com >
2023-01-04 23:54:50 -05:00
Charlie Marsh
3400be18a6
Revert "Add task-tags & ignore-overlong-task-comments settings ( #1550 )"
...
This reverts commit ca48492137 .
2023-01-04 23:54:50 -05:00
Charlie Marsh
7b59cd2d32
Bump version to 0.0.211
2023-01-04 23:13:04 -05:00
Charlie Marsh
b8ed4d402a
Implement SIM110 and SIM111 (conversion to any and all) ( #1653 )
2023-01-04 23:08:12 -05:00
messense
46dcf3c4c0
Implement flake8-simplify SIM107 ( #1650 )
2023-01-04 23:02:25 -05:00
Charlie Marsh
ef7777703b
Run generation steps
2023-01-04 22:05:04 -05:00
messense
6a1edeb694
Cancel outdated in-progress workflow automatically ( #1652 )
2023-01-04 22:03:26 -05:00
Charlie Marsh
fb8024a6ac
Implement nested with detection (SIM117) ( #1651 )
2023-01-04 21:22:25 -05:00
Edgar R. M
2f71bdfbfc
Implement flake8-bandit rule S108 ( #1644 )
2023-01-04 21:11:13 -05:00
Charlie Marsh
30d6688c26
Implement nested-if detection ( #1649 )
2023-01-04 20:55:01 -05:00
Charlie Marsh
9041423b92
Move external licenses to separate directory ( #1648 )
2023-01-04 20:07:51 -05:00
Charlie Marsh
c91c435dc9
Fix URL in pyproject.toml
2023-01-04 19:23:40 -05:00
Charlie Marsh
5cb162bd7b
Add missing McCabe comment
2023-01-04 19:16:36 -05:00
Charlie Marsh
7339d7eccf
Implement builtin import removal ( #1645 )
2023-01-04 19:10:16 -05:00
Charlie Marsh
2ff816f108
DRY up unused import removal code ( #1643 )
2023-01-04 19:03:52 -05:00
Charlie Marsh
980d10b952
Add Ruff badge to README ( #1642 )
2023-01-04 17:27:01 -05:00
Charlie Marsh
6c5db1008d
Add badge JSON ( #1641 )
2023-01-04 17:24:27 -05:00
Martin Fischer
ca48492137
Add task-tags & ignore-overlong-task-comments settings ( #1550 )
2023-01-04 17:10:21 -05:00
Charlie Marsh
7c23701b62
Note a few more incompatibilities ( #1639 )
2023-01-04 16:05:15 -05:00
Charlie Marsh
8da2c4815a
Tweak Yoda condition message ( #1638 )
2023-01-04 15:58:01 -05:00
Charlie Marsh
34fec8cbd0
Rename flake8-bandit rules from plugins to checks ( #1637 )
2023-01-04 15:49:05 -05:00
Edgar R. M
1817f8752b
Implement flake8-bandit rule S103 ( #1636 )
2023-01-04 15:47:38 -05:00
Colin Delahunty
8b8e6e44ea
Adding my company to the "used in" category of the Readme. ( #1631 )
2023-01-04 12:31:18 -05:00
Harutaka Kawamura
12166584c4
Minor fixes for SIM105 ( #1633 )
2023-01-04 11:01:06 -05:00
Charlie Marsh
9ede902328
Run generate-all
2023-01-04 10:46:24 -05:00
messense
0df28bdd4e
Implement flake8-simplify SIM105 rule ( #1621 )
2023-01-04 08:10:59 -05:00
Charlie Marsh
8b07f9517a
Implement SIM220 and SIM221 ( #1630 )
2023-01-04 08:07:00 -05:00
Harutaka Kawamura
0a0e1926f2
Check SIM118 in comprehension ( #1627 )
2023-01-04 07:05:13 -05:00
Charlie Marsh
4473c7e905
Update stale references in CONTRIBUTING.md
2023-01-03 23:44:10 -05:00
Charlie Marsh
20930b3675
Add some more users to the README ( #1623 )
2023-01-03 23:06:08 -05:00
Colin Delahunty
fb1a638a96
Implement yield-to-yield from conversion ( #1544 )
2023-01-03 22:56:52 -05:00
Edgar R. M
16964409a8
Implement missing fixes for PT006 ( #1622 )
2023-01-03 22:52:51 -05:00
Charlie Marsh
aacfc9ee0b
Bump version to 0.0.210
2023-01-03 21:46:08 -05:00
Charlie Marsh
bd14f92898
Avoid byte-string conversions ( #1618 )
2023-01-03 21:45:14 -05:00
Charlie Marsh
cc116b0192
Treat convention as setting ignore, rather than select ( #1611 )
2023-01-03 21:27:53 -05:00
Charlie Marsh
0d27c0be27
Treat .pyi files as __future__ annotations-enabled ( #1616 )
2023-01-03 21:27:26 -05:00
Edgar R. M
60359c6adf
Fix leftover whitespace when removing pass for PIE790 ( #1612 )
2023-01-03 20:44:59 -05:00
Charlie Marsh
77692e4b5f
Associate inline comments with parenthesized ImportFrom statements ( #1609 )
2023-01-03 20:02:12 -05:00
Charlie Marsh
731f3a74a9
Fix *arg and **kwarg handling for Google docstrings ( #1608 )
2023-01-03 18:17:42 -05:00
Matt Oberle
03275c9c98
Add isort.order-by-type boolean setting ( #1607 )
2023-01-03 18:07:44 -05:00
Harutaka Kawamura
8d99e317b8
Implement autofix for PT022 ( #1604 )
2023-01-03 13:36:28 -05:00
Maksudul Haque
d4d67e3014
Do not Change Quotation Style for PT006 Autofix ( #1600 )
2023-01-03 10:16:49 -05:00
Charlie Marsh
e9a236f740
Bump version to 0.0.209
2023-01-03 08:27:28 -05:00
Ran Benita
ebb31dc29b
Fix PT006 autofix of parametrize name strings like ' first, , second ' ( #1591 )
2023-01-03 08:12:09 -05:00
Charlie Marsh
b9e92affb1
Avoid silently dropping code generator errors ( #1598 )
2023-01-03 08:11:18 -05:00
Charlie Marsh
68fbd0f029
Preserve style when generating flake8-simplify messages ( #1599 )
2023-01-03 08:05:55 -05:00
Charlie Marsh
8d01efb571
Avoid hard unwrap in PT checks ( #1597 )
2023-01-03 07:39:52 -05:00
Pedram Navid
da5a25b421
Add autofix for SIM300 ( #1588 )
2023-01-03 07:19:04 -05:00
Charlie Marsh
bfdab4ac94
Add flake8-pytest-style settings to hash ( #1595 )
2023-01-03 07:12:33 -05:00
jvstme
d1389894a4
Fix several typos in README ( #1590 )
2023-01-03 07:06:43 -05:00
Charlie Marsh
8b277138de
Bump version to 0.0.208
2023-01-02 23:19:03 -05:00
Charlie Marsh
e0fe34c523
Implement and-false and or-true rules ( #1586 )
2023-01-02 23:10:42 -05:00
Charlie Marsh
995fee5ddd
Increment flake8-pie implementation count
2023-01-02 22:47:05 -05:00
Charlie Marsh
99906c16db
Prefer GitHub icon on mobile ( #1585 )
2023-01-02 22:46:23 -05:00
Charlie Marsh
b6cb35414e
Swap accent color for playground ( #1584 )
2023-01-02 22:44:09 -05:00
Harutaka Kawamura
b351221049
Mark FStringMissingPlaceholders as fixable ( #1582 )
2023-01-02 22:41:40 -05:00
Charlie Marsh
afb6f55b8d
Add a link to GitHub from the playground ( #1583 )
2023-01-02 22:40:38 -05:00
Harutaka Kawamura
03a8ece954
Implement autofix for F541 ( #1577 )
2023-01-02 22:28:32 -05:00
Charlie Marsh
8aeec35bfb
Implement dupe-class-field-definitions ( #1581 )
2023-01-02 22:26:01 -05:00
Charlie Marsh
93259acb31
Implement unnecessary-pass-statement ( #1580 )
2023-01-02 22:15:24 -05:00
Charlie Marsh
ca7fe686d5
Add scripts to generate plugin and check boilerplate ( #1579 )
2023-01-02 22:10:31 -05:00
Charlie Marsh
5dd9e99a4b
Add flake8-pie plugin with prefer_list_builtin ( #1578 )
2023-01-02 21:47:38 -05:00
Charlie Marsh
8f0270acfe
Remove registry_gen.rs at root
2023-01-02 21:31:19 -05:00
Charlie Marsh
7ce38840a2
Re-run registry_gen.rs generation
2023-01-02 21:29:53 -05:00
Charlie Marsh
8ab8217ca5
Fix destination for registry_gen.rs
2023-01-02 21:29:08 -05:00
Charlie Marsh
5d3ff69053
Add comment annotations to plugin match
2023-01-02 20:49:30 -05:00
Charlie Marsh
726399b2b3
Move Ruff checks to the end of each list
2023-01-02 20:44:27 -05:00
Charlie Marsh
8329237f19
Warn user when D203 and D211 are enabled ( #1576 )
2023-01-02 19:54:55 -05:00
Oliver Margetts
cd5882c66d
Remove need for vendored format/cformat code ( #1573 )
2023-01-02 19:37:31 -05:00
Charlie Marsh
0c05488740
Automatically set baseline D codes based on convention ( #1574 )
2023-01-02 19:08:56 -05:00
Charlie Marsh
1425b21d93
Avoid invalid trailing comma fixes for mock rewrites ( #1570 )
2023-01-02 18:03:43 -05:00
Charlie Marsh
e5a59f41b0
Remove extend- from docstring configuration examples ( #1571 )
2023-01-02 17:53:41 -05:00
Charlie Marsh
8647bec3cb
Rename checks.rs to registry.rs ( #1566 )
2023-01-02 17:26:51 -05:00
Charlie Marsh
14042800c2
Remove common-path dependency ( #1565 )
2023-01-02 17:23:29 -05:00
Charlie Marsh
21986e89fd
Always check directly-passed-in files ( #1564 )
2023-01-02 16:49:44 -05:00
Edgar R. M
c4014ef2d3
Implement flake8-pytest-style ( #1506 )
2023-01-02 16:34:17 -05:00
Charlie Marsh
9ffd20707f
Avoid PEP 604 rewrites for runtime annotations ( #1563 )
2023-01-02 16:33:52 -05:00
Charlie Marsh
6d5aa344a1
Avoid merging import from statements with inline comments ( #1562 )
2023-01-02 16:24:41 -05:00
Colin Delahunty
e9be5fc7be
Add typo linter ( #1553 )
2023-01-02 15:57:59 -05:00
Charlie Marsh
f74050e5b1
Bump version to 0.0.207
2023-01-02 14:39:32 -05:00
Martin Fischer
90b2d85c85
Fix __init__.py being private ( #1556 )
...
Previously visibility::module_visibility() returned Private
for any module name starting with an underscore, resulting in
__init__.py being categorized as private, which in turn resulted
in D104 (Missing docstring in public package) never being reported
for __init__.py files.
2023-01-02 14:39:23 -05:00
Charlie Marsh
ccf848705d
Detect unpacking assignments in eradicate ( #1559 )
2023-01-02 14:05:58 -05:00
Charlie Marsh
3b535fcc74
Add explicit new-rule recommendation in CONTRIBUTING.md ( #1558 )
2023-01-02 13:50:11 -05:00
Víctor
06321fd240
Add usage clarification to README ( #1557 )
2023-01-02 13:40:16 -05:00
Martin Fischer
cdae2f0e67
Fix typing::match_annotated_subscript matching ExprKind::Call ( #1554 )
2023-01-02 12:13:45 -05:00
Martin Fischer
f52691a90a
Print warning when running debug builds without --no-cache ( #1549 )
2023-01-02 12:12:04 -05:00
Pedram Navid
07e47bef4b
Add flake8-simplify SIM300 check for Yoda Conditions ( #1539 )
2023-01-01 18:37:40 -05:00
Anders Kaseorg
86b61806a5
Correct UP027 message to “generator expression” ( #1540 )
2023-01-01 18:30:58 -05:00
Charlie Marsh
31ce37dd8e
Avoid PD false positives on some non-DataFrame expressions ( #1538 )
2023-01-01 17:05:57 -05:00
Charlie Marsh
2cf6d05586
Avoid triggering PD errors on method calls ( #1537 )
2023-01-01 17:00:17 -05:00
Colin Delahunty
65c34c56d6
Implement list-to-tuple comprehension unpacking ( #1534 )
2023-01-01 16:53:26 -05:00
Charlie Marsh
2315db7d13
Bump version to 0.0.206
2023-01-01 16:39:29 -05:00
Charlie Marsh
f1a183c171
Rewrite mock.mock attribute accesses ( #1533 )
2023-01-01 13:14:09 -05:00
Harutaka Kawamura
509c6d5ec7
Add visit_format_spec to avoid false positives for F541 in f-string format specifier ( #1528 )
2023-01-01 13:03:32 -05:00
Maksudul Haque
6695988b59
Do not Change Quotation Style for SIM118 Autofix ( #1529 )
2023-01-01 12:53:46 -05:00
Harutaka Kawamura
e3867b172d
Simplify unused snapshot check ( #1525 )
2023-01-01 02:43:07 -05:00
Harutaka Kawamura
4b8e30f350
Fix Name node range in NamedExpr node ( #1526 )
2023-01-01 02:41:49 -05:00
Charlie Marsh
8fd0d8e9d8
Bump pyupgrade implementation count
2022-12-31 21:25:34 -05:00
Colin Delahunty
70895a8f1e
Pyupgrade: import mock to from unittest import mock ( #1488 )
2022-12-31 21:25:06 -05:00
Charlie Marsh
f2c9f94f73
Avoid some false positives for ends-in-period checks ( #1521 )
2022-12-31 18:38:22 -05:00
Charlie Marsh
605c6069e2
Ignore property assignments in RET504 ( #1520 )
2022-12-31 18:04:13 -05:00
Charlie Marsh
92c2981b6d
Add dark mode variant for benchmark image ( #1519 )
2022-12-31 17:47:32 -05:00
Colin Delahunty
4ad8db3d61
Pyupgrade: Turn errors into OSError ( #1434 )
2022-12-31 16:36:05 -05:00
Charlie Marsh
0e8c237167
Bump version to 0.0.205
2022-12-31 13:44:39 -05:00
Harutaka Kawamura
960c5e2006
Use more precise error ranges for names ( #1513 )
2022-12-31 13:42:39 -05:00
Charlie Marsh
9ba17fbf92
Avoid flagging nested f-strings ( #1516 )
2022-12-31 13:41:21 -05:00
Charlie Marsh
bfdf972a5d
Add code kind to Quick Fix action
2022-12-31 10:26:47 -05:00
Charlie Marsh
0c215365ae
Bump version to 0.0.204
2022-12-31 08:20:09 -05:00
Maksudul Haque
815284f890
Check for Unsupported Files and Display Errors and Warnings ( #1509 )
2022-12-31 08:12:55 -05:00
Charlie Marsh
6880338a9a
Restore pyproject.toml
2022-12-31 08:06:08 -05:00
Charlie Marsh
68b749c67d
Remove foo directory
2022-12-31 08:05:04 -05:00
Reiner Gerecke
c0fc55b812
Generate source code with detected line ending ( #1487 )
2022-12-31 08:02:29 -05:00
Reiner Gerecke
ba9cf70917
Adjust test_path helper to detect round-trip autofix issues ( #1501 )
2022-12-31 08:02:13 -05:00
Harutaka Kawamura
f73dfbbfd3
Fix E722 and F707 ranges ( #1508 )
2022-12-31 07:58:46 -05:00
Reiner Gerecke
62c273cd22
Include fix commit message when showing violations together with source ( #1505 )
2022-12-31 07:54:41 -05:00
Harutaka Kawamura
938ad9a39e
Fix N818 range ( #1503 )
2022-12-31 07:43:03 -05:00
Harutaka Kawamura
14248cb8cb
Improve PLW0120 range ( #1500 )
2022-12-31 07:42:49 -05:00
Harutaka Kawamura
3a280039e1
Improve F811 range for function and class definitions ( #1499 )
2022-12-31 07:42:18 -05:00
Harutaka Kawamura
4e9e58bdc0
Improve T20X ranges ( #1502 )
2022-12-31 07:41:53 -05:00
Harutaka Kawamura
926b5494ad
Remove unused snapshots ( #1497 )
2022-12-31 07:40:38 -05:00
Reiner Gerecke
6717b48ca5
Fix detection of changed imports in isort plugin ( #1504 )
2022-12-31 07:37:27 -05:00
Harutaka Kawamura
f7bb5bc858
Remove F831 ( #1495 )
2022-12-30 23:57:51 -05:00
Harutaka Kawamura
3e23fd1487
Stop overriding locations for expressions within f-strings ( #1494 )
2022-12-30 23:43:59 -05:00
Charlie Marsh
01c74e0629
Add a "fix message" to every autofix-able check ( #1489 )
2022-12-30 23:16:03 -05:00
Charlie Marsh
1e3cf87f67
Escape strings when formatting check messages ( #1493 )
2022-12-30 22:11:01 -05:00
Charlie Marsh
248447e139
Trim CLI help during generation ( #1492 )
2022-12-30 22:03:58 -05:00
Charlie Marsh
95f139583a
Modify pyproject.toml to meet schema compliance
2022-12-30 15:51:35 -05:00
Charlie Marsh
74903f23d6
Bump version to 0.0.203
2022-12-30 15:33:30 -05:00
Charlie Marsh
3ee20a70d3
Remove lingering ruff_options.ts references
2022-12-30 15:33:09 -05:00
Charlie Marsh
4c2fbb7ac0
Remove hidden autoformat command ( #1486 )
2022-12-30 15:32:05 -05:00
Charlie Marsh
7a66f98590
Move some argument validation into Clap ( #1485 )
2022-12-30 15:29:41 -05:00
Charlie Marsh
a2bf3916f3
Make clean a standalone command
2022-12-30 15:20:18 -05:00
Reiner Gerecke
c9aa7b9308
Generate the README's --help output automatically via cargo +nightly dev generate-all ( #1483 )
2022-12-30 15:06:32 -05:00
Charlie Marsh
d880ca6cc6
Add a command to clear the Ruff cache ( #1484 )
2022-12-30 13:52:16 -05:00
Reiner Gerecke
080f99b908
Detect line endings and use them during code generation ( #1482 )
2022-12-30 12:59:40 -05:00
Charlie Marsh
a7dc491ff1
Fix clippy
2022-12-30 12:34:43 -05:00
Charlie Marsh
cdc8f8c91a
Remove support for ur prefixes ( #1481 )
2022-12-30 11:21:05 -05:00
Colin Delahunty
138c46e793
Simplified code for unicode fix ( #1475 )
2022-12-30 11:18:52 -05:00
Charlie Marsh
a86c57a832
Support multi-line noqa directives for 'import from' ( #1479 )
2022-12-30 11:16:50 -05:00
Charlie Marsh
818582fe8a
Bump version to 0.0.202
2022-12-30 08:16:32 -05:00
Charlie Marsh
90574c1088
Set editor background on top-level component ( #1478 )
2022-12-30 07:55:54 -05:00
Charlie Marsh
3061a35e7c
Use more precise ranges for class and function checks ( #1476 )
2022-12-30 07:39:20 -05:00
Martin Fischer
87681697ae
Improve CLI help for --select ( #1471 )
2022-12-30 07:16:44 -05:00
Martin Fischer
e9ec2a7b36
Add use test_case::test_case; to CONTRIBUTING.md
...
I previously tried adding the #[test_case()] attribute macro and got
confused because the Rust compilation suddenly failed with:
error[E0658]: use of unstable library feature 'custom_test_frameworks': custom test frameworks are an unstable feature
which is a quite confusing error message. The solution is to just add
`use test_case::test_case;`, so this commit adds that line to the
example in CONTRIBUTING.md to spare others this source of confusion.
2022-12-30 07:13:48 -05:00
Martin Fischer
b0bb75dc1c
Add --select to command suggested in CONTRIBUTING.md
...
By default only E* and F* lints are enabled. I previously followed the
CONTRIBUTING.md instructions to implement a TID* lint and was confused
why my lint wasn't being run.
2022-12-30 07:13:48 -05:00
Martin Fischer
ebca5c2df8
Make banned-api config setting optional ( #1465 )
2022-12-30 07:09:56 -05:00
Charlie Marsh
16b10c42f0
Fix lint issues
2022-12-29 23:12:28 -05:00
Charlie Marsh
4a6e5d1549
Bump version to 0.0.201
2022-12-29 23:01:35 -05:00
Charlie Marsh
b078050732
Implicit flake8-implicit-str-concat ( #1463 )
2022-12-29 23:00:55 -05:00
Charlie Marsh
5f796b39b4
Run cargo fmt
2022-12-29 22:25:14 -05:00
Martin Fischer
9d34da23bd
Implement TID251 (banning modules & module members) ( #1436 )
2022-12-29 22:11:12 -05:00
Charlie Marsh
bde12c3bb3
Restore quick fixes for playground
2022-12-29 20:16:19 -05:00
Colin Delahunty
f735660801
Removed unicode literals ( #1448 )
2022-12-29 20:11:33 -05:00
Charlie Marsh
34cd22dfc1
Copy URL but don't update the hash ( #1458 )
2022-12-29 19:46:50 -05:00
Charlie Marsh
9fafe16a55
Re-add GitHub badge to the bottom of the page
2022-12-29 19:38:33 -05:00
Charlie Marsh
e9a4cb1c1d
Remove generated TypeScript options ( #1456 )
2022-12-29 19:37:49 -05:00
Charlie Marsh
9db825c731
Use trailingComma: 'all' ( #1457 )
2022-12-29 19:36:51 -05:00
Charlie Marsh
2c7464604a
Implement dark mode ( #1455 )
2022-12-29 19:33:46 -05:00
Charlie Marsh
cd2099f772
Move default options into WASM interface ( #1453 )
2022-12-29 18:06:57 -05:00
Adam Turner
091d36cd30
Add Sphinx to user list ( #1451 )
2022-12-29 18:06:09 -05:00
Mathieu Kniewallner
02f156c6cb
docs(README): add missing flake8-simplify ( #1449 )
2022-12-29 17:02:26 -05:00
Charlie Marsh
9f7350961e
Rename config to settings in the playground ( #1450 )
2022-12-29 16:59:38 -05:00
Charlie Marsh
118a93260a
Bump version to 0.0.200
2022-12-29 13:31:23 -05:00
Charlie Marsh
1c16255884
Include docstrings for settings enum members ( #1446 )
2022-12-29 13:15:44 -05:00
Charlie Marsh
16c4552946
Update snapshots
2022-12-29 13:13:43 -05:00
Charlie Marsh
0ba3989b3d
Make update check enablement cofnigurable ( #1445 )
2022-12-29 13:06:22 -05:00
Charlie Marsh
3435e15cba
Avoid caching diffs ( #1441 )
2022-12-29 12:51:58 -05:00
Maksudul Haque
781bbbc286
[pygrep-hooks] Adds Check for Blanket # noqa ( #1440 )
2022-12-29 12:43:16 -05:00
Charlie Marsh
acf0b82f19
Re-style the Ruff playground ( #1438 )
2022-12-29 11:47:27 -05:00
Charlie Marsh
057414ddd4
Bump version to 0.0.199
2022-12-28 20:58:43 -05:00
Charlie Marsh
ca94e9aa26
Warn the user when max iteration count is reached ( #1433 )
2022-12-28 20:56:43 -05:00
Charlie Marsh
797b5bd261
Split into lint and lint-and-fix methods ( #1432 )
2022-12-28 20:14:33 -05:00
Charlie Marsh
a64f62f439
Revert setup.py change
2022-12-28 19:34:20 -05:00
Charlie Marsh
058ee8e6bf
Add a --diff flag to dry-run autofixes ( #1431 )
2022-12-28 19:21:29 -05:00
Charlie Marsh
39fc1f0c1b
Add a note on autofix settings
2022-12-28 17:26:38 -05:00
Colin Delahunty
34842b4c4b
PyUpgrade: Replace pipes with capture_output=True ( #1415 )
2022-12-28 16:53:35 -05:00
Charlie Marsh
dfa6fa8f83
Check in updated snapshots
2022-12-28 16:42:55 -05:00
Colin Delahunty
6131c819ed
Rewrite xml.etree.cElementTree to xml.etree.ElementTree ( #1426 )
2022-12-28 16:30:36 -05:00
Hannes Käufler
79ba420faa
Extract duplicated logic into method ( #1428 )
2022-12-28 16:10:53 -05:00
Charlie Marsh
d16ba890ae
Turn off wasm-pack tests ( #1427 )
2022-12-28 12:55:25 -05:00
Charlie Marsh
6b6851bf1f
Update JSON schema
2022-12-28 12:27:01 -05:00
Charlie Marsh
056718ce75
Remove stray Plugins doc
2022-12-28 12:24:48 -05:00
Charlie Marsh
4521fdf021
Only test --lib for wasm-pack
2022-12-28 10:28:40 -05:00
Maksudul Haque
8e479628f2
Add Support for GitLab CI Code Quality Report Format ( #1424 )
2022-12-28 10:10:43 -05:00
Charlie Marsh
2a11c4b1f1
Try increasing wasm-bindgen timeout
2022-12-28 07:39:23 -05:00
Anders Kaseorg
a8cde5a936
Check for keyword arguments before the last star argument ( #1420 )
2022-12-27 23:20:03 -05:00
Charlie Marsh
1822b57ed5
Remove 'static
2022-12-27 21:57:32 -05:00
Charlie Marsh
c679570041
Bump version to 0.0.198
2022-12-27 21:39:53 -05:00
Charlie Marsh
edcb3a7217
Support --select ALL to enable all error codes ( #1418 )
2022-12-27 21:38:26 -05:00
Charlie Marsh
6e43dc7270
Add nbQA support to the docs ( #1417 )
2022-12-27 21:24:07 -05:00
Charlie Marsh
570d0864f2
Add rule to detect keyword arguments before starred arguments ( #1416 )
2022-12-27 21:17:22 -05:00
Charlie Marsh
d22e96916c
Automatically detect and respect indentation and quotation code style ( #1413 )
2022-12-27 19:45:50 -05:00
Charlie Marsh
043d31dcdf
Bump version to 0.0.197
2022-12-27 17:05:15 -05:00
Charlie Marsh
1392e4cced
Default to double quotes in code_gen.rs ( #1412 )
2022-12-27 16:17:49 -05:00
Charlie Marsh
59ee89a091
Fix it_converts_docstring_conventions test
2022-12-27 15:41:29 -05:00
Charlie Marsh
6a7c3728ee
Set convention in flake8-to-ruff ( #1410 )
2022-12-27 13:51:24 -05:00
Charlie Marsh
0a60eb0aca
Fix invalid reference to ruff_options.rs ( #1409 )
2022-12-27 12:12:28 -05:00
Charlie Marsh
3e96803033
Bump version to 0.0.196
2022-12-27 12:02:02 -05:00
Colin Delahunty
c59035139c
Pyupgrade: converts universal_newlines to text in subprocess.run ( #1403 )
2022-12-27 12:01:27 -05:00
Charlie Marsh
7632d7eda7
Allow specification of explicit docstring convention ( #1408 )
2022-12-27 11:50:28 -05:00
Charlie Marsh
b4dbe62da0
Add cargo +nightly dev generate-all ( #1404 )
2022-12-27 10:07:18 -05:00
Harutaka Kawamura
9106d5338b
Replace make_tokenize with make_tokenizer_located ( #1405 )
2022-12-27 10:07:03 -05:00
Reiner Gerecke
534d8d049c
Support isort's force-single-line option ( #1366 )
2022-12-27 08:51:32 -05:00
Charlie Marsh
e692c4a2cc
Tweak secret detection for playground releases ( #1402 )
2022-12-27 08:41:53 -05:00
Reiner Gerecke
e0b39fa63e
Implement pyupgrade check for io.open alias ( #1399 )
2022-12-27 07:47:40 -05:00
Charlie Marsh
320a48977b
Tweak README again
2022-12-26 21:17:18 -05:00
Charlie Marsh
0d05aaeb6e
Add monorepo note
2022-12-26 21:00:14 -05:00
Charlie Marsh
1e4b1533ad
Bump version to 0.0.195
2022-12-26 20:41:39 -05:00
Charlie Marsh
df4f5358f9
Bump pyupgrade implementation count
2022-12-26 19:56:12 -05:00
Colin Delahunty
58c383401c
Replace typing.Text with str ( #1391 )
2022-12-26 19:55:41 -05:00
Charlie Marsh
018b9a2977
Only run playground release in main repo ( #1396 )
2022-12-26 19:45:04 -05:00
Charlie Marsh
658cb87ddd
Enable Quick Fix in the playground ( #1395 )
2022-12-26 19:25:50 -05:00
Charlie Marsh
0d35087bc6
Choose a more interesting example snippet ( #1394 )
2022-12-26 15:19:17 -05:00
Charlie Marsh
b721125af9
Add badge to playground ( #1393 )
2022-12-26 15:13:55 -05:00
Charlie Marsh
20d6b21d77
Add ESLint, Prettier, and TypeScript checks ( #1384 )
2022-12-26 15:08:22 -05:00
Charlie Marsh
1a27992f47
Enable preview deployments for playground ( #1383 )
2022-12-26 14:52:13 -05:00
Charlie Marsh
89cebe1ce2
Update name of Playground job
2022-12-26 12:10:22 -05:00
Reiner Gerecke
bdb1505262
Web playground with WASM ( #1279 )
2022-12-26 12:09:17 -05:00
Charlie Marsh
8c018e8261
Add settings validation to lib.rs
2022-12-26 10:12:07 -05:00
Colin Delahunty
debd909b2c
Magic Trailing Commas in isort ( #1363 )
2022-12-26 09:40:02 -05:00
Reiner Gerecke
fa54538bd1
Only re-associate inline comments during normalization when necessary ( #1380 )
2022-12-26 07:52:13 -05:00
Reiner Gerecke
939f738a71
Update rust python to handle files with BOM ( #1379 )
2022-12-26 07:03:13 -05:00
Charlie Marsh
b0f30bef8f
Add support for ruff.toml ( #1378 )
2022-12-25 21:55:07 -05:00
Charlie Marsh
28c45eb2a3
Remove required versions from pyproject.toml
2022-12-25 20:21:01 -05:00
Charlie Marsh
4dc45912e8
Run cargo dev commands
2022-12-25 20:12:12 -05:00
Charlie Marsh
5ef8bff341
Bump version to 0.0.194
2022-12-25 19:54:45 -05:00
Charlie Marsh
2ab8f77223
Update command-line help text
2022-12-25 19:54:14 -05:00
Charlie Marsh
8b72f55a09
Add --required-version ( #1376 )
2022-12-25 19:53:50 -05:00
Charlie Marsh
19121219fb
Avoid double-extending past the end when showing source ( #1377 )
2022-12-25 19:52:42 -05:00
Charlie Marsh
d9355c989a
Add a --fix-only command-line and pyproject.toml option ( #1375 )
2022-12-25 18:49:56 -05:00
Charlie Marsh
ec80d1cd85
Respect natural ordering for imports ( #1374 )
2022-12-25 18:11:41 -05:00
Charlie Marsh
9bb470c7d4
Ignore unused arguments for @overload stubs ( #1373 )
2022-12-25 17:22:31 -05:00
Harutaka Kawamura
dca3fcd8d1
Improve excepthandler_name_range ( #1368 )
2022-12-25 00:12:12 -05:00
Harutaka Kawamura
10f75c9620
Fix F841 (UnusedVariable) range in except handler ( #1367 )
2022-12-24 22:55:55 -05:00
Charlie Marsh
cc2110449c
Run cargo dev commands
2022-12-24 15:06:12 -05:00
Charlie Marsh
f6ca49e05f
Bump version to 0.0.193
2022-12-24 14:56:26 -05:00
Charlie Marsh
9a7331b2e2
Annotate RUF100 messages with unmatched, disabled, and unknown codes ( #1365 )
2022-12-24 14:55:55 -05:00
Edgar R. M
4888afd423
Generate JSON schema for Ruff options ( #1329 )
2022-12-24 14:10:22 -05:00
Sawbez
0dc523b081
Add autofix for W605 [InvalidEscapeSequence] ( #1361 )
2022-12-24 13:46:28 -05:00
Harutaka Kawamura
63772e335d
Fix B025 location ( #1360 )
2022-12-24 12:22:11 -05:00
Reiner Gerecke
7f4ff1e38f
Fix false-positive in RET504 when referencing globals ( #1358 )
2022-12-24 12:02:57 -05:00
Reiner Gerecke
32ebc1d227
Don't trigger E721 when comparing with None ( #1356 )
2022-12-24 04:45:40 -05:00
Sawbez
4ded155dc0
Add autofix for W292 [NoNewLineAtEndOfFile] ( #1354 )
2022-12-23 23:14:17 -05:00
Harutaka Kawamura
201e1250de
Update RustPython to use the correct BinOp location ( #1355 )
2022-12-23 22:58:39 -05:00
Reiner Gerecke
102b049a32
Add cache-dir to command-line and pyproject.toml ( #1351 )
2022-12-23 22:58:29 -05:00
Charlie Marsh
74f49eda64
Bump compatibility to 3.11 ( #1352 )
2022-12-23 12:12:11 -05:00
Reiner Gerecke
9da3e2cca1
Implement "native literals" check from pyupgrade ( #1350 )
2022-12-23 11:40:32 -05:00
Charlie Marsh
e290050821
Avoid enabling all EM checks at once ( #1349 )
2022-12-23 08:25:07 -05:00
Charlie Marsh
bc9ed0a4ef
Tweak LSP docs
2022-12-22 22:16:32 -05:00
Charlie Marsh
20b9b44973
Link to ruff-lsp docs
2022-12-22 21:53:11 -05:00
Charlie Marsh
6e5a553235
Update Neovim instructions
2022-12-22 21:52:30 -05:00
Charlie Marsh
2a08a63f17
Add a link to the PyCharm plugin ( #1345 )
2022-12-22 21:50:24 -05:00
Colin Delahunty
d4290e6721
Update CONTRIBUTING.md ( #1344 )
2022-12-22 21:04:19 -05:00
Charlie Marsh
51bda28a7d
Bump version to 0.0.192
2022-12-22 17:31:31 -05:00
Reiner Gerecke
cc26051b7a
Implement "datetime.UTC alias" check from pyupgrade ( #1341 )
2022-12-22 17:21:36 -05:00
Charlie Marsh
3ac5a9aa31
Respect --force-exclude for files passed via stdin ( #1342 )
2022-12-22 16:40:15 -05:00
Charlie Marsh
451047c30d
Exclude directly-passed files nested in excluded subdirectories
2022-12-22 15:08:11 -05:00
Charlie Marsh
6907df489b
Extend false-positive list for flake8-boolean-trap ( #1338 )
2022-12-22 10:56:04 -05:00
Charlie Marsh
970f882b03
Set force-exclude for pre-commit in README ( #1337 )
2022-12-22 10:51:20 -05:00
Charlie Marsh
3eff9a2860
Allow unittest methods in flake8-boolean-trap ( #1333 )
2022-12-22 08:40:22 -05:00
Charlie Marsh
a4a24a0ef3
Add some more repositories to the user list ( #1328 )
2022-12-21 22:16:47 -05:00
Charlie Marsh
48e3c046b0
Fix integration tests
2022-12-21 21:25:37 -05:00
Charlie Marsh
03e4f5be8a
Bump version to 0.0.191
2022-12-21 21:16:21 -05:00
Charlie Marsh
99657b7d92
Implement E401 ("multiple imports on one line") ( #1326 )
2022-12-21 21:15:57 -05:00
Charlie Marsh
40377aa1fc
Move number of errors to the bottom of the output summary ( #1325 )
2022-12-21 21:04:26 -05:00
Charlie Marsh
2a37017e8c
Add src to Settings hash
2022-12-21 21:01:20 -05:00
Charlie Marsh
ff66d08cef
Run generate-options
2022-12-21 20:58:14 -05:00
Charlie Marsh
dad8035eef
Support shell expansion in src field ( #1324 )
2022-12-21 20:57:20 -05:00
Charlie Marsh
bf5fec342c
Support shell expansion in extend paths ( #1323 )
2022-12-21 20:46:38 -05:00
Charlie Marsh
66a6c81ebf
Infer package roots when running via stdin ( #1321 )
2022-12-21 20:30:10 -05:00
Charlie Marsh
5c70f5044b
Improve debug logging in flake8-to-ruff ( #1320 )
2022-12-21 20:05:48 -05:00
Charlie Marsh
953d141ab2
Support code redirects in flake8-to-ruff ( #1318 )
2022-12-21 19:31:20 -05:00
Charlie Marsh
07dba46039
Extract line length from pyproject.toml Black section ( #1317 )
2022-12-21 19:05:18 -05:00
Ran Benita
3b02da9d7b
Fix false positive DTZ001 on datetime(2000, 1, 1, 0, 0, 0, 0, utc) ( #1308 )
2022-12-21 19:03:36 -05:00
Charlie Marsh
20234c6156
Bump version to 0.0.190
2022-12-21 16:01:48 -05:00
Charlie Marsh
de767cc026
Avoid used-prior-global-declaration false-positives in f-strings ( #1314 )
2022-12-21 14:34:09 -05:00
Charlie Marsh
ce1663d302
Allow overriding cache location via RUFF_CACHE_DIR ( #1312 )
2022-12-21 14:24:10 -05:00
Charlie Marsh
f40e4bcd14
Avoid flagging RUF100 as a RUF100 violation ( #1305 )
2022-12-20 17:40:10 -05:00
Charlie Marsh
e7d40d435f
Avoid F821 false positives for Mypy extensions ( #1304 )
2022-12-20 16:29:33 -05:00
Charlie Marsh
ef8fe31c0c
Bump version to 0.0.189
2022-12-20 13:26:17 -05:00
Charlie Marsh
226f682c99
Avoid DTZ007 false-positives for non-string arguments ( #1300 )
2022-12-20 13:20:53 -05:00
Hannes Käufler
468ffd29fb
[Stylistic/non-functional] Use an r# format string to make json easier to read ( #1299 )
2022-12-20 12:55:21 -05:00
Charlie Marsh
a61126ab23
Run generate-options
2022-12-19 23:19:05 -05:00
Charlie Marsh
54c7c25861
Revert test changes to setup.py
2022-12-19 20:09:47 -05:00
Charlie Marsh
eff7700d92
Add --force-exclude setting to force exclusions with pre-commit ( #1295 )
2022-12-19 20:08:59 -05:00
Charlie Marsh
8934f6938d
Avoid RET504 errors for intermediary function calls ( #1294 )
2022-12-19 19:48:09 -05:00
Charlie Marsh
8f0fc3033a
Update Arg section checking to match latest pydocstyle ( #1293 )
2022-12-19 16:39:42 -05:00
Charlie Marsh
4107bc828d
Bump version to 0.0.188
2022-12-19 12:18:06 -05:00
Charlie Marsh
706d28cabc
Rename PDV checks to PD ( #1288 )
2022-12-19 00:20:28 -05:00
Charlie Marsh
4da2264722
Avoid T201 errors for print(..., file=fp)-like calls ( #1287 )
2022-12-19 00:10:07 -05:00
Charlie Marsh
bf88c815aa
Move flake8-debugger tests into flake8-debugger subdirectory ( #1286 )
2022-12-18 22:06:42 -05:00
Yasu_umi
8a4831dd5b
Implement flake8-datetimez ( #1270 )
2022-12-18 22:06:06 -05:00
Charlie Marsh
b5ab492a70
Bump version to 0.0.187
2022-12-18 20:09:02 -05:00
Charlie Marsh
1fc09ebd5c
Fix inverted E501 condition ( #1285 )
2022-12-18 20:08:30 -05:00
Charlie Marsh
6cf047976c
Bump pygrep-hooks tally in README
2022-12-18 18:05:32 -05:00
Reiner Gerecke
87465daacc
pygrep-hooks - deprecated use of logging.warn & no blanket type ignore ( #1275 )
2022-12-18 18:04:21 -05:00
Chris Brendel
a52bed7101
Use --stdin-filename when resolving configuration files ( #1281 )
2022-12-18 17:51:55 -05:00
Anders Kaseorg
20ac823778
generate-check-code-prefix: Run rustfmt automatically; only write if changed ( #1282 )
2022-12-18 17:46:23 -05:00
Charlie Marsh
1028ed3565
Bump version to 0.0.186
2022-12-18 14:30:30 -05:00
Anders Kaseorg
98897db6ac
Add packaging status badge from repology ( #1276 )
2022-12-18 14:27:29 -05:00
Honkertonken
5ce4262112
Readme : Fix incorrect exmaple. ( #1277 )
2022-12-18 12:04:48 -05:00
Charlie Marsh
6b2359384d
Print redirect warnings exactly once per code ( #1280 )
2022-12-18 12:03:49 -05:00
Harutaka Kawamura
d3443d7c19
Update RustPython to use correct Tuple location ( #1278 )
2022-12-18 08:53:57 -05:00
Anders Kaseorg
04b1e1de6f
README: Add missing backtick ( #1274 )
2022-12-18 00:29:33 -05:00
Anders Kaseorg
c93c85300f
Repair corrupted PDV007, PDV009 messages ( #1273 )
2022-12-18 00:29:12 -05:00
Charlie Marsh
73ed6f8654
Touch-up README
2022-12-17 21:38:45 -05:00
Charlie Marsh
eb183645f3
Add ruff-lsp to README ( #1272 )
...
Add ruff-lsp to README
2022-12-17 21:37:11 -05:00
Charlie Marsh
ef17aa93da
Add ruff-lsp to README ( #1272 )
2022-12-17 21:37:00 -05:00
Charlie Marsh
f366b0147f
Add ruff-lsp to README ( #1272 )
2022-12-17 21:35:44 -05:00
Charlie Marsh
fc88fa35ff
Add instructions for Sublime Text installation ( #1271 )
2022-12-17 16:22:50 -05:00
Charlie Marsh
a2806eb8ef
Bump version to 0.0.185
2022-12-16 23:47:56 -05:00
Charlie Marsh
89d919eac5
Re-remove W605_1.py from Black compatibility test
2022-12-16 23:17:27 -05:00
Charlie Marsh
5ad77fbc8d
Move checkers into their own module ( #1268 )
2022-12-16 22:55:47 -05:00
Charlie Marsh
9cb18a481b
Separate line-based checker from noqa enforcement ( #1267 )
2022-12-16 22:49:27 -05:00
Charlie Marsh
2393e270ed
Change a few more methods to take AsRef<Path>
2022-12-16 21:38:52 -05:00
Charlie Marsh
f36e6035c8
Change a few methods to take AsRef<Path>
2022-12-16 21:28:19 -05:00
Charlie Marsh
ecf0dd05d6
Auto-detect same-package imports ( #1266 )
2022-12-16 21:19:11 -05:00
Charlie Marsh
5f67ee93f7
Replace cache bool with an enum
2022-12-16 15:45:30 -05:00
Charlie Marsh
1e19142d0e
Bump version to 0.0.184
2022-12-16 14:36:25 -05:00
Charlie Marsh
6a95dade6d
Actually check-in snapshots for #1265
2022-12-16 14:36:00 -05:00
Charlie Marsh
d6e765877e
Enable autofix for __init__ method with missing None-return ( #1265 )
2022-12-16 14:28:56 -05:00
Charlie Marsh
e4d36bae57
Replace ignore_noqa and autofix booleans with enums ( #1264 )
2022-12-16 14:01:25 -05:00
Harutaka Kawamura
e3531276a7
Fix F501 (line-too-long) start location ( #1262 )
2022-12-16 11:29:47 -05:00
Charlie Marsh
634553f188
Add ignore-variadic-names options to flake8-unused-arguments ( #1261 )
2022-12-16 00:22:38 -05:00
Edgar R. M
4ff0b75045
test: Fix flake8-errmsg snapshots ( #1260 )
2022-12-15 23:53:15 -05:00
Charlie Marsh
481d668511
Add flake8-errmsg to README
2022-12-15 23:16:38 -05:00
Charlie Marsh
a9f56ee76e
Bump version to 0.0.183
2022-12-15 23:15:12 -05:00
Charlie Marsh
b4bfa87104
Avoid removing partially-unused imports ( #1259 )
2022-12-15 23:13:58 -05:00
Charlie Marsh
b9f42bf5e5
Remove extraneous test file
2022-12-15 23:12:19 -05:00
Edgar R. M
8281d414ca
Implement flake8-errmsg ( #1258 )
2022-12-15 23:10:59 -05:00
Charlie Marsh
7e45a9f2e2
Avoid generating invalid statements when deleting from multi-statement lines ( #1253 )
2022-12-15 22:17:31 -05:00
Reiner Gerecke
a000cd4a09
Test to prevent continious reformatting when used together with black ( #1206 )
2022-12-15 15:26:41 -05:00
Martin Lehoux
d8b4b92733
Implement U016: Remove six compatibility code ( #1013 )
2022-12-15 14:16:58 -05:00
Edgar R. M
27de342e75
Implement pandas-vet ( #1235 )
2022-12-15 14:01:01 -05:00
Charlie Marsh
d805067683
Avoid fixing E711 and E712 issues that would cause F632 ( #1248 )
2022-12-15 12:08:31 -05:00
Charlie Marsh
1ea2e93f8e
Bump version to 0.0.182
2022-12-14 22:57:22 -05:00
Charlie Marsh
dc180dc277
Negate ignore_names condition
2022-12-14 22:50:26 -05:00
Charlie Marsh
6be910ae07
Use more precise ranges for function and class checks ( #1247 )
2022-12-14 22:40:00 -05:00
Charlie Marsh
ba85eb846c
Run cargo fmt
2022-12-14 21:52:44 -05:00
Charlie Marsh
d067efe265
Treat extend-* configuration options as "always extended" ( #1245 )
2022-12-14 20:22:40 -05:00
Charlie Marsh
549ea2f85f
Ignore any pyproject.toml without a [tool.ruff] section ( #1243 )
2022-12-14 19:35:52 -05:00
Charlie Marsh
d814ebd21f
Bump version to 0.0.181
2022-12-14 17:35:36 -05:00
Charlie Marsh
3f272b6cf8
Enable opt-out of .gitignore checks via respect-gitignore flag ( #1242 )
2022-12-14 16:54:23 -05:00
Charlie Marsh
76891a8c07
Always check zero-depth CLI paths ( #1241 )
2022-12-14 16:32:02 -05:00
Charlie Marsh
e389201b5f
Add new .gitignore behavior to BREAKING_CHANGES.md ( #1240 )
2022-12-14 16:04:06 -05:00
Charlie Marsh
4b2020d03a
Automatically ignore files specified in .gitignore ( #1234 )
2022-12-14 15:58:40 -05:00
Charlie Marsh
0aa356c96c
Avoid converting expression to statement in invald contexts ( #1239 )
2022-12-14 13:57:25 -05:00
Charlie Marsh
630b4b627d
Apply fix to all errors in E711 and E712 autofix ( #1238 )
2022-12-14 13:29:56 -05:00
Charlie Marsh
854cd14842
Bump version to 0.0.180
2022-12-14 13:21:10 -05:00
Chris Brendel
6b93c8403f
Apply CLI options even when no pyproject.toml is found ( #1232 )
2022-12-13 22:55:04 -05:00
Charlie Marsh
765d21c7b0
Bump version to 0.0.179
2022-12-13 10:17:16 -05:00
Charlie Marsh
a58b9b5063
Upgrade RustPython to support parenthesized context managers ( #1228 )
2022-12-13 10:16:43 -05:00
Charlie Marsh
f3e11a30cb
Bump version to 0.0.178
2022-12-12 22:06:04 -05:00
Charlie Marsh
2f3b5367ff
Add a note on extends to README
2022-12-12 21:36:39 -05:00
Charlie Marsh
92bc417e4e
Add support for glob patterns in src ( #1225 )
2022-12-12 21:35:03 -05:00
Charlie Marsh
9853b0728b
Enable configuration files to "extend" other configuration files ( #1219 )
2022-12-12 20:28:22 -05:00
Charlie Marsh
77709dcc41
Remove underscore from extend_exclude
2022-12-12 16:34:16 -05:00
Charlie Marsh
b0cb5fc7ef
Document current behavior around pyproject.toml discovery ( #1213 )
2022-12-12 11:49:21 -05:00
Charlie Marsh
d6f51e55dd
Remove extraneous test_project
2022-12-12 10:53:12 -05:00
Charlie Marsh
4bb6b4851a
Rename p to path
2022-12-12 10:51:24 -05:00
Charlie Marsh
54c5ded938
Move settings path discovery into its own function
2022-12-12 10:50:08 -05:00
Charlie Marsh
0157fedab5
Move Python file resolution into resolver.rs ( #1211 )
2022-12-12 10:43:50 -05:00
Charlie Marsh
cd69610741
Use --config everywhere if provided ( #1210 )
2022-12-12 10:28:00 -05:00
Charlie Marsh
a3d06d0005
Move more commands into commands.rs ( #1209 )
2022-12-12 10:22:47 -05:00
Charlie Marsh
ac6fa1dc88
Simplify some logic around configuration detection ( #1197 )
2022-12-12 10:15:05 -05:00
Charlie Marsh
73794fc299
Resolve hierarchical settings and Python files in a single filesystem pass ( #1205 )
2022-12-12 10:13:52 -05:00
Charlie Marsh
0adc9ed259
Support hierarchical settings for nested directories ( #1190 )
2022-12-12 10:12:23 -05:00
Charlie Marsh
19e9eb1af8
Bump version to 0.0.177
2022-12-11 22:38:52 -05:00
Anders Kaseorg
e57044800c
Fix quotes in SIM118 error message ( #1204 )
2022-12-11 22:30:39 -05:00
Charlie Marsh
ae8ff7cb7f
Add notes around python-lsp-ruff ( #1202 )
2022-12-11 17:36:20 -05:00
Charlie Marsh
c05914f222
Avoid inserting extra newlines for comment-delimited import blocks ( #1201 )
2022-12-11 17:13:09 -05:00
Charlie Marsh
24179655b8
Fix 'a test' reference
2022-12-11 13:31:14 -05:00
Charlie Marsh
d27b419e68
Run cargo dev generate-options
2022-12-11 10:34:52 -05:00
Charlie Marsh
9fc7a32a24
Sort list in README
2022-12-11 10:25:27 -05:00
Charlie Marsh
9161b866b5
Bump version to 0.0.176
2022-12-11 10:19:50 -05:00
Reiner Gerecke
38141a6f14
Check for outdated auto-generated files in CI ( #1192 )
2022-12-11 10:18:57 -05:00
Charlie Marsh
aa5402fc0e
Add flake8-simplify to flake8-to-ruff
2022-12-11 10:10:46 -05:00
Charlie Marsh
99f077aa4e
Add missing hash in README comment
2022-12-11 10:05:32 -05:00
Reiner Gerecke
7f25d1ec70
Implement SIM118 (key in dict) of flake8-simplify ( #1195 )
2022-12-11 10:05:11 -05:00
Charlie Marsh
360b033e04
Avoid F821 false positive on annotated global ( #1196 )
2022-12-11 10:04:06 -05:00
Reiner Gerecke
247dcc9f9c
Mark C413 as fixable ( #1191 )
2022-12-11 09:07:51 -05:00
Charlie Marsh
c86e52193c
Bump version to 0.0.175
2022-12-10 21:23:19 -05:00
Harutaka Kawamura
efdc4e801d
Upgrade RustPython to fix end location of implicitly concatenated strings ( #1187 )
2022-12-10 19:16:01 -05:00
Charlie Marsh
f8f2eeed35
Enable --no-show-source for consistency ( #1189 )
2022-12-10 19:09:49 -05:00
Charlie Marsh
8fa414b67e
Move configuration-CLI resolution into dedicated methods ( #1188 )
2022-12-10 19:07:38 -05:00
Charlie Marsh
484d7a30bd
Add TODO around nested globals
2022-12-10 17:44:08 -05:00
Charlie Marsh
fb681c614a
Move string formatting checks to plugins ( #1185 )
2022-12-10 16:43:21 -05:00
Reiner Gerecke
06ed125771
Add autofix for F504 and F522 ( #1184 )
2022-12-10 16:33:09 -05:00
Charlie Marsh
74668915b0
Remove serialization format from Settings struct ( #1183 )
2022-12-10 13:38:59 -05:00
Charlie Marsh
6da3de25ba
Add jupyter_server to README ( #1182 )
2022-12-10 12:10:27 -05:00
Charlie Marsh
63b3e00c97
Bump version to 0.0.174
2022-12-10 12:08:48 -05:00
Charlie Marsh
39440aa274
Create function and lambda scopes eagerly ( #1181 )
2022-12-10 12:08:33 -05:00
Charlie Marsh
add96d3dc5
Implement E0117 (nonlocal-without-binding) ( #1180 )
2022-12-10 11:41:57 -05:00
Charlie Marsh
6f8e0224d0
Implement W0602 (global-variable-not-assigned) ( #1179 )
2022-12-10 11:33:24 -05:00
Charlie Marsh
b8bbafd85b
Flag global usages prior to global declarations ( #1178 )
2022-12-10 11:19:24 -05:00
Charlie Marsh
40b54d3e8c
Ignore imports in class scopes ( #1176 )
2022-12-10 10:23:33 -05:00
Charlie Marsh
2b44941d63
Add pacman instructions to README ( #1175 )
2022-12-10 10:00:01 -05:00
Charlie Marsh
257bd7f1d7
Bump version to 0.0.173
2022-12-09 23:23:12 -05:00
Charlie Marsh
5728dceef0
Add note around redefinitions
2022-12-09 23:18:51 -05:00
Charlie Marsh
6739602806
Mark redefined-but-unused imports as unused regardless of scope ( #1173 )
2022-12-09 23:17:33 -05:00
Charlie Marsh
305326f7d7
Remove some string clones from docstring helpers ( #1172 )
2022-12-09 22:30:34 -05:00
Charlie Marsh
69866f5461
Extract docstring exactly once ( #1171 )
2022-12-09 22:21:16 -05:00
Charlie Marsh
41ca29c4f4
Add TODO in redefined_by_function
2022-12-09 21:19:57 -05:00
Charlie Marsh
b35a804f9d
Bump version to 0.0.172
2022-12-09 17:47:34 -05:00
Charlie Marsh
e594ed6528
Implement D301 (backslash checks) ( #1169 )
2022-12-09 17:44:18 -05:00
Charlie Marsh
197645d90d
Always use raw docstrings for pydocstyle rules ( #1167 )
2022-12-09 17:31:04 -05:00
Charlie Marsh
26d3ff5a3a
Add pyflakes test suite for annotations ( #1166 )
2022-12-09 16:28:07 -05:00
Charlie Marsh
0dacf61153
Implement F842 (UnusedAnnotation) ( #1165 )
2022-12-09 12:42:03 -05:00
Charlie Marsh
a6251360b7
Avoid RET false-positives for usages in f-strings ( #1163 )
2022-12-09 12:28:09 -05:00
Charlie Marsh
2965e2561d
Clarify combination of combine-as-imports and force-wrap-aliases ( #1162 )
2022-12-09 12:20:15 -05:00
Charlie Marsh
a19050b8a4
Update README.md
2022-12-08 23:39:01 -05:00
Charlie Marsh
dfd6225d85
Bump version to 0.0.171
2022-12-08 23:18:48 -05:00
Charlie Marsh
a0a6327fae
Only allowlist noqa et al at the start of a comment ( #1157 )
2022-12-08 23:10:36 -05:00
Charlie Marsh
db815a565f
Run release job on release: published event ( #1156 )
2022-12-08 23:05:28 -05:00
Charlie Marsh
3bacdafd1c
Improve some __all__ handling cases ( #1155 )
2022-12-08 23:03:23 -05:00
Charlie Marsh
6403e3630d
Fix flaky unused import test
2022-12-08 22:51:13 -05:00
Charlie Marsh
229eab6f42
Improve some behavior around global handling ( #1154 )
2022-12-08 22:47:19 -05:00
Charlie Marsh
e33582fb0e
Add pyflakes import test suite ( #1151 )
2022-12-08 22:23:37 -05:00
Charlie Marsh
aaeab0ecf1
Implement F811 (RedefinedWhileUnused) ( #1137 )
2022-12-08 21:31:08 -05:00
Charlie Marsh
f9a16d9c44
Fix GitHub link
2022-12-08 20:54:54 -05:00
Charlie Marsh
2aa884eb9b
Re-implement the entire test_undefined_names.py test suite ( #1150 )
2022-12-08 20:53:01 -05:00
Charlie Marsh
84fa64d98c
Move bindings to an arena ( #1147 )
2022-12-08 19:48:00 -05:00
Charlie Marsh
c1b1ac069e
Include else block in break detection ( #1143 )
2022-12-08 11:53:31 -05:00
Charlie Marsh
a710e35ebc
Bump version to 0.0.170
2022-12-08 11:36:24 -05:00
Charlie Marsh
49df43bb78
Use single newlines in .pyi import sorting ( #1142 )
2022-12-08 11:34:41 -05:00
Charlie Marsh
e338d9acbe
Remove 'consider' language from check messages ( #1135 )
2022-12-07 20:10:36 -05:00
Charlie Marsh
5c8655f479
Bump ruff_macros to 0.0.169
2022-12-07 19:10:16 -05:00
Charlie Marsh
60987888a2
Re-increase max iterations to 100
2022-12-07 19:10:03 -05:00
Charlie Marsh
a81581c781
Bump ruff_macros to 0.0.168
2022-12-07 19:08:18 -05:00
Charlie Marsh
3152dd7a8e
Don't prompt users to --fix if they ran with --fix ( #1133 )
2022-12-07 19:07:51 -05:00
Charlie Marsh
528416f07a
Rename I252 to TID252; add redirects for all renamed codes ( #1129 )
2022-12-07 15:12:22 -05:00
Charlie Marsh
4405a6a903
Bump version to 0.0.168
2022-12-07 13:18:40 -05:00
Charlie Marsh
35fa2a3c32
Convert more BTree usages to Fx ( #1112 )
2022-12-07 12:21:12 -05:00
Charlie Marsh
bb67fbb73a
Implement unused argument detection (ARG) ( #1126 )
...
Detect unused arguments
2022-12-07 12:15:41 -05:00
Charlie Marsh
d698c6123e
Bump version to 0.0.167
2022-12-07 10:37:31 -05:00
Charlie Marsh
9579faffa8
Avoid flagging bare exception issues when exception is re-raised ( #1124 )
2022-12-07 10:37:08 -05:00
Phillip Verheyden
9c6e8c7644
Auto-generate the rules table of contents ( #1121 )
2022-12-07 10:03:42 -05:00
Charlie Marsh
7abecd4f0e
Implement B905 ( #1122 )
2022-12-07 10:01:24 -05:00
Phillip Verheyden
b8ff209af8
Encode prefixes in README headings not just in TOC ( #1109 )
2022-12-07 09:24:49 -05:00
Jeong YunWon
c5451cd8ad
Reduce indents ( #1116 )
2022-12-07 09:20:33 -05:00
Jonathan Plasse
92b9ab3010
Add aiter() and anext() to BUILTINS ( #1118 )
2022-12-07 09:20:06 -05:00
Edgar R. M
f2ac8c4ec2
Add flake8-import-conventions to TOC in readme ( #1114 )
2022-12-06 21:27:04 -05:00
Charlie Marsh
80e2f0c92e
Bump version to 0.0.166
2022-12-06 16:06:19 -05:00
Edgar R. M
ea550abd3c
Implement flake8-import-conventions ( #1098 )
2022-12-06 16:01:17 -05:00
Charlie Marsh
5c26777e4c
Avoid flagging ANN errors in @overload implementations ( #1110 )
2022-12-06 12:46:38 -05:00
Laurent Baillet
6eb6b6eede
Update readme in order to match pylint prefixes ( #1105 )
2022-12-06 08:59:45 -05:00
Charlie Marsh
f1d3e3698a
Bump version to 0.0.165
2022-12-06 00:03:30 -05:00
Charlie Marsh
080411bc89
Re-create ruff snapshots
2022-12-06 00:03:14 -05:00
Charlie Marsh
f2ad915224
Bump version to 0.0.164
2022-12-05 23:37:22 -05:00
Charlie Marsh
71543eeabc
Rename rules mod to ruff ( #1104 )
2022-12-05 23:35:36 -05:00
Charlie Marsh
44025f1c92
Improve F841's Flake8 parity for unpacking assignments ( #1103 )
2022-12-05 23:34:40 -05:00
Charlie Marsh
971bf6d232
Run cargo fmt
2022-12-05 23:01:47 -05:00
Charlie Marsh
0acc47386a
Use pyproject.toml parent as project root when explicitly provided ( #1101 )
2022-12-05 23:00:59 -05:00
Reiner Gerecke
982ac6b0ad
Auto-generate options in README from field attributes ( #1015 )
2022-12-05 22:34:40 -05:00
Charlie Marsh
541440f7a8
Re-support F841 detection for single context managers ( #1099 )
2022-12-05 22:09:45 -05:00
Charlie Marsh
66dde46e03
Track nested imports without column number detection ( #1097 )
2022-12-05 21:16:44 -05:00
Charlie Marsh
1339e2a002
Bump version to 0.0.163
2022-12-05 20:45:24 -05:00
Charlie Marsh
38ad10f60d
Treat nested classes and functions as "standard" siblings ( #1095 )
2022-12-05 20:45:12 -05:00
Charlie Marsh
88e78c5cde
Add missing D415 fixture
2022-12-05 20:42:21 -05:00
Charlie Marsh
436aeed20a
Implement autofix for D400 and D415 ( #1094 )
2022-12-05 20:24:56 -05:00
Charlie Marsh
b94169a8bb
Don't autofix D210 by introducing a syntax error ( #1093 )
2022-12-05 19:13:22 -05:00
Charlie Marsh
995994be3e
Bump version to 0.0.162
2022-12-05 19:07:44 -05:00
Charlie Marsh
f001305b2e
Only autofix D205 by deleting blank lines ( #1091 )
2022-12-05 19:01:32 -05:00
Charlie Marsh
e88093541f
Avoid wrapping import-star statements ( #1089 )
2022-12-05 18:39:16 -05:00
Charlie Marsh
da41a495f1
Remove extraneous plugin creation script
2022-12-05 18:31:19 -05:00
Charlie Marsh
55b7ec8f85
Ignore newline enforcement when imports break indentation boundaries ( #1085 )
2022-12-05 18:02:41 -05:00
Charlie Marsh
4b41ae3f53
Bump version to 0.0.161
2022-12-05 17:02:05 -05:00
Charlie Marsh
f944e1e1cf
Add action comments to README.md ( #1082 )
2022-12-05 16:56:28 -05:00
Charlie Marsh
4fbc1082de
Support isort: split directive ( #1081 )
2022-12-05 16:48:10 -05:00
Charlie Marsh
cf2e887e38
Tweak summary message to include total error counts ( #1067 )
2022-12-05 16:12:12 -05:00
Charlie Marsh
ee994e8c07
Import compatibility with isort newline-insertion behavior ( #1078 )
2022-12-05 16:07:07 -05:00
Charlie Marsh
c69c4fd655
Support isort: skip_file directive ( #1075 )
2022-12-05 15:02:01 -05:00
Charlie Marsh
e01e45ca35
Remove extraneous test file
2022-12-05 14:58:54 -05:00
Charlie Marsh
4be74785fe
Support unterminated isort: off directives ( #1074 )
2022-12-05 14:54:47 -05:00
Charlie Marsh
40b7c64f7d
Bump version to 0.0.160
2022-12-05 12:56:38 -05:00
Jonathan Plasse
a76c5d1226
Add allowed-confusable settings ( #1059 )
2022-12-05 12:53:55 -05:00
Charlie Marsh
5aeddeb825
Include pyproject.toml path in error message ( #1068 )
2022-12-05 12:04:50 -05:00
Charlie Marsh
5f8294aea4
Preserve star imports when re-formatting import blocks ( #1066 )
2022-12-05 11:48:38 -05:00
Charlie Marsh
e07d3f6313
Fix clippy
2022-12-05 11:47:42 -05:00
Charlie Marsh
1d1662cb9c
Bump version to 0.0.159
2022-12-05 11:22:02 -05:00
Charlie Marsh
55ce7bd0df
Migrate invalid_literal_comparisons fix to token-based logic ( #1065 )
2022-12-05 11:16:59 -05:00
Charlie Marsh
e695f6eb25
Avoid false-positive on PLR1701 for multi-type isinstance calls ( #1063 )
2022-12-05 10:07:05 -05:00
messense
fb2c457a9b
Upgrade to notify 5.0.0 ( #1048 )
2022-12-05 09:58:42 -05:00
Jeong YunWon
523cf62eda
Style fixes ( #1049 )
2022-12-05 09:57:48 -05:00
Charlie Marsh
7024ad7cc7
Bump version to 0.0.158
2022-12-04 21:22:24 -05:00
Charlie Marsh
871ac511ae
Add an option to force one-member-per-line for aliased import-froms ( #1047 )
2022-12-04 21:22:00 -05:00
Charlie Marsh
0685af8a4f
Update RustPython ( #1045 )
2022-12-04 20:09:28 -05:00
Charlie Marsh
5e9a8fcf53
Bump version to 0.0.157
2022-12-04 14:46:46 -05:00
Charlie Marsh
76439235af
Remove unused imports in __init__.py files by default ( #1042 )
2022-12-04 14:45:54 -05:00
Charlie Marsh
0c9c6a1c1c
Remove extraneous test file
2022-12-04 13:59:55 -05:00
Charlie Marsh
46a99243cd
Fix D205 autofix by detecting summary line ( #1041 )
2022-12-04 13:56:51 -05:00
Charlie Marsh
d06dc4c72d
Bump version to 0.0.156
2022-12-04 10:22:09 -05:00
Jonathan Plasse
8f6b2fb32b
Extend and rename RUF004 to PLR1722 ( #1036 )
2022-12-04 10:20:12 -05:00
Charlie Marsh
1d61db5b62
Allow import builtins under T100 ( #1037 )
2022-12-04 10:13:17 -05:00
Charlie Marsh
e15c0c68cb
Fix PLW0120 snapshot
2022-12-04 10:10:00 -05:00
Harutaka Kawamura
abb2adc4d8
Implement useless-import-alias ( #1025 )
2022-12-04 09:48:56 -05:00
Harutaka Kawamura
e070166409
Implement useless-else-on-loop ( #1031 )
2022-12-04 09:22:04 -05:00
Jonathan Plasse
0ae6890094
Fix Table of Contents ( #1030 )
2022-12-04 09:14:09 -05:00
Harutaka Kawamura
21cace0973
Fix PLR0402 ( #1024 )
2022-12-04 09:13:47 -05:00
Jakub Kuczys
4994b72ba2
Fix README header links in isort config section ( #1033 )
2022-12-04 09:12:25 -05:00
Anders Kaseorg
dbb1a6e44b
Remove sloppy match_name_or_attr helper ( #1027 )
2022-12-04 09:12:03 -05:00
Charlie Marsh
4b0c3e3bc9
Bump version to 0.0.155
2022-12-04 00:12:00 -05:00
Charlie Marsh
ddae3586d5
Add support for combine-as-imports import formatting ( #1022 )
2022-12-04 00:11:48 -05:00
Charlie Marsh
97684b7215
Mark MisplacedComparisonConstant as fixable
2022-12-04 00:11:19 -05:00
Harutaka Kawamura
20e6ff112a
Implement misplaced-comparison-constant ( #1023 )
2022-12-04 00:10:07 -05:00
Charlie Marsh
6cb84d29f0
Rename M001 to RUF100 ( #1021 )
2022-12-03 22:51:05 -05:00
Charlie Marsh
d069054792
Rename RUF101 fixtures
2022-12-03 22:47:16 -05:00
Charlie Marsh
c659cb86d9
Rename RUF101 to RUF004 ( #1020 )
2022-12-03 22:46:13 -05:00
Charlie Marsh
8a3f29497b
Add backwards compatible redirect map for U-to-UP rename ( #1019 )
2022-12-03 22:43:00 -05:00
Harutaka Kawamura
58e7baedd0
Implement consider-using-from-import ( #1018 )
2022-12-03 22:36:43 -05:00
Charlie Marsh
00eff2b09a
Rename pyupgrade rules from UXXX to UPXXX ( #957 )
2022-12-03 22:35:42 -05:00
Charlie Marsh
b6b509811d
Bump version to 0.0.154
2022-12-03 20:14:38 -05:00
Charlie Marsh
87bdda3cfa
Make some flake8-return rules auto-fixable ( #1017 )
2022-12-03 20:13:17 -05:00
Charlie Marsh
291727a27d
Implement flake8-return plugin ( #1016 )
2022-12-03 20:12:11 -05:00
Charlie Marsh
e66b786229
Bump version to 0.0.153
2022-12-03 17:05:39 -05:00
Harutaka Kawamura
e05e1cdf76
Implement consider-merging-isinstance ( #1009 )
2022-12-03 16:51:53 -05:00
Harutaka Kawamura
f92cc7a159
Fix clippy errors on main ( #1010 )
2022-12-03 10:02:36 -05:00
Harutaka Kawamura
ebd2181946
Implement unnecessary-direct-lambda-call ( #1008 )
2022-12-03 09:59:04 -05:00
Harutaka Kawamura
3efa1a03f2
Fix match_like_matches_macro in src/pylint/plugins.rs ( #1007 )
2022-12-03 00:21:32 -05:00
Harutaka Kawamura
115e85b47d
Rename PLE0206 to PLR0206 ( #1006 )
2022-12-03 00:14:46 -05:00
Harutaka Kawamura
31a3314ebd
Implement PLE0206 ( #1005 )
2022-12-03 00:04:43 -05:00
Charlie Marsh
bf33025ea9
Support whole-file noqa exclusions ( #1001 )
2022-12-02 23:56:56 -05:00
Charlie Marsh
1a33ee3fc4
Bump version to 0.0.152
2022-12-02 13:23:00 -05:00
Charlie Marsh
4722885910
Avoid recursing on nested deferred annotations ( #1000 )
...
Parse nested deferred annotations
2022-12-02 13:22:39 -05:00
Jonathan Plasse
117fcb6936
Add no-eval rule from pygrep-hooks ( #994 )
2022-12-02 12:59:06 -05:00
Charlie Marsh
1a24d78f67
Bump version to 0.0.151
2022-12-01 22:31:44 -05:00
Charlie Marsh
4a4082cf0e
Track type definitions and annotations separately ( #992 )
2022-12-01 22:31:20 -05:00
Charlie Marsh
18b9fbd71e
Improve docstring checks with empty trailing lines ( #991 )
2022-12-01 20:15:44 -05:00
Charlie Marsh
d699bb7b86
Bump version to 0.0.150
2022-12-01 16:31:18 -05:00
Charlie Marsh
46f5053c73
Include fixes in JSON API output ( #988 )
2022-12-01 16:30:56 -05:00
Charlie Marsh
af40e64d6c
Remove Patch abstraction from Fix ( #987 )
2022-12-01 16:04:42 -05:00
Charlie Marsh
2e89cd8802
Split test fixtures up by plugin ( #985 )
2022-12-01 13:33:33 -05:00
Charlie Marsh
1085b547b6
Convert Err(anyhow(...)) to bail ( #984 )
2022-12-01 13:33:06 -05:00
Charlie Marsh
9e5df82578
Remove trailing punctuation from error messages ( #983 )
2022-12-01 12:25:37 -05:00
Charlie Marsh
6fe478cb43
Add Conda installation instructions ( #982 )
2022-12-01 12:19:39 -05:00
Charlie Marsh
c06a1f6da9
Force format --text in tests
2022-12-01 10:51:11 -05:00
Edgar R. M
6f48ac6c0b
Add GitHub output format ( #975 )
2022-12-01 10:22:11 -05:00
Edgar R. M
9e1ba916f0
Send logs to stderr ( #977 )
2022-12-01 10:19:32 -05:00
Charlie Marsh
f6b0a606d6
Implement await-outside-async / E1142 ( #972 )
2022-11-30 11:38:03 -05:00
Charlie Marsh
c8e72dfb9e
Narrow keyword in yield-outside-function ( #971 )
2022-11-30 10:03:40 -05:00
Charlie Marsh
6fa0f21227
Bump version to 0.0.149
2022-11-30 00:51:36 -05:00
messense
f5466fe720
Add JUnit xml output format ( #968 )
2022-11-30 00:47:41 -05:00
Charlie Marsh
a0202e8eb2
Add Pylint parity to FAQ ( #969 )
2022-11-29 23:51:27 -05:00
Charlie Marsh
30ff4de9a3
Bump version to 0.0.148
2022-11-29 22:50:30 -05:00
Charlie Marsh
897b0f06ef
Fix clippy
2022-11-29 22:50:20 -05:00
Charlie Marsh
2fe22a223b
Bump version to 0.0.147
2022-11-29 20:17:58 -05:00
Charlie Marsh
e762dec677
Add one more note to README
2022-11-29 20:17:46 -05:00
Charlie Marsh
19baa50003
Remove extraneous key in pyproject.toml
2022-11-29 20:13:28 -05:00
Charlie Marsh
ab0df03a05
Fix pyproject tests to include pyupgrade
2022-11-29 20:11:16 -05:00
Charlie Marsh
808b348c5f
Add W to pycodestyle list in README
2022-11-29 20:09:07 -05:00
Charlie Marsh
e55daa89e6
Uses dashes for README options ( #966 )
2022-11-29 20:08:03 -05:00
Charlie Marsh
b8e7d86696
Add pyupgrade's --keep-runtime-typing option ( #965 )
2022-11-29 20:05:32 -05:00
Charlie Marsh
ced7868559
Add format setting to pyproject.toml ( #964 )
2022-11-29 19:22:23 -05:00
Ramazan Elsunakev
7c344e8e4c
feat: use more precise ranges for imports ( #958 )
2022-11-29 19:01:39 -05:00
Hayden
ca38c7ac48
Grouped format implementation ( #954 )
2022-11-29 18:45:16 -05:00
Guillaume Andreu Sabater
602291c0c2
README: fixed conf section typo ( #959 )
2022-11-29 09:27:02 -05:00
Charlie Marsh
d4cf376e9b
Fix failing pyproject test
2022-11-29 00:00:43 -05:00
Charlie Marsh
0e6a38e6d8
Bump version to 0.0.146
2022-11-28 22:27:41 -05:00
Charlie Marsh
058fd8748d
Re-generate check code prefix and rules table
2022-11-28 22:26:32 -05:00
Charlie Marsh
e8247e3ed9
Run cargo fmt
2022-11-28 22:25:09 -05:00
Charlie Marsh
ea73c717be
Remove pre-commit note in README.md ( #956 )
2022-11-28 22:18:59 -05:00
Charlie Marsh
427e0c3158
Allow preservation of external check codes ( #955 )
2022-11-28 22:16:17 -05:00
Charlie Marsh
dca994d05f
Bump version to 0.0.145
2022-11-28 20:57:58 -05:00
Charlie Marsh
9944246f98
Rewrite type annotations on Python 3.7 when __future__ enabled ( #953 )
2022-11-28 20:57:38 -05:00
Charlie Marsh
82b0b7941a
Implement eradicate ( #947 )
2022-11-28 20:54:33 -05:00
Charlie Marsh
72453695d6
Bump version to 0.0.144
2022-11-28 20:11:08 -05:00
Charlie Marsh
1617d715f2
Allow long lines that consist of only a URL ( #952 )
2022-11-28 20:10:21 -05:00
pwoolvett
c4a7344791
fix(flake8_boolean_trap): add allowlist for dict methods ( #943 )
2022-11-28 16:17:01 -05:00
Charlie Marsh
ea9acda732
Bump version to 0.0.143
2022-11-28 15:42:25 -05:00
Anders Kaseorg
6c8021e970
Fix clippy::manual_let_else (pedantic) ( #939 )
2022-11-28 09:52:59 -05:00
Charlie Marsh
61b6ad46ea
Allow @override methods to be undocumented ( #941 )
2022-11-28 09:52:12 -05:00
Anders Kaseorg
041d8108e6
Don’t require files with --explain or --generate-shell-completion ( #937 )
2022-11-28 00:40:20 -05:00
Charlie Marsh
e2c4a098de
Bump version to 0.0.142
2022-11-28 00:19:27 -05:00
Charlie Marsh
e865f58426
Add all plugin options to README reference ( #936 )
2022-11-28 00:19:14 -05:00
messense
23b4e16b1d
Add shell completions support ( #935 )
2022-11-27 23:59:36 -05:00
Charlie Marsh
ae2ac905dc
Document all top-level configuration options ( #934 )
2022-11-27 23:50:24 -05:00
Charlie Marsh
55619b321a
Run cargo fmt
2022-11-27 22:58:42 -05:00
Harutaka Kawamura
6f31b002f8
Do not enforce line length limit for comments ending with a URL ( #920 )
2022-11-27 22:36:17 -05:00
Charlie Marsh
1a79965aa0
Allow varargs and kwargs to be prefixed with stars ( #933 )
2022-11-27 22:08:27 -05:00
Charlie Marsh
16da183f8e
Add some user testimonials ( #932 )
2022-11-27 21:55:01 -05:00
Charlie Marsh
3f689917cb
Use alternative TOML format for per-file-ignores in README ( #931 )
2022-11-27 21:38:43 -05:00
Charlie Marsh
a4a215e8a3
Add Homebrew installation to README ( #930 )
2022-11-27 21:37:34 -05:00
Charlie Marsh
aa1c884910
Tweak Flake8 parity in README
2022-11-27 21:34:47 -05:00
Oliver Margetts
7fb55c6d99
F50x implementation ( #919 )
2022-11-27 21:30:55 -05:00
Charlie Marsh
04ea523ad8
Track aliased import-from members ( #929 )
2022-11-27 17:27:27 -05:00
Charlie Marsh
9897f81cf3
Bump version to 0.0.141
2022-11-26 16:33:08 -05:00
Charlie Marsh
1a2559b001
Avoid flagging redundant open modes when open is rebound ( #918 )
2022-11-26 16:24:41 -05:00
Denis Gavrilyuk
721a1e9443
Add flake8-debugger ( #909 )
2022-11-26 16:21:03 -05:00
Charlie Marsh
f38bba18ee
Fix clippy warnings
2022-11-26 15:56:33 -05:00
Charlie Marsh
14cf36f922
Bump version to 0.0.140
2022-11-26 15:05:46 -05:00
Charlie Marsh
d28e026525
Preserve existing noqa codes in --add-noqa ( #913 )
2022-11-26 14:42:19 -05:00
Jonathan Plasse
d19a8aa54d
Auto-generate CheckCodePrefix::fixables() ( #916 )
2022-11-26 14:10:30 -05:00
Charlie Marsh
f299940452
Respect noqa comments in U009 ( #917 )
2022-11-26 14:03:18 -05:00
Charlie Marsh
e1ab7163ac
Respect f-string locations in B023 check ( #914 )
2022-11-26 10:31:23 -05:00
Jonathan Plasse
9edc479c6c
Fix F821 false positive ( #911 )
2022-11-26 10:12:07 -05:00
Charlie Marsh
560558b814
Bump version to 0.0.139
2022-11-25 18:38:26 -05:00
Andri Bergsson
bef601b994
Add keyword argument handling for redundant open modes. ( #906 )
2022-11-25 18:38:05 -05:00
Charlie Marsh
7445d00b88
Implement B023 (function uses loop variable) ( #907 )
2022-11-25 18:29:54 -05:00
Charlie Marsh
7c78d4e103
Use docstring comment for CheckCode
2022-11-25 13:15:43 -05:00
Oliver Margetts
8b14f1b8cc
Implement F522-F525 ( #899 )
2022-11-25 13:14:31 -05:00
Xuan (Sean) Hu
5a6b51e623
Minor changes in README. ( #903 )
2022-11-25 09:49:16 -05:00
Charlie Marsh
0b60242fb7
Bump version to 0.0.138
2022-11-25 00:05:41 -05:00
Charlie Marsh
65b77feeb8
Bump LibCST version
2022-11-25 00:05:03 -05:00
Charlie Marsh
04b9c0a31d
Fix cargo clippy
2022-11-24 23:40:43 -05:00
Harutaka Kawamura
49dc8231be
Fix typo ( #902 )
2022-11-24 23:38:45 -05:00
Charlie Marsh
92ca114882
Move some main.rs subcommands to a new module ( #901 )
2022-11-24 22:43:43 -05:00
Charlie Marsh
553bc7443a
Remove UserConfiguration struct ( #900 )
2022-11-24 22:39:07 -05:00
CelebrateVC
a3af6c1ea5
Implement GlobSet optimization for file path exclusions ( #883 )
2022-11-24 22:31:55 -05:00
Charlie Marsh
b50016fe89
Regenerate README.md
2022-11-24 18:10:07 -05:00
Oliver Margetts
2cf2805848
Implement F521 ( #898 )
2022-11-24 18:09:36 -05:00
Harutaka Kawamura
33fbef7700
Implement B904 ( #892 )
2022-11-24 09:49:57 -05:00
Charlie Marsh
68668a584b
Bump version to 0.0.137
2022-11-23 20:28:45 -05:00
Charlie Marsh
6cd8655d29
Treat withitem variables as bindings ( #897 )
2022-11-23 20:28:37 -05:00
Charlie Marsh
72a9bd3cfb
Revert "Upload wheels back to GitHub Releases ( #884 )"
...
This reverts commit bd08fc359d .
2022-11-23 20:27:33 -05:00
Charlie Marsh
58aac21a36
Bump version to 0.0.136
2022-11-23 17:41:17 -05:00
Charlie Marsh
77e0be3464
Visit iter prior to target in comprehensions ( #895 )
2022-11-23 10:13:21 -05:00
Charlie Marsh
bd08fc359d
Upload wheels back to GitHub Releases ( #884 )
2022-11-23 00:06:36 -05:00
Harutaka Kawamura
19ad6ab4f5
Add --explain ( #887 )
2022-11-23 00:06:25 -05:00
Charlie Marsh
4b2df99e78
Set rust-version in Cargo.toml ( #886 )
2022-11-22 23:33:39 -05:00
Charlie Marsh
66975876b2
Bump version to 0.0.135
2022-11-22 19:21:53 -05:00
Charlie Marsh
7316b120ba
Log errors in add_noqa and autoformat calls ( #881 )
2022-11-22 19:21:36 -05:00
Charlie Marsh
fec887e481
Apply a limit to the number of fix iterations ( #882 )
2022-11-22 19:21:31 -05:00
Charlie Marsh
bdd32c0850
Enforce most pedantic lints on CI ( #878 )
2022-11-22 18:55:57 -05:00
Charlie Marsh
10dcd5fd0a
Remove unused imports
2022-11-22 18:45:24 -05:00
Charlie Marsh
b922e6ecc8
Fix clippy::unnecessary_wraps (pedantic) ( #880 )
...
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps
2022-11-22 18:25:30 -05:00
Charlie Marsh
f59799e0c4
Remove lingering empty lines
2022-11-22 17:54:24 -05:00
Charlie Marsh
814ddeb7ea
Remove always-inline ( #879 )
2022-11-22 17:13:25 -05:00
Charlie Marsh
9315b9f459
Remove Mode from various internal checkers ( #877 )
2022-11-22 16:57:47 -05:00
Charlie Marsh
113b5a10bf
Return Vec<Check> from check_tokens ( #876 )
2022-11-22 16:43:32 -05:00
Charlie Marsh
fe77fb70a1
Apply autofixes iteratively until code is stabilized ( #875 )
2022-11-22 16:37:52 -05:00
Charlie Marsh
c3f6170503
Update README with list of projects ( #874 )
2022-11-22 14:28:02 -05:00
Anders Kaseorg
a46160f0e2
Fix clippy::unreadable_literal (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
9a66cf2ffb
Fix clippy::uninlined_format_args (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
3205473612
Ignore clippy::struct_excessive_bools (pedantic)
...
“consider using a state machine or refactoring bools into two-variant
enums”
https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
0bb8b14ae1
Fix clippy::single_match_else (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
9cf4621071
Fix clippy::redundant_else (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
bbc9ed1b21
Fix clippy::redundant_closure_for_method_calls (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
517ca2604a
Fix clippy::needless_pass_by_value (pedantic)
...
“this argument is passed by value, but not consumed in the function
body”
https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
348ff509c0
Fix clippy::mut_mut (pedantic)
...
“this expression mutably borrows a mutable reference. Consider
reborrowing”
https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
fb545551f8
Fix clippy::match_bool (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#match_bool
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
3b33a431d6
Fix clippy::map_unwrap_or (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
bc95690725
Fix clippy::manual_string_new (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#manual_string_new
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
9dc788d089
Fix clippy::let_underscore_drop (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_drop
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
15f63494a7
Fix clippy::items_after_statements (pedantic)
...
“adding items after statements is confusing, since items exist from
the start of the scope”
https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
68668c20e8
Fix clippy::if_not_else (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
9462335371
Fix clippy::from_iter_instead_of_collect (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
3dd6522b4f
Fix clippy::explicit_iter_loop (pedantic)
...
“it is more concise to loop over references to containers instead of
using explicit iteration methods”
https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
6b935121a7
Fix clippy::explicit_deref_methods (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#explicit_deref_methods
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
8d9d9b3204
Fix clippy::documentation_markdown (pedantic)
...
https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
0a506eff34
Fix clippy::cloned_instead_of_copied (pedantic)
...
“used `cloned` where `copied` could be used instead”
https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
7c7489c1dd
Ignore clippy::cast_possible_truncation (pedantic)
...
“casting `usize` to `u8` may truncate the value”
https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
ae90eccb7f
Fix clippy::cast_lossless (pedantic)
...
“casting `bool` to `u8` is more cleanly stated with `u8::from(_)`”
https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
Signed-off-by: Anders Kaseorg <andersk@mit.edu >
2022-11-21 23:22:28 -05:00
Anders Kaseorg
7a61edbe46
Fix clippy::default-trait-access (pedantic) ( #867 )
2022-11-21 21:00:38 -05:00
Charlie Marsh
59615486d8
Bump version to 0.0.134
2022-11-21 16:15:23 -05:00
Andri Bergsson
ce116a80ad
Automatically remove redundant open modes #640 ( #843 )
2022-11-21 16:06:41 -05:00
Anders Kaseorg
731fba9006
Ignore clippy::unreadable-literal (pedantic) for CONFUSABLES ( #864 )
2022-11-21 16:00:05 -05:00
Anders Kaseorg
9bcf194fdc
Ignore clippy::match-same-arms (pedantic) in a few places ( #863 )
2022-11-21 15:59:58 -05:00
Anders Kaseorg
58949b564e
Fix clippy::trivially-copy-pass-by-ref (pedantic) ( #862 )
2022-11-21 15:59:51 -05:00
Anders Kaseorg
6b9e57fb78
Fix clippy::sort-unstable (pedantic) ( #861 )
2022-11-21 15:59:41 -05:00
Anders Kaseorg
cb119401a7
Fix clippy::inefficient-to-string (pedantic) ( #860 )
2022-11-21 15:59:35 -05:00
Charlie Marsh
0b9188011b
Bump version to 0.0.133
2022-11-21 13:39:37 -05:00
Anders Kaseorg
b657d912d9
Propagate errors from glob::Pattern::new ( #858 )
2022-11-21 13:39:19 -05:00
Charlie Marsh
1559671093
Target isort code in README.md
2022-11-21 13:38:01 -05:00
Charlie Marsh
70a53bf12b
Add unit tests for complexity check ( #859 )
2022-11-21 13:31:17 -05:00
Charlie Marsh
cd1e07f37c
Avoid incrementing McCabe complexity for class methods ( #857 )
2022-11-21 13:30:36 -05:00
Charlie Marsh
7bd6db62d9
Sort relative imports by parent level descending ( #856 )
2022-11-21 13:30:24 -05:00
Charlie Marsh
f8b49f308d
Upgrade RustPython ( #855 )
2022-11-21 13:20:03 -05:00
Charlie Marsh
b1f9c7b6bd
Update default complexity in README.md
2022-11-21 13:19:55 -05:00
Keming
0867d2ded9
Make it visible under light theme ( #854 )
2022-11-21 10:18:21 -05:00
messense
3f597a3b30
Upgrade maturin to 0.14 ( #846 )
2022-11-21 10:00:14 -05:00
Charlie Marsh
6733aad216
Avoid attempting to fix PEP 604 violations with deferred annotations ( #845 )
2022-11-20 21:41:54 -05:00
Harutaka Kawamura
89980ad651
Implement autofix for B013 ( #824 )
2022-11-20 18:49:07 -05:00
Charlie Marsh
38f896502a
Bump version to 0.0.132
2022-11-20 18:10:13 -05:00
Jonathan Plasse
7cab541343
Add convert exit() to sys.exit() rule ( #816 )
2022-11-20 18:09:40 -05:00
Charlie Marsh
1a3d2ead41
Support PEP 562 ( #841 )
2022-11-20 17:55:57 -05:00
Jonathan Plasse
f96c64b40d
Fix N804 class method with positional only args ( #836 )
2022-11-20 15:48:09 -05:00
Charlie Marsh
0791869451
Add RUF to list of fixable defaults ( #838 )
2022-11-20 15:40:14 -05:00
Charlie Marsh
965918744b
Replace FNV with rustc-hash ( #837 )
2022-11-20 15:38:31 -05:00
Charlie Marsh
6b4aedb366
Bump version to 0.0.131
2022-11-20 13:40:58 -05:00
Charlie Marsh
8123e3e94e
Remove extraneous Python file
2022-11-20 13:39:55 -05:00
Charlie Marsh
9f9a545c51
Improve cache performance by removing cacache dependency ( #833 )
2022-11-20 13:36:33 -05:00
Charlie Marsh
5bf8219db3
Make main.rs robust to cache initialization failures ( #831 )
2022-11-20 11:05:17 -05:00
Charlie Marsh
529513bf02
Add CACHEDIR.TAG to .ruff_cache ( #830 )
2022-11-20 10:53:31 -05:00
Charlie Marsh
124782771f
Bump version to 0.0.130
2022-11-20 10:37:19 -05:00
Charlie Marsh
98cab5cdba
Add class names to NamedTuple and TypedDict rules ( #829 )
2022-11-20 10:29:47 -05:00
Martin Lehoux
40f38c94a5
Implement U014: Convert NamedTuple function to class ( #819 )
2022-11-20 10:26:15 -05:00
Harutaka Kawamura
7839204bf7
Implement autofix for B010 ( #823 )
2022-11-20 10:14:29 -05:00
Jonathan Plasse
e63ea704f0
Adjust U011 start location ( #828 )
2022-11-20 10:13:29 -05:00
Charlie Marsh
4be09b45ea
Bump version to 0.0.129
2022-11-19 19:52:40 -05:00
Harutaka Kawamura
13e8ed0a0a
Implement autofix for E731 ( #814 )
2022-11-19 19:51:41 -05:00
Anders Kaseorg
4161d4ae32
Exempt parameters with immutable annotations from B006 ( #821 )
2022-11-19 19:46:08 -05:00
Charlie Marsh
99f7854d8c
Mark nonlocal variables as used in parent scopes ( #822 )
2022-11-19 19:21:02 -05:00
Harutaka Kawamura
a580d1a858
Adjust UnusedNOQA start location ( #817 )
2022-11-19 09:30:02 -05:00
Martin Lehoux
86806a9e39
U013: Also convert typing.TypedDict ( #810 )
2022-11-19 09:29:05 -05:00
Charlie Marsh
89afc9db74
Bump version to 0.0.128
2022-11-18 18:50:03 -05:00
Charlie Marsh
0f34cdb7a3
Enable customization of autofixable error codes ( #811 )
2022-11-18 18:49:13 -05:00
Charlie Marsh
437b6f23b9
Remove warn_on checks ( #812 )
2022-11-18 18:48:24 -05:00
Charlie Marsh
0fe2b15676
Change NotInTest to NotIsTest
2022-11-18 18:23:40 -05:00
Harutaka Kawamura
e81efa5a3d
Implement a --show-source setting ( #698 )
2022-11-18 14:02:29 -05:00
Charlie Marsh
49559da54e
Bump version to 0.0.127
2022-11-18 13:31:22 -05:00
Jonathan Plasse
b74fd1fe13
Change error code of flake8-blind-except ( #808 )
2022-11-18 13:30:36 -05:00
Charlie Marsh
9c4d24a452
Add flake8-boolean-trap to README
2022-11-18 12:36:13 -05:00
pwoolvett
7a4449eacb
Add flake8-boolean-trap ( #790 )
2022-11-18 12:30:07 -05:00
Charlie Marsh
ee31fa6109
Reduce newlines in code gen ( #807 )
2022-11-18 12:27:56 -05:00
Harutaka Kawamura
6ffe767252
Implement autofix for E713 and E714 ( #804 )
2022-11-18 12:16:11 -05:00
Jonathan Plasse
2f894e3951
Add flake8-blind-except ( #805 )
2022-11-18 12:15:10 -05:00
Charlie Marsh
589d923c99
Misc. follow-ups to #716 ( #806 )
2022-11-18 12:14:41 -05:00
Martin Lehoux
c5722d8a4d
Implement U013: Unnecessary TypedDict syntactic form ( #716 )
2022-11-18 12:10:47 -05:00
Jonathan Plasse
c2d6307e9b
Add missing plugins in some sections of README.md ( #802 )
2022-11-18 09:28:33 -05:00
Edgar R. M
f44fada446
Implement C901 (mccabe) ( #765 )
2022-11-17 17:40:50 -05:00
Charlie Marsh
6a6f4651aa
Bump version to 0.0.126
2022-11-17 17:19:19 -05:00
Charlie Marsh
66ae4db6cd
Ignore globals when checking local variable names ( #800 )
2022-11-17 17:19:01 -05:00
Charlie Marsh
801c76037f
Except BaseException from N818 checks ( #798 )
2022-11-17 15:04:42 -05:00
Charlie Marsh
ab825eb28d
Fix D202 to remove line after docstring ( #797 )
2022-11-17 15:01:58 -05:00
Charlie Marsh
826ef7da67
Trigger N818 when parent ends in Error or Exception ( #796 )
2022-11-17 14:51:40 -05:00
Charlie Marsh
72f5393d3a
Add flake8-tidy-imports to cache key
2022-11-17 14:46:45 -05:00
Charlie Marsh
6602f7f489
Trim dedented sections for arg detection ( #793 )
2022-11-17 12:55:55 -05:00
Charlie Marsh
aafddae644
Bump version to 0.0.125
2022-11-17 12:07:05 -05:00
Charlie Marsh
749df87de0
Tweak presentation of null-ls and efm docs ( #791 )
2022-11-17 12:04:11 -05:00
Eddie Bergman
d67db33f22
docs(integrations): neovim null-ls integration ( #782 )
2022-11-17 11:55:08 -05:00
Charlie Marsh
f0a54716e5
Implement flake8-tidy-imports ( #789 )
2022-11-17 11:44:06 -05:00
Harutaka Kawamura
c59e1ff0b5
Implement auto-fix for E711 and E712 ( #784 )
2022-11-17 11:43:44 -05:00
Jonathan Plasse
ecf858cf16
Add the tools identifier in the TOC ( #779 )
2022-11-17 11:34:32 -05:00
Jonathan Plasse
8063aee006
Remove unnecessary abspath rule (U002) ( #781 )
2022-11-17 11:29:42 -05:00
Anders Kaseorg
f1fee5d240
Propagate exit code through Python __main__ wrapper ( #776 )
2022-11-16 16:16:58 -05:00
Anders Kaseorg
d3155560df
Fix find_and_parse_pyproject_toml test for #772 ( #774 )
2022-11-16 13:47:25 -05:00
Charlie Marsh
90bfc4ec4d
Bump version to 0.0.124
2022-11-16 12:25:24 -05:00
Charlie Marsh
b04a6a3f7c
Support arbitrary expression paths for class and static decorators ( #772 )
2022-11-16 12:24:46 -05:00
Charlie Marsh
8ec14e7ee2
Bump version to 0.0.123
2022-11-16 12:06:01 -05:00
Charlie Marsh
17c5cd7c42
Fix off-by-one in noqa map detection ( #771 )
...
Fix off-by-one in noqa
2022-11-16 12:00:10 -05:00
Charlie Marsh
7d8360a1de
Change all &Option<> to Option<&> ( #768 )
2022-11-16 09:40:01 -05:00
Harutaka Kawamura
910ee523dd
Fix E731 ( #766 )
2022-11-16 09:17:14 -05:00
Charlie Marsh
72e35a535e
Run cargo fmt
2022-11-16 09:15:22 -05:00
Charlie Marsh
b4e1563517
Avoid allocations for binding values ( #764 )
2022-11-16 08:55:35 -05:00
Charlie Marsh
5717cc97d7
Add references to Flake8 licenses
2022-11-15 23:07:41 -05:00
Charlie Marsh
2c89a19f76
Bump Ruff version to 0.0.122
2022-11-15 22:03:46 -05:00
Charlie Marsh
82fea36bb3
Preserve comments when sorting imports ( #749 )
2022-11-15 22:02:52 -05:00
Charlie Marsh
63d63e8c12
Increase retry counts in GitHub Actions workflows ( #763 )
2022-11-15 17:21:16 -05:00
Charlie Marsh
9d136de55a
Bump version to 0.0.121
2022-11-15 16:18:39 -05:00
Harutaka Kawamura
1821c07367
Implement B020 ( #753 )
2022-11-15 16:17:03 -05:00
Charlie Marsh
1fe90ef7f4
Only notify once for each app update ( #762 )
2022-11-15 16:14:10 -05:00
Charlie Marsh
b5cb9485f6
Move updater to its own module
2022-11-15 15:51:24 -05:00
Charlie Marsh
4d798512b1
Only print version checks on tty ( #761 )
2022-11-15 15:36:06 -05:00
Charlie Marsh
5f9815b103
Disable auto-updates in JSON mode ( #760 )
2022-11-15 15:29:10 -05:00
Charlie Marsh
0d3fac1bf9
Add --line-length command line argument ( #759 )
2022-11-15 12:23:38 -05:00
Charlie Marsh
ff0e5f5cb4
Preserve scopes when checking deferred strings ( #758 )
2022-11-15 12:19:22 -05:00
Charlie Marsh
374d57d822
Limit PEP 604 checks to Python 3.10+ ( #757 )
2022-11-15 11:52:12 -05:00
Edgar R. M
85b2a9920f
docs: Add flake8-bandit to ToC ( #750 )
2022-11-15 00:11:39 -05:00
Charlie Marsh
3c22913470
Bump version to 0.0.120
2022-11-14 22:53:36 -05:00
Charlie Marsh
ea03a59b72
De-alias Literal checks ( #748 )
2022-11-14 22:53:23 -05:00
Charlie Marsh
058a5276b0
Bump version to 0.0.119
2022-11-14 21:45:41 -05:00
Charlie Marsh
62d4096be3
Move bindings to FNV map ( #747 )
2022-11-14 21:42:57 -05:00
Charlie Marsh
8961da7b89
Add support for import alias tracking ( #746 )
2022-11-14 21:29:30 -05:00
Brett Cannon
58bcffbe2d
Add isort to the README's ToC ( #745 )
2022-11-14 18:51:39 -05:00
Charlie Marsh
f67727b13c
Improve performance of import matching code ( #744 )
2022-11-14 17:14:22 -05:00
Charlie Marsh
fea029ae35
Bump version to 0.0.118
2022-11-14 13:21:27 -05:00
Harutaka Kawamura
3e3c3c7421
Ignore namedtuple assignment in N806, N815, and N816 ( #735 )
2022-11-14 13:21:04 -05:00
Harutaka Kawamura
9047bf680d
Implement B024 and B027 ( #738 )
2022-11-14 13:12:23 -05:00
Charlie Marsh
d170388b7b
Allow second line as 'first line' for punctuation ( #741 )
2022-11-14 13:07:27 -05:00
Charlie Marsh
502d3316f9
Add flake8-bugbear settings to hash ( #739 )
2022-11-14 12:29:47 -05:00
Harutaka Kawamura
a8159f9893
Implement B022 ( #734 )
2022-11-14 09:24:05 -05:00
Charlie Marsh
71f727c380
Use FNV hasher in more places ( #732 )
2022-11-13 23:44:16 -05:00
Charlie Marsh
ce3c45a361
Make combine-as-imports the default import sorting behavior ( #731 )
2022-11-13 23:07:13 -05:00
Charlie Marsh
29ae6c159d
Add FastAPI to README ( #730 )
2022-11-13 22:27:35 -05:00
Charlie Marsh
1ae07b4c70
Allow explicit re-export of straight imports ( #729 )
2022-11-13 22:26:48 -05:00
Charlie Marsh
08ca8788a7
Bump version to 0.0.117
2022-11-13 16:10:29 -05:00
Charlie Marsh
8a97a76038
Make # noqa detection case-insensitive ( #728 )
2022-11-13 16:09:44 -05:00
Brett Cannon
d2d84cf5bf
Fix Markdown in README ( #727 )
2022-11-13 15:19:25 -05:00
Anders Kaseorg
450970e0e6
Restore clippy on all crates in the workspace ( #725 )
2022-11-13 15:18:57 -05:00
Charlie Marsh
34ecc69914
Don't mark re-exported symbols as unused ( #724 )
2022-11-13 14:31:43 -05:00
Charlie Marsh
a310aed128
Bump version to 0.0.116
2022-11-13 13:46:05 -05:00
Harutaka Kawamura
43cc8bc84e
Lint test code ( #721 )
2022-11-13 11:55:57 -05:00
Harutaka Kawamura
84bf36194b
Implement B012 ( #718 )
2022-11-13 11:55:33 -05:00
Harutaka Kawamura
e4d168bb4f
Implement B021 ( #719 )
2022-11-13 11:40:24 -05:00
Charlie Marsh
439642addf
Regenerate README
2022-11-13 10:55:14 -05:00
Charlie Marsh
f5b1f957e3
Improve some import tracking code ( #715 )
2022-11-13 00:10:13 -05:00
Charlie Marsh
8f99705795
Make some error messages more grammatically consistent
2022-11-12 16:57:23 -05:00
Charlie Marsh
9ec7e6bcd6
Add function name to B008 message
2022-11-12 16:53:13 -05:00
Charlie Marsh
695b06ba60
Bump version to 0.0.115
2022-11-12 16:46:26 -05:00
Charlie Marsh
3a2e6926d4
Include flake8-bugbear settings in flake8-to-ruff ( #712 )
2022-11-12 16:46:12 -05:00
Charlie Marsh
d16c3a1186
Use an FNVHashSet for settings.enabled ( #711 )
2022-11-12 16:36:56 -05:00
Charlie Marsh
53a2187f02
Run cargo fmt
2022-11-12 16:33:12 -05:00
Charlie Marsh
00b5d1059c
Validate that mutable and immutable defaults are imported ( #710 )
2022-11-12 16:32:21 -05:00
Charlie Marsh
b7acf76aaf
Track all import-from members ( #709 )
2022-11-12 16:10:43 -05:00
Charlie Marsh
8cfc0e5cf5
Use FnvHasher for unordered maps and sets ( #708 )
2022-11-12 16:09:34 -05:00
Edgar R. M
aa7681f9ad
Add extend-immutable-calls setting for B008 ( #706 )
2022-11-12 15:48:34 -05:00
Charlie Marsh
2493d48725
Add flake8-bandit to flake8-to-ruff ( #701 )
2022-11-12 12:08:15 -05:00
Edgar R. M
1b422a7f12
Add flake8-bandit ( #697 )
2022-11-12 12:04:49 -05:00
Charlie Marsh
da051624e4
Add backticks around functools.lru_cache
2022-11-12 11:56:23 -05:00
Charlie Marsh
da9ae6a42a
Bump version to 0.0.114
2022-11-12 11:55:18 -05:00
Martin Lehoux
afa59d78bb
feat: no unnecessary encode utf8 ( #686 )
2022-11-12 11:54:36 -05:00
Charlie Marsh
bbc38fea73
Avoid generating empty statement bodies ( #700 )
2022-11-12 11:39:09 -05:00
Chammika Mannakkara
6bcc11a90f
add fixes for __future__ import removal ( #682 )
2022-11-12 11:28:05 -05:00
Harutaka Kawamura
6f36e5dd25
Implement B019 ( #695 )
2022-11-12 11:14:03 -05:00
Anders Kaseorg
1d13752eb1
Remove static isort classifications for __main__, disutils ( #694 )
2022-11-12 09:13:38 -05:00
Anders Kaseorg
394af0dcff
Disable default features of chrono ( #696 )
2022-11-12 09:02:02 -05:00
Charlie Marsh
51cee471a0
Add test case for import-from wrapping
2022-11-11 23:46:19 -05:00
Charlie Marsh
8df3a5437a
Take indentation into account for import-from wrapping ( #693 )
2022-11-11 23:45:04 -05:00
Charlie Marsh
a21fe716f2
Bump version to 0.0.113
2022-11-11 22:42:02 -05:00
Charlie Marsh
558883299a
Default to isort's import sort logic ( #691 )
2022-11-11 22:41:39 -05:00
Charlie Marsh
048a13c795
Add a separate local folder category for imports ( #690 )
2022-11-11 22:12:48 -05:00
Anders Kaseorg
5a8b7c1d20
Implement flake8-2020 (sys.version, sys.version_info misuse) ( #688 )
2022-11-11 20:39:37 -05:00
Charlie Marsh
f8932ec12b
Add some TODOs around import tracking
2022-11-11 19:07:40 -05:00
Charlie Marsh
2e7878ff48
Bump version to 0.0.112
2022-11-11 17:13:04 -05:00
Anders Kaseorg
5113ded22a
Add ruff.__main__ wrapper to allow invocation as ‘python -m ruff’ ( #687 )
2022-11-11 15:53:42 -05:00
Anders Kaseorg
bf7bf7aa17
Only scan checks once in check_lines ( #679 )
2022-11-11 13:34:23 -05:00
Charlie Marsh
560c00ff9d
Bump version to 0.0.111
2022-11-11 12:38:23 -05:00
Charlie Marsh
befe64a10e
Support isort: skip, isort: on, and isort: off ( #678 )
2022-11-11 12:38:01 -05:00
Charlie Marsh
4eccfdeb69
Fix lambda handling for B010 ( #685 )
2022-11-11 11:18:23 -05:00
Charlie Marsh
4123ba9851
Add backticks around setattr
2022-11-11 11:08:22 -05:00
Harutaka Kawamura
e727c24f79
Implement autofix for B009 ( #684 )
2022-11-11 11:06:47 -05:00
Harutaka Kawamura
bd3b40688f
Implement B010 ( #683 )
2022-11-11 10:26:37 -05:00
Charlie Marsh
b5549382a7
Clarify a few settings for isort behavior ( #676 )
2022-11-10 23:19:51 -05:00
Charlie Marsh
8cf745045f
Bump version to 0.0.110
2022-11-10 19:22:45 -05:00
Charlie Marsh
f6992cc98c
Add a test utility for running lint checks ( #672 )
2022-11-10 19:22:00 -05:00
Charlie Marsh
3cc74c0564
Implement import sorting ( #633 )
2022-11-10 19:05:56 -05:00
Charlie Marsh
887b9aa840
Rename some fixture files ( #671 )
2022-11-10 17:28:10 -05:00
Charlie Marsh
faf8556a5c
Limit Ropey to newlines and carriage returns ( #670 )
2022-11-10 17:25:30 -05:00
Harutaka Kawamura
1888f6d41b
Implement B009 ( #669 )
2022-11-10 13:52:20 -05:00
Charlie Marsh
9d8cd2d2fe
Bump version to 0.0.109
2022-11-10 10:54:27 -05:00
Harutaka Kawamura
05c19f0091
Implement B026 ( #668 )
2022-11-10 10:47:42 -05:00
Chammika Mannakkara
8213b64ad5
Fix unnecessary params in lru_cache ( #667 )
2022-11-10 10:45:12 -05:00
Chammika Mannakkara
ff0f5968fa
Detect unnecessary params in lru_cache ( #664 )
2022-11-09 10:02:48 -05:00
Charlie Marsh
6c17670aa5
Upgrade LibCST and other crates ( #663 )
2022-11-08 17:42:12 -05:00
Charlie Marsh
1347b7ebb6
Add notes to README on editor integrations ( #655 )
2022-11-08 16:12:42 -05:00
Reiner Gerecke
f40609f524
Implement autofix for C413 ( #661 )
2022-11-08 16:12:29 -05:00
Charlie Marsh
f572acab30
Bump version to 0.0.108
2022-11-08 13:20:35 -05:00
Charlie Marsh
1eb5f3ea75
Support allow_star_arg_any in flake8-to-ruff
2022-11-08 09:51:11 -05:00
Edgar R. M
24aa177912
Implement ANN401 ( #657 )
2022-11-08 09:49:44 -05:00
Reiner Gerecke
2ddc768412
Implement fix for C404 ( #656 )
2022-11-08 09:37:17 -05:00
Chammika Mannakkara
0f9508f549
Remove unnecessary __future__ imports ( #634 )
2022-11-07 22:26:57 -05:00
Charlie Marsh
7c3d387abd
Implement confusing unicode character detection for comments ( #653 )
2022-11-07 21:16:34 -05:00
Charlie Marsh
d600650214
Upgrade RustPython ( #652 )
2022-11-07 21:07:49 -05:00
Charlie Marsh
43383bb696
Bump version to 0.0.107
2022-11-07 16:39:03 -05:00
Charlie Marsh
ff83f356af
Fix failing flake8-to-ruff tests
2022-11-07 16:38:46 -05:00
Anders Kaseorg
89622425d4
Run annotations plugin if ANN204, ANN205, ANN206 are selected ( #649 )
2022-11-07 16:37:49 -05:00
Charlie Marsh
1aafe31c00
Avoid U009 violations when disabled ( #650 )
2022-11-07 16:36:39 -05:00
Charlie Marsh
16c5ac1e91
Bump version to 0.0.106
2022-11-07 15:32:54 -05:00
Charlie Marsh
da39cddccb
Include function and argument names in ANN checks ( #648 )
2022-11-07 15:27:03 -05:00
Charlie Marsh
de6435f41d
Add a flake8-to-ruff mention ( #644 )
2022-11-07 10:59:47 -05:00
Charlie Marsh
589ae48f8c
Update --help
2022-11-07 10:41:04 -05:00
Harutaka Kawamura
35cc3094b5
Implement B005 ( #643 )
2022-11-07 10:10:59 -05:00
Charlie Marsh
07c9fc55f6
Add fix option to pyproject.toml ( #639 )
2022-11-07 09:46:21 -05:00
Harutaka Kawamura
7773e9728b
Implement B004 ( #638 )
2022-11-07 09:25:09 -05:00
Charlie Marsh
8fc435bad9
Fix --ignore for ANN101 and ANN102 ( #637 )
2022-11-07 09:03:09 -05:00
Charlie Marsh
dd20b23576
Infer plugins based on per-file-ignores, ignores, etc. ( #632 )
2022-11-06 22:39:06 -05:00
Charlie Marsh
da8ee1df3e
Add TODO in flake8_annotations
2022-11-06 21:24:46 -05:00
Charlie Marsh
7f77ed0f86
Bump version to 0.0.105
2022-11-06 21:17:00 -05:00
Charlie Marsh
1b33cfb9cb
Respect project root in per-file ignores ( #631 )
2022-11-06 21:15:49 -05:00
Charlie Marsh
dbc64f1faa
Remove erroneous Literal entry from subscript list ( #630 )
2022-11-06 21:03:41 -05:00
Charlie Marsh
f4b5f0d259
Remove foo.py
2022-11-06 21:03:23 -05:00
Charlie Marsh
85b882fc54
Remove CheckLocator abstraction ( #627 )
2022-11-06 17:42:10 -05:00
Charlie Marsh
99d9aa61bf
Implement flake8-annotations ( #625 )
2022-11-06 17:25:49 -05:00
Charlie Marsh
050f34dd25
Bump version to 0.0.104
2022-11-06 15:31:10 -05:00
Charlie Marsh
1cd82d588b
Categorize functions in pep8-naming ( #624 )
2022-11-06 15:29:49 -05:00
Charlie Marsh
cea9e34942
Update CONTRIBUTING.md ( #623 )
2022-11-06 14:31:16 -05:00
Reiner Gerecke
1ede377402
Improve discoverability of dev commands ( #621 )
2022-11-06 14:25:59 -05:00
Reiner Gerecke
82eff641fb
Remove utf-8 encoding declaration ( #618 )
2022-11-06 14:23:06 -05:00
Charlie Marsh
eb1bc9f092
Allow underscore names in N803 ( #622 )
2022-11-06 14:19:02 -05:00
Reiner Gerecke
df88504dea
pyflakes F632 Autofix ( #612 )
2022-11-06 06:57:46 -05:00
Anders Kaseorg
b9ec3e9137
Correct source link in CONFUSABLES comment ( #617 )
2022-11-05 20:53:05 -04:00
Anders Kaseorg
b067b665ff
Fix B015 false positive on comparison deep inside expression statement ( #616 )
2022-11-05 20:13:22 -04:00
Charlie Marsh
22cfd03b13
Bump ruff_dev to v0.0.103
2022-11-05 19:53:27 -04:00
Charlie Marsh
3ae408a364
Only track noqa directives for multi-line strings ( #615 )
2022-11-05 19:53:13 -04:00
Anders Kaseorg
95073b1586
Fix “Code” misspelling ( #614 )
2022-11-05 19:28:52 -04:00
Charlie Marsh
3597a94818
Add a README link to each plugin ( #611 )
2022-11-05 16:18:27 -04:00
Charlie Marsh
2727e5f3b7
Remove some usages of Ruff internals in ruff_dev ( #610 )
2022-11-05 16:07:21 -04:00
Charlie Marsh
de53b567f5
Add a list of projects using Ruff ( #608 )
2022-11-05 16:03:10 -04:00
Charlie Marsh
21479a151d
Bump ruff_dev to v0.0.102
2022-11-05 16:00:24 -04:00
Charlie Marsh
d822458d97
Fix reference to src/checks_gen.rs
2022-11-05 15:59:51 -04:00
Charlie Marsh
6741ea9790
Create a separate dev crate for development scripts ( #607 )
2022-11-05 15:59:18 -04:00
Charlie Marsh
2e1799dd80
Automatically update README.md from generate_rules_table.rs ( #606 )
2022-11-05 15:33:47 -04:00
Reiner Gerecke
c48c7669a8
Remove rust version from CONTRIBUTING.md ( #605 )
2022-11-05 15:03:10 -04:00
Charlie Marsh
d5fbcd708d
Automatically write to src/checks_gen.rs ( #604 )
2022-11-05 14:30:18 -04:00
Charlie Marsh
b335a6a5ec
Bump version to 0.0.102
2022-11-05 14:13:02 -04:00
Charlie Marsh
f5cbee452a
Increase flake8-bugbear count to 15/32
2022-11-05 14:12:35 -04:00
Harutaka Kawamura
5d1ea4410a
Ignore ellipsis in B018 ( #598 )
2022-11-05 14:11:44 -04:00
Harutaka Kawamura
f27163d2c7
Remove needless return ( #597 )
2022-11-05 14:11:26 -04:00
Harutaka Kawamura
62c126f70e
Implement B003 ( #596 )
2022-11-05 14:08:02 -04:00
Harutaka Kawamura
8344d5151c
Implement B016 ( #595 )
2022-11-05 14:06:00 -04:00
Harutaka Kawamura
f7780eb720
Implement B008 ( #594 )
2022-11-05 14:05:04 -04:00
Charlie Marsh
c544d84b46
Rely on token locations for noqa map extraction ( #603 )
2022-11-05 10:51:19 -04:00
Charlie Marsh
fbdc075e5c
Change Ruff's error prefix to RUF ( #592 )
2022-11-04 23:13:50 -04:00
Charlie Marsh
d3472104d0
Bump flake8-bugbear count to 12/32
2022-11-04 14:49:14 -04:00
Charlie Marsh
0c8b981216
Bump version to 0.0.101
2022-11-04 14:46:48 -04:00
Charlie Marsh
0e3f08aa68
Split ambiguous unicode detection into string vs. docstring rules ( #590 )
2022-11-04 14:46:20 -04:00
Charlie Marsh
a75b1c85ee
Fix invalid escape handling for CRLF files ( #589 )
2022-11-04 14:26:39 -04:00
Harutaka Kawamura
726e6c68cf
Implement B015 ( #587 )
2022-11-04 13:47:52 -04:00
Charlie Marsh
34c91224d7
Bump version to 0.0.100
2022-11-04 12:10:17 -04:00
Charlie Marsh
50c4bbc52b
Implement ambiguous unicode character detection ( #578 )
2022-11-04 12:08:26 -04:00
Charlie Marsh
f0239de559
Use a shared Rope between AST checker and fixer ( #585 )
2022-11-04 12:05:46 -04:00
Charlie Marsh
2be632f3cc
Use a Rope to power fixer ( #584 )
2022-11-04 12:04:14 -04:00
Harutaka Kawamura
ec3fed5a61
Implement B018 ( #582 )
2022-11-04 10:53:30 -04:00
Charlie Marsh
1da44485d5
Confine subscript annotation checks to ExprContext::Load ( #583 )
2022-11-04 10:51:05 -04:00
Charlie Marsh
e5f30ff5a8
Use a rope to manage string slicing ( #576 )
2022-11-03 23:23:38 -04:00
Charlie Marsh
c92f5c14a3
Bump Rust version to 1.65.0 ( #575 )
2022-11-03 22:49:21 -04:00
Charlie Marsh
2f92399f4e
Add W to list of default flake8-to-ruff codes ( #574 )
2022-11-03 22:13:00 -04:00
Charlie Marsh
83dfb5fe8b
Infer Flake8 plugins from .flake8 config ( #573 )
2022-11-03 22:05:46 -04:00
Charlie Marsh
cc915371ca
Implement autofix for F901 ( #571 )
2022-11-03 11:58:54 -04:00
Charlie Marsh
5576db3d5a
Bump version to 0.0.99
2022-11-03 11:47:15 -04:00
Charlie Marsh
f26f38d023
Enable autofix for C406 ( #570 )
2022-11-03 11:27:46 -04:00
Charlie Marsh
578ec4d843
Implement autofix for C416 ( #568 )
2022-11-03 11:05:08 -04:00
Charlie Marsh
2f3bebe5a2
Enable autofix for dict(a=1)-like dictionaries ( #567 )
2022-11-03 10:42:54 -04:00
Charlie Marsh
22991e3e0e
Bump version to 0.0.98
2022-11-03 10:09:33 -04:00
Charlie Marsh
242bdf86b1
Use ::ruff to ensure ruff imports come first
2022-11-03 10:09:28 -04:00
Charlie Marsh
a3f7de2257
Make --quiet more aggressive ( #566 )
2022-11-03 10:08:15 -04:00
Charlie Marsh
9f9cbb5520
Improve pyproject.toml examples in README.md
2022-11-03 09:33:17 -04:00
Charlie Marsh
937c83d57f
Remove crates subdirectory ( #563 )
2022-11-03 09:19:54 -04:00
Charlie Marsh
e00bcd19f5
Bump version to 0.0.97
2022-11-02 22:38:43 -04:00
Charlie Marsh
4550581be2
Relax lowercase condition in N806 ( #562 )
2022-11-02 22:38:29 -04:00
Charlie Marsh
b42d77a4c6
Avoid autofixes for errors in f-strings ( #561 )
2022-11-02 22:31:57 -04:00
Charlie Marsh
e473df1fe9
Bump version to 0.0.96
2022-11-02 22:10:56 -04:00
Charlie Marsh
d448281b33
Add plugin properties to settings cache key ( #559 )
2022-11-02 22:10:01 -04:00
Charlie Marsh
94597fefc1
Change flake8-quotes default to double quotes ( #558 )
2022-11-02 22:03:54 -04:00
Charlie Marsh
add0bdeeb7
DRY up utilities in flake8_comprehensions/fixes.rs ( #556 )
2022-11-02 22:00:53 -04:00
Charlie Marsh
6a180b95d1
Implement autofix for dict and tuple comprehensions ( #555 )
2022-11-02 21:36:20 -04:00
Charlie Marsh
416c338237
Respect trailing whitespace in comprehension fixes ( #554 )
2022-11-02 21:08:17 -04:00
Charlie Marsh
9948be0145
Automatically fix a variety of comprehension rules ( #553 )
2022-11-02 20:39:35 -04:00
Charlie Marsh
f50ff61056
Expose autofix mode in public API ( #551 )
2022-11-02 09:44:46 -04:00
Charlie Marsh
017fec2bc5
Set override in actions-rs/toolchain@v1 ( #543 )
2022-11-02 09:36:22 -04:00
Charlie Marsh
f9def0a139
Bump version to 0.0.95
2022-11-02 09:03:34 -04:00
StefanBRas
d4fc485a76
Update README.md to use table for per-file-ignore ( #549 )
2022-11-02 09:02:11 -04:00
Charlie Marsh
0827d0beef
Account for typing_extensions for annotation parsing ( #550 )
2022-11-02 09:01:12 -04:00
Charlie Marsh
b4a46ab6f0
Add tests for converter.rs ( #542 )
2022-11-01 22:36:08 -04:00
Charlie Marsh
f6e14edc3e
Use max-line-length in converter.rs ( #541 )
2022-11-01 22:27:13 -04:00
Charlie Marsh
878a94f9cb
Add a rust-toolchain.toml file ( #538 )
2022-11-01 20:34:58 -04:00
Charlie Marsh
79ca66ace5
Use nightly rustfmt with rustfmt.toml ( #536 )
2022-11-01 20:34:38 -04:00
fsouza
c68c6b5424
Make columns indices 1-based in the text output format ( #539 )
2022-11-01 19:06:08 -04:00
Charlie Marsh
bad5723d80
Add plugin configuration to flake8-to-ruff ( #535 )
2022-11-01 17:08:53 -04:00
Charlie Marsh
2d83f99dbf
Bump version to 0.0.94
2022-11-01 16:38:59 -04:00
Charlie Marsh
5123b38758
Refine list of annotatable subscripts ( #534 )
2022-11-01 16:36:05 -04:00
Charlie Marsh
e9a4c8ba13
Track typing module imports ( #533 )
2022-11-01 14:01:59 -04:00
Charlie Marsh
927d716edd
Enable flake8-to-ruff builds on all platforms
2022-11-01 12:15:43 -04:00
Charlie Marsh
df6a48fced
Use separate tokens for each PyPI release
2022-10-31 22:43:38 -04:00
Charlie Marsh
91a8277ac0
Always release flake8-to-ruff
2022-10-31 22:16:28 -04:00
Charlie Marsh
5797884262
Represent per-file ignores as a map ( #531 )
2022-10-31 22:15:33 -04:00
Charlie Marsh
5aa8455258
Misc. improvements to flake8-to-ruff
2022-10-31 18:38:47 -04:00
Charlie Marsh
8fd713739b
Use pretty-print for flake8-to-ruff
2022-10-31 17:52:03 -04:00
Charlie Marsh
5de1fcd653
Add to flake8-to-ruff README
2022-10-31 17:50:32 -04:00
Charlie Marsh
032f4f3f12
Set maturin path when building flake8-to-ruff
2022-10-31 16:49:45 -04:00
Charlie Marsh
621db96e7f
Use more consistent Option in pyproject settings ( #530 )
2022-10-31 16:34:58 -04:00
Charlie Marsh
05867ef260
Set flake8-to-ruff release to workflow_dispatch
2022-10-31 16:25:09 -04:00
Charlie Marsh
0cd8b75f06
Rename release.yaml files
2022-10-31 16:23:52 -04:00
Charlie Marsh
5f07e1d6b5
Fix release.yaml task names
2022-10-31 16:22:25 -04:00
Charlie Marsh
1ce4585c88
Add a separate release job for flake8-to-ruff ( #529 )
2022-10-31 16:21:38 -04:00
Charlie Marsh
f3f010cdf5
Move flake8-to-ruff to a separate crate ( #528 )
2022-10-31 14:22:07 -04:00
Charlie Marsh
7e5e03fb15
Add a Flake8-to-Ruff configuration conversion tool ( #527 )
2022-10-31 11:34:40 -04:00
Charlie Marsh
062c41b6f5
Bump version to 0.0.93
2022-10-31 09:20:39 -04:00
Charlie Marsh
78889efa37
Modify public API to return Check rather than Message ( #524 )
2022-10-31 09:20:14 -04:00
Charlie Marsh
97fc281779
Remove erroneous foo.py file
2022-10-30 19:19:49 -04:00
Charlie Marsh
138b06c98a
Bump version to 0.0.92
2022-10-30 18:04:30 -04:00
Charlie Marsh
2415d73260
Remove RustPython fork ( #523 )
2022-10-30 18:04:05 -04:00
Charlie Marsh
b060ae2f22
Move SourceCodeLocator to its own module ( #522 )
2022-10-30 15:51:59 -04:00
Charlie Marsh
9aa91d3d3c
Add a cargo bench for SourceCodeLocator ( #521 )
2022-10-30 13:50:42 -04:00
Charlie Marsh
dcedb801e5
Tweak a few check messages ( #520 )
2022-10-30 13:13:37 -04:00
Charlie Marsh
d3e7fdabb5
Implement consistent newline handling for SourceCodeLocator ( #519 )
2022-10-30 13:11:08 -04:00
Charlie Marsh
dfa5a4f0f7
Fix 9/32 flake8-bugbear reference
2022-10-30 13:03:39 -04:00
Charlie Marsh
58a2d600da
Avoid flagging D202 for inner functions and classes ( #518 )
2022-10-30 13:02:55 -04:00
Harutaka Kawamura
7ecbfe4f6a
Implement B006 ( #515 )
2022-10-30 12:57:57 -04:00
Charlie Marsh
d8248104a7
Avoid re-indenting empty lines in D207 ( #517 )
2022-10-30 09:41:54 -04:00
Charlie Marsh
6eb09122c0
Add final newline in SourceCodeLocator
2022-10-29 19:23:16 -04:00
Charlie Marsh
f84c1f1fa1
Bump version to 0.0.91
2022-10-29 18:49:26 -04:00
Charlie Marsh
3aa9528229
Avoid flake8-comprehensions errors for dicts with kwargs ( #512 )
2022-10-29 18:49:06 -04:00
Charlie Marsh
5a3f06bab1
Bump version to 0.0.90
2022-10-29 18:34:38 -04:00
Charlie Marsh
db59d5b558
Use a single SourceCodeLocator everywhere ( #510 )
2022-10-29 18:23:24 -04:00
Charlie Marsh
2fcbf3ab62
Simplify SourceCodeLocator offset computation ( #509 )
2022-10-29 18:13:42 -04:00
Anders Kaseorg
fa9b10be72
Remove leading space from C416 message ( #508 )
2022-10-29 17:40:50 -04:00
Charlie Marsh
c495cef529
Move pyproject.toml logging to debug ( #506 )
2022-10-29 17:07:46 -04:00
Charlie Marsh
c0c8dff6ce
Implement configuration options for pep8-naming ( #505 )
2022-10-29 17:00:30 -04:00
Charlie Marsh
80b00cc89f
Add error code categories to table of contents ( #504 )
2022-10-29 16:39:55 -04:00
Charlie Marsh
934db3d179
Bump version to 0.0.89
2022-10-29 15:39:17 -04:00
Charlie Marsh
6a040a0405
Update checks_gen.rs
2022-10-29 15:39:02 -04:00
Harutaka Kawamura
2821ef0f69
Implement B013 ( #503 )
2022-10-29 15:36:29 -04:00
Harutaka Kawamura
343d931ddb
Ignore unittest methods and functions in N802 ( #502 )
2022-10-29 15:36:09 -04:00
Harutaka Kawamura
3fc257f71b
Implement N806, 815, 816, 818 ( #501 )
2022-10-29 15:35:56 -04:00
Charlie Marsh
6dbb0a17e9
Update README to reflect selection groups
2022-10-28 19:15:46 -04:00
Charlie Marsh
ae5ad6a4ac
Bump version to 0.0.88
2022-10-28 19:11:04 -04:00
Charlie Marsh
549af6c584
Regenerate CheckCodePrefix
2022-10-28 19:10:45 -04:00
Charlie Marsh
9a799eb4e6
Bump version to 0.0.87
2022-10-28 19:00:03 -04:00
Anders Kaseorg
f260b873b6
Fix “not a char boundary” error with Unicode in extract_quote ( #497 )
2022-10-28 18:59:12 -04:00
Charlie Marsh
782a90b584
Add tests for resolve_codes ( #498 )
2022-10-28 18:58:46 -04:00
Charlie Marsh
7df903dc4d
Move around and rename some of the Settings structs ( #496 )
2022-10-28 18:46:54 -04:00
Charlie Marsh
8fc5e91ec7
Enable prefix-based check code selection ( #493 )
2022-10-28 18:19:57 -04:00
Charlie Marsh
9ca1a2c273
Fix failing pyproject.toml test
2022-10-28 18:13:07 -04:00
Charlie Marsh
86265c1d7c
Implement the flake8-quotes plugin ( #495 )
2022-10-28 17:52:11 -04:00
Charlie Marsh
a057c9a323
Move invalid_escape_sequence into pycodestyle ( #494 )
2022-10-28 12:20:11 -04:00
Trevor Gross
2e63bb6dcb
Update hook id in README and in .pre-commit-config.yaml ( #492 )
2022-10-27 17:32:52 -04:00
Charlie Marsh
1b5db80b32
Update pre-commit invocation in README.md
2022-10-27 17:19:22 -04:00
Charlie Marsh
3f20cea402
Bump version to 0.0.86
2022-10-27 13:09:57 -04:00
Charlie Marsh
389fe1ff64
Avoid auto-fixing unused imports in __init__.py ( #489 )
2022-10-27 13:08:04 -04:00
Charlie Marsh
bad2d7ba85
Add example of per-file ignores to the README ( #488 )
2022-10-27 12:58:52 -04:00
Charlie Marsh
416aa298ac
Allow whitespace in per-file ignore patterns ( #487 )
2022-10-27 12:55:28 -04:00
Charlie Marsh
a535b1adbf
Replace compliance comments with check codes ( #485 )
2022-10-27 09:32:18 -04:00
Charlie Marsh
05fbd1a283
Bump version to 0.0.85
2022-10-26 19:13:04 -04:00
Charlie Marsh
63552cbc8e
Implement W605 (invalid escape sequence) ( #482 )
2022-10-26 19:10:24 -04:00
Charlie Marsh
c00bd489f1
Fix multi-segment import removal ( #480 )
2022-10-26 16:43:55 -04:00
Charlie Marsh
16c2e3a995
Handle multi-segment import-from removal ( #479 )
2022-10-26 16:36:12 -04:00
Anders Kaseorg
650b025181
Suppress “No pyproject.toml found” message with --quiet ( #478 )
2022-10-26 16:03:25 -04:00
Anders Kaseorg
8fe46f7400
Rename --quiet to --silent and make --quiet only log errors ( #477 )
2022-10-26 16:03:10 -04:00
Charlie Marsh
a9bcc15797
Bump version to 0.0.84
2022-10-26 12:01:55 -04:00
Charlie Marsh
b6c856bd07
Implement B007 (unused loop control variable) ( #473 )
2022-10-26 12:01:27 -04:00
Charlie Marsh
4beea0484a
Use lazy initialization for SourceCodeLocator ( #472 )
2022-10-26 11:27:48 -04:00
Suguru Yamamoto
2679db1d10
Correct EOL offset for lines ending with multi-byte char ( #471 )
2022-10-26 11:00:27 -04:00
Charlie Marsh
3e73462e04
Optimize imports
2022-10-25 22:06:51 -04:00
Charlie Marsh
f63a87737a
DRY up usages of matches with fixer Mode ( #470 )
2022-10-25 22:02:58 -04:00
Charlie Marsh
e7472eac1c
Increment flake8-bugbear to 8/32
2022-10-25 21:54:00 -04:00
Charlie Marsh
db3c847771
Bump version to 0.0.83
2022-10-25 21:24:13 -04:00
Charlie Marsh
4adbfc24a5
Increment flake8-bugbear to 6/32
2022-10-25 21:23:13 -04:00
Charlie Marsh
8f734a6562
Implement B002 (unary prefix increment) ( #468 )
2022-10-25 21:10:51 -04:00
Charlie Marsh
bcf7519eb3
Implement B017 (no assertRaises(Exception)) ( #467 )
2022-10-25 20:55:00 -04:00
Heyward Fann
66089052ee
chore: typo on #283 link ( #464 )
2022-10-25 08:02:11 -04:00
Jeong YunWon
d50cc8ff65
Restyle flake8_comprehensions::check to reduce indent ( #462 )
2022-10-24 15:16:56 -04:00
Harutaka Kawamura
b75ea94f58
Fix uppercase and lowercase check ( #461 )
2022-10-22 12:49:13 -04:00
Harutaka Kawamura
2c24e2fd28
Enable N811, 812, 813, 814, 817 for Import ( #460 )
2022-10-22 08:31:02 -04:00
Charlie Marsh
f8dc208665
Tweak messages for pep8-naming rules
2022-10-21 17:06:16 -04:00
Charlie Marsh
c72b8e8d1e
Bump version to 0.0.82
2022-10-21 12:15:19 -04:00
Harutaka Kawamura
b108c693fa
Implement N811, 812, 813, 814, and 817 ( #457 )
2022-10-20 12:20:44 -04:00
Harutaka Kawamura
aac1912ea7
Implement N807 ( #456 )
2022-10-20 11:12:02 -04:00
Charlie Marsh
3dcd26aac3
Add SectionUnderlineAfterName to autofix list
2022-10-17 22:08:49 -04:00
Charlie Marsh
e53b9807f6
Bump version to 0.0.81
2022-10-17 21:43:49 -04:00
Charlie Marsh
36fe8b76d4
Enable autofix for over- and under-indented docstrings ( #451 )
2022-10-17 21:43:38 -04:00
Charlie Marsh
f832f88c75
Implement autofix support for D214, D405, D406, and D416 ( #450 )
2022-10-17 17:37:20 -04:00
Charlie Marsh
659a28de02
Bump version to 0.0.80
2022-10-17 17:02:44 -04:00
Charlie Marsh
583149a472
Break up autofix/fixes.rs ( #449 )
2022-10-17 17:01:50 -04:00
Charlie Marsh
206e6463be
Implement autofix for more docstring-related rules ( #448 )
2022-10-17 16:56:47 -04:00
Charlie Marsh
118a9feec8
Split checks and plugins into source-related modules ( #447 )
2022-10-17 15:38:49 -04:00
Charlie Marsh
1f2ccb059a
Break up some nested if statements
2022-10-17 13:08:33 -04:00
Charlie Marsh
f4d9d6c858
Fix typo in prev_visible_scope
2022-10-17 13:03:50 -04:00
Charlie Marsh
3477f5664a
Fix README link to near-parity
2022-10-17 11:57:07 -04:00
Charlie Marsh
edefa5219c
Update RustPython to get main versions of end_location etc. ( #445 )
2022-10-17 11:52:40 -04:00
Charlie Marsh
cf0d198365
Bump version to 0.0.79
2022-10-16 21:39:01 -04:00
Charlie Marsh
08b14ed77e
Remove leading 'or' from fixable match
2022-10-16 21:38:22 -04:00
Charlie Marsh
6ee3075867
Bump version to 0.0.78
2022-10-16 21:28:25 -04:00
Charlie Marsh
cc8a945cbf
Tweak messages for flake8-comprehensions rules ( #444 )
2022-10-16 21:27:13 -04:00
Charlie Marsh
1a1922b3fc
Re-add the fix icon to README.md ( #443 )
2022-10-16 21:21:30 -04:00
Charlie Marsh
48bd766298
Implement autofixes for more docstring rules ( #442 )
2022-10-16 21:16:57 -04:00
Charlie Marsh
1ece3873cd
Implement autofix for newline-related docstring rules ( #441 )
2022-10-16 19:40:38 -04:00
Charlie Marsh
472d902486
Rename docstring_plugins.rs to plugins.rs
2022-10-16 18:39:08 -04:00
Charlie Marsh
4ac6a18d40
Remove some Vec arguments
2022-10-16 18:17:10 -04:00
Charlie Marsh
8a47ea91ba
Use CheckCategory to drive default rules
2022-10-16 18:07:03 -04:00
Charlie Marsh
bd4394aa89
Capitalize pep8-naming messages
2022-10-16 17:58:26 -04:00
Charlie Marsh
56f69ce71e
Bump version to 0.0.77
2022-10-16 13:43:52 -04:00
Charlie Marsh
248a6cd50b
Remove offsets hacks for docstring parsing logic ( #440 )
2022-10-16 13:43:30 -04:00
Charlie Marsh
d9e659d817
Revert "Remove trailing colon from messages"
...
This reverts commit 77e5564f4b .
2022-10-16 12:35:40 -04:00
Charlie Marsh
77e5564f4b
Remove trailing colon from messages
2022-10-16 12:09:46 -04:00
Charlie Marsh
e79766d5ec
Use backticks for pep8-naming messages
2022-10-16 12:09:07 -04:00
Harutaka Kawamura
c55fd76743
Implement N801 ~ N805 ( #439 )
2022-10-16 11:58:39 -04:00
Charlie Marsh
e2aedc5ba8
Bump version to 0.0.76
2022-10-15 17:22:12 -04:00
Charlie Marsh
1b2d085460
Mark W292 as a non-AST check
2022-10-15 17:21:52 -04:00
Charlie Marsh
cb138526b1
Add a note on pydocstyle
2022-10-15 17:05:18 -04:00
Charlie Marsh
8eac270d8f
Add an FAQ
2022-10-15 16:52:20 -04:00
Charlie Marsh
6e19fd20bb
Add table of contents
2022-10-15 16:37:52 -04:00
Charlie Marsh
10868445f5
Use H3 for rules sections
2022-10-15 16:33:26 -04:00
Charlie Marsh
e3ecf21287
Break rules table into sections ( #437 )
2022-10-15 16:29:08 -04:00
Charlie Marsh
fd849e112e
Remove checkmark from rule table ( #436 )
2022-10-15 11:28:32 -04:00
Harutaka Kawamura
af27471c77
Fix C401 and C402 ( #435 )
2022-10-15 09:16:43 -04:00
konstin
bb466bc8d3
Add initial wasm32-wasi support ( #416 )
2022-10-14 20:58:18 -04:00
Charlie Marsh
7741a713e2
Avoid checking for updates when executing via stdin ( #433 )
2022-10-14 20:57:40 -04:00
Charlie Marsh
3ab1cfc6f8
Make some improvements to the README
2022-10-14 17:30:40 -04:00
Charlie Marsh
e73f13473d
Add a .flake8 file for benchmarking
2022-10-14 17:05:24 -04:00
Charlie Marsh
3e8ef5b40f
Bump version to 0.0.75
2022-10-14 14:42:57 -04:00
Charlie Marsh
c59610906c
Optimize imports
2022-10-14 14:42:48 -04:00
Charlie Marsh
2353a52be8
Nest if
2022-10-14 14:36:45 -04:00
Charlie Marsh
bbffdd57ff
Handle multi-byte chars in SourceCodeLocator ( #431 )
2022-10-14 14:29:18 -04:00
Charlie Marsh
3c15c578a7
Implement D206, D207, and D208 ( #429 )
2022-10-14 13:26:36 -04:00
Charlie Marsh
6a8e31b2ff
Bump version to 0.0.74
2022-10-14 12:36:44 -04:00
Charlie Marsh
6407fd5a33
Re-arrange some docstring modules ( #428 )
2022-10-14 12:34:35 -04:00
Harutaka Kawamura
b64040cbb2
Implement C417 ( #426 )
2022-10-14 12:34:00 -04:00
Charlie Marsh
952a0eb4e3
Implement checks for Google-style docstrings ( #427 )
2022-10-14 11:53:29 -04:00
Charlie Marsh
3e28d6de04
Bump version to 0.0.73
2022-10-14 10:18:42 -04:00
Charlie Marsh
9bbfd1d3b2
Implement docstring argument tracking for NumPy-style docstrings ( #425 )
2022-10-14 10:18:07 -04:00
Charlie Marsh
6fb82ab763
Use test_case for macro-driven check tests ( #424 )
2022-10-13 18:51:01 -04:00
Charlie Marsh
6b286e9bc1
Add --config as a command-line option ( #422 )
2022-10-13 18:13:41 -04:00
Harutaka Kawamura
bcddd9e97f
Implement C413 ( #421 )
2022-10-13 11:15:41 -04:00
Harutaka Kawamura
3e789136af
Implement C411 ( #420 )
2022-10-13 09:48:27 -04:00
Harutaka Kawamura
07ef3b8754
Implement C416 ( #415 )
2022-10-13 08:34:33 -04:00
Charlie Marsh
46e1b16472
Bump version to 0.0.72
2022-10-12 22:43:29 -04:00
fsouza
720bfe0161
Implement --fix with stdin ( #405 )
2022-10-12 22:31:46 -04:00
Charlie Marsh
2f69be0d41
Bump version to 0.0.71
2022-10-12 17:14:28 -04:00
Charlie Marsh
54cb2eb15b
Only run section checks when CheckCodes are enabled
2022-10-12 17:14:16 -04:00
Charlie Marsh
167992ad48
Implement D407, D408, D409, D412, and D414 ( #413 )
2022-10-12 17:12:54 -04:00
Charlie Marsh
f0dab24079
Implement D405, D406, D410, D411, and D413 ( #411 )
2022-10-12 16:31:14 -04:00
Charlie Marsh
77055faab6
Implement D404 and D418 for pydocstyle ( #409 )
2022-10-12 13:20:55 -04:00
Charlie Marsh
e08e1caf71
Bump version to 0.0.70
2022-10-12 12:59:14 -04:00
Harutaka Kawamura
0072dfd81e
Implement C414 ( #406 )
2022-10-12 12:58:46 -04:00
Charlie Marsh
6ffe02ee05
Pass around VisibleScope
2022-10-12 12:52:48 -04:00
Charlie Marsh
688fc0cd02
Implement docstring visibility checks ( #408 )
2022-10-12 12:46:40 -04:00
Charlie Marsh
f30e5e45ab
Remove initial field
2022-10-12 11:07:31 -04:00
Charlie Marsh
1a68a38306
Enable definition tracking for docstrings ( #407 )
2022-10-12 11:06:28 -04:00
Charlie Marsh
590aa92ead
Implement D201, D202, D203, D204, and D211 ( #404 )
2022-10-11 21:08:30 -04:00
Charlie Marsh
8868f57a74
Implement D402 for pydocstyle ( #403 )
2022-10-11 13:19:56 -04:00
Charlie Marsh
71802f8861
Bump version to 0.0.69
2022-10-11 12:54:56 -04:00
Charlie Marsh
5b6fb8cefa
Skip docstring checks for empty docstrings ( #402 )
2022-10-11 12:54:30 -04:00
Charlie Marsh
2ff964107c
Add D212, D213, D300, D403, and D415 ( #400 )
2022-10-11 12:48:23 -04:00
Charlie Marsh
141132d5be
Add fake setup.py ( #399 )
2022-10-11 12:38:48 -04:00
Harutaka Kawamura
8ba872ece4
Support linting input from stdin ( #387 )
2022-10-11 09:56:20 -04:00
Charlie Marsh
209dce2033
Fix missing backtick
2022-10-10 17:23:58 -04:00
Charlie Marsh
90d88dfb10
Make pyupgrade tally more precise
2022-10-10 17:18:20 -04:00
Charlie Marsh
4730911b25
Bump version to 0.0.68
2022-10-10 16:50:09 -04:00
Charlie Marsh
4e9fb9907a
Implement D205, D209, and D210 ( #398 )
2022-10-10 16:49:51 -04:00
Charlie Marsh
b8dce8922d
Implement D200 (OneLinerDocstring) ( #397 )
2022-10-10 16:07:51 -04:00
Charlie Marsh
30877127bc
Implement D400 (DocstringEndsInNonPeriod) ( #396 )
2022-10-10 15:35:23 -04:00
Charlie Marsh
8b66bbdc9b
Regenerate rules table
2022-10-10 15:18:18 -04:00
Charlie Marsh
71d3a84b14
Implement D410 (EmptyDocstring) ( #395 )
2022-10-10 15:15:38 -04:00
Charlie Marsh
323a5c857c
Implement docstring tracking ( #394 )
2022-10-10 15:15:09 -04:00
Charlie Marsh
42cec3f5a0
Regenerate rules table
2022-10-10 14:02:31 -04:00
Charlie Marsh
ee42413e10
Enable autofix for B014
2022-10-10 13:18:43 -04:00
Charlie Marsh
765db12b84
Remove check_ prefix from check utilities ( #393 )
2022-10-10 12:58:40 -04:00
Charlie Marsh
e1b711d9c6
Bump version to 0.0.67
2022-10-10 12:55:04 -04:00
Charlie Marsh
35f593846e
Implement B014 from flake8-bugbear ( #392 )
2022-10-10 12:53:42 -04:00
Charlie Marsh
c384fa513b
Implement B025 from flake8-bugbear ( #391 )
2022-10-10 12:18:31 -04:00
Charlie Marsh
022ff64d29
Implement B011 from flake8-bugbear ( #390 )
2022-10-10 10:55:55 -04:00
Charlie Marsh
5a06fb28fd
Bump version to 0.0.66
2022-10-10 10:03:59 -04:00
Charlie Marsh
46750a3e17
Flag unimplemented error codes in M001 ( #388 )
2022-10-10 10:03:40 -04:00
Charlie Marsh
9cc902b802
Avoid F821 false-positives with NameError ( #386 )
2022-10-10 09:39:59 -04:00
Harutaka Kawamura
c2a36ebd1e
Implement C410 ( #382 )
2022-10-09 23:33:55 -04:00
Charlie Marsh
34ca225393
Rename flakes8 to flake8
2022-10-09 23:02:44 -04:00
Harutaka Kawamura
38c30905e6
Implement C409 ( #381 )
2022-10-09 22:34:52 -04:00
Charlie Marsh
2774194b03
Bump version to 0.0.65
2022-10-09 22:14:04 -04:00
Charlie Marsh
71ebd39f35
Extend assertEquals check to all deprecated unittest aliases ( #380 )
2022-10-09 22:13:51 -04:00
Charlie Marsh
a2f78ba2c7
Fix auto-fix for assertEquals rename
2022-10-09 22:11:32 -04:00
Charlie Marsh
b51a080a44
Rename SPR001 to U008 ( #379 )
2022-10-09 21:58:22 -04:00
Charlie Marsh
6a1d7d8a1c
Defer string annotations even when futures annotations are enabled ( #378 )
2022-10-09 18:28:29 -04:00
Charlie Marsh
10b250ee57
Bump version to 0.0.64
2022-10-09 17:38:09 -04:00
Charlie Marsh
30b1b1e15a
Treat TypeAlias values as annotations ( #377 )
2022-10-09 17:37:19 -04:00
Charlie Marsh
aafe7c0c39
Mark aliased submodule imports as used ( #374 )
2022-10-09 17:01:14 -04:00
Harutaka Kawamura
f060248656
Fix collapsed message ( #372 )
2022-10-09 13:01:36 -04:00
Harutaka Kawamura
bbe0220c72
Implement C415 ( #371 )
2022-10-09 10:12:58 -04:00
Charlie Marsh
129e2b6ad3
Bump version to 0.0.63
2022-10-08 22:51:49 -04:00
Charlie Marsh
73e744b1d0
Create unified Expr for PEP 604 rewrites ( #370 )
2022-10-08 22:13:00 -04:00
Charlie Marsh
50a3fc5a67
Move some code into helpers.rs
2022-10-08 20:45:15 -04:00
Charlie Marsh
de499f0258
Optimize imports
2022-10-08 20:39:13 -04:00
Charlie Marsh
e1abe37c6a
Bump version to 0.0.62
2022-10-08 20:28:38 -04:00
Charlie Marsh
7fe5945541
Implement PEP 604 annotation rewrites ( #369 )
2022-10-08 20:28:00 -04:00
Charlie Marsh
806f3fd4f6
Implement PEP 585 annotation rewrites ( #368 )
2022-10-08 18:22:24 -04:00
Charlie Marsh
2bba643dd2
Use strum to facilitate simple enum serialization ( #367 )
2022-10-08 17:47:25 -04:00
Charlie Marsh
54090bd7ac
Use strum to iterate over all check codes ( #366 )
2022-10-08 17:41:47 -04:00
Charlie Marsh
c62727db42
Bump version to 0.0.61
2022-10-08 17:25:36 -04:00
Charlie Marsh
d0e1612507
Check newline ending on contents directly ( #365 )
2022-10-08 17:25:22 -04:00
Harutaka Kawamura
5ccd907398
Implement C408 ( #364 )
2022-10-08 17:17:34 -04:00
Harutaka Kawamura
346610c2e3
Implement C406 ( #363 )
2022-10-08 11:15:41 -04:00
Harutaka Kawamura
307fa26515
Implement C405 ( #362 )
2022-10-08 09:03:21 -04:00
Harutaka Kawamura
136d412edd
Add missing C400,C401, and C402 to CheckCode.from_str ( #361 )
2022-10-08 09:02:03 -04:00
Harutaka Kawamura
d9edec0ac9
Implement C402 ( #359 )
2022-10-07 22:57:04 -04:00
Chris Pryer
473675fffb
Add check for W292 ( #339 )
2022-10-07 21:10:16 -04:00
Steven Maude
95dfc61315
Update GitHub Actions versions in README ( #358 )
2022-10-07 20:24:00 -04:00
Charlie Marsh
dd496c7b52
Bump version to 0.0.60
2022-10-07 17:36:33 -04:00
Charlie Marsh
78aafb4b34
Warn the user if an explicitly selected check code is ignored ( #356 )
2022-10-07 17:36:17 -04:00
Charlie Marsh
99c66d513a
Rename refactor checks to upgrade checks ( #354 )
2022-10-07 16:54:55 -04:00
Charlie Marsh
04ade6a2f3
Update README.md
2022-10-07 16:50:17 -04:00
Charlie Marsh
4cf2682cda
Implement type(primitive) ( #353 )
2022-10-07 16:47:06 -04:00
Charlie Marsh
e3a7357187
Wrap each import in its own backticks ( #346 )
2022-10-07 15:58:30 -04:00
Charlie Marsh
b60768debb
Remove erroneous output.py file
2022-10-07 15:04:23 -04:00
Charlie Marsh
25e476639f
Use or_default in lieu of or_insert
2022-10-07 14:56:56 -04:00
Charlie Marsh
4645788205
Bump version to 0.0.59
2022-10-07 14:55:23 -04:00
Charlie Marsh
0b9eda8836
Add target Python version as a configurable setting ( #344 )
2022-10-07 14:54:50 -04:00
Charlie Marsh
ad23d6acee
Remove :: prefix for ruff imports
2022-10-07 14:24:51 -04:00
Harutaka Kawamura
e3d1d01a1f
Implement C401 ( #343 )
2022-10-07 13:00:22 -04:00
Harutaka Kawamura
6dfdd21a7c
Implement C400 ( #340 )
2022-10-07 12:16:23 -04:00
Charlie Marsh
f17d3b3c44
Bump version to 0.0.58
2022-10-07 12:14:03 -04:00
Charlie Marsh
da6b913317
Exit 0 if all errors are fixed ( #342 )
2022-10-07 12:13:15 -04:00
Harutaka Kawamura
bd34850f98
Implement C404 ( #338 )
2022-10-07 08:53:18 -04:00
Charlie Marsh
d5b33cdb40
Add missing snapshot for U002
2022-10-07 08:48:59 -04:00
Charlie Marsh
3fb4cf7009
Hide autoformat argument
2022-10-06 22:56:01 -04:00
Charlie Marsh
6e19539e28
Enable abspath(__file__) removal ( #336 )
2022-10-06 22:49:06 -04:00
Charlie Marsh
4eac7a07f5
Mention flake8-comprehensions in README
2022-10-06 16:26:21 -04:00
Harutaka Kawamura
5141285c8e
Implement C403 ( #335 )
2022-10-06 16:24:23 -04:00
Charlie Marsh
82cc139d2d
Bump version to 0.0.57
2022-10-06 09:16:56 -04:00
Adrian Garcia Badaracco
df438ba051
Support PEP 593 annotations ( #333 )
2022-10-06 09:16:07 -04:00
Adrian Garcia Badaracco
a70624cd47
add instructions for setting up cargo insta ( #334 )
2022-10-06 08:01:11 -04:00
Charlie Marsh
b307afc00c
Move some accesses behind a shared function
2022-10-05 14:54:31 -04:00
Charlie Marsh
3d5bc1f51f
Migrate Checker logic to independent plugins ( #331 )
2022-10-05 14:08:40 -04:00
Charlie Marsh
aba01745f5
Bump version to 0.0.56
2022-10-05 11:58:54 -04:00
Charlie Marsh
1eeeffab66
Add T201 and T203 to string conversion match ( #332 )
2022-10-05 11:58:33 -04:00
Charlie Marsh
9b564c9cf4
Bump version to 0.0.55
2022-10-04 20:07:31 -04:00
Charlie Marsh
5bf8b13644
Properly combine CLI and pyproject.toml ignores and selects ( #329 )
2022-10-04 20:07:17 -04:00
Anders Kaseorg
f80d5e70dd
Support extend-select in pyproject.toml ( #327 )
2022-10-04 17:24:30 -04:00
Charlie Marsh
44897b2a5b
Enable AST-to-source code generation ( #292 )
2022-10-04 16:27:57 -04:00
Anders Kaseorg
d1bcc919a2
Remove unnecessary Option wrapper from some pyproject::Config fields ( #326 )
2022-10-04 16:27:40 -04:00
Charlie Marsh
03e1397427
Bump version to 0.0.54
2022-10-04 14:32:06 -04:00
Charlie Marsh
fdb32330a9
Implement __metaclass__ = type removal ( #324 )
2022-10-04 14:31:52 -04:00
Charlie Marsh
4e6ae33a3a
Only flag super calls in class-function scopes ( #323 )
2022-10-04 13:55:32 -04:00
Charlie Marsh
295ff8eb1a
Add autofix and default status to README ( #322 )
2022-10-04 12:30:35 -04:00
Parth Shandilya
2449771d2f
Fix the broken link to contribution guidelines ( #321 )
2022-10-04 11:10:10 -04:00
Charlie Marsh
406491a3a2
Bump version to 0.0.53
2022-10-04 08:56:46 -04:00
Charlie Marsh
bfae262359
Simplify noqa extraction logic ( #320 )
2022-10-04 08:56:14 -04:00
Charlie Marsh
af894f290f
Disable plugin-based rules by default ( #318 )
2022-10-04 08:28:46 -04:00
Charlie Marsh
c901742244
Add plugins mention to README ( #309 )
2022-10-03 17:23:53 -04:00
Charlie Marsh
7e4faf4b69
Implement flake8-print ( #308 )
2022-10-03 17:19:56 -04:00
Charlie Marsh
31a0b20271
Bump version to 0.0.52
2022-10-03 15:22:58 -04:00
Charlie Marsh
0966bf2c66
Handle multi-import lines ( #307 )
2022-10-03 15:22:46 -04:00
Charlie Marsh
64d8e25528
Bump version to 0.0.51
2022-10-03 14:08:39 -04:00
Charlie Marsh
b049cced04
Automatically remove unused imports ( #298 )
2022-10-03 14:08:16 -04:00
Charlie Marsh
bc335f839e
Visit lambda arguments prior to deferral ( #303 )
2022-10-02 20:54:02 -04:00
Charlie Marsh
4819e19ba2
Bump version to 0.0.50
2022-10-02 20:43:30 -04:00
Charlie Marsh
622b8adb79
Avoid falling back to A003 when A001 is disabled ( #302 )
2022-10-02 20:43:12 -04:00
Charlie Marsh
558d9fcbe3
Enable LibCST-based autofixing for SPR001 ( #297 )
2022-10-02 19:58:13 -04:00
Charlie Marsh
83f18193c2
Add an end location to Check ( #299 )
2022-10-02 12:50:42 -04:00
Charlie Marsh
46e6a1b3be
Add end locations to all nodes ( #296 )
2022-10-02 12:49:48 -04:00
Suguru Yamamoto
4d0d433af9
fix: Make assigns to dunder exception for E402. ( #294 )
2022-10-01 09:43:47 -04:00
Christian Clauss
11f7532e72
pre-commit: Validate pyproject.toml ( #266 )
2022-09-30 19:21:12 -04:00
Charlie Marsh
417764d309
Expose a public 'check' method ( #289 )
2022-09-30 11:30:37 -04:00
Charlie Marsh
1e36c109c6
Bump version to 0.0.49
2022-09-30 09:15:32 -04:00
Nikita Sobolev
3960016d55
Create .editorconfig ( #290 )
2022-09-30 09:15:08 -04:00
Charlie Marsh
75d669fa86
Update check ordering
2022-09-30 09:14:41 -04:00
Nikita Sobolev
20989e12ba
Implement flake8-super check ( #291 )
2022-09-30 09:12:09 -04:00
Charlie Marsh
5a1b6c32eb
Add CONTRIBUTING.md ( #288 )
2022-09-30 07:51:30 -04:00
Charlie Marsh
46bdcb9080
Add instructions on GitHub Actions integration
2022-09-29 19:05:02 -04:00
Charlie Marsh
d16a7252af
Add instructions on PyCharm integration
2022-09-29 18:52:45 -04:00
Charlie Marsh
ca6551eb37
Remove misc. unnecessary statements
2022-09-29 18:45:10 -04:00
Charlie Marsh
43a4f5749e
Create CODE_OF_CONDUCT.md ( #287 )
2022-09-29 16:59:17 -04:00
Charlie Marsh
6fef4db433
Bump version to 0.0.48
2022-09-29 16:40:01 -04:00
Charlie Marsh
7470d6832f
Add pattern matching limitation to README.md
2022-09-29 16:39:25 -04:00
Nikita Sobolev
63ba0bfeef
Adds flake8-builtins ( #284 )
2022-09-29 16:37:43 -04:00
Anders Kaseorg
91666fcaf6
Don’t follow directory symlinks found while walking ( #280 )
2022-09-29 15:10:25 -04:00
Heyward Fann
643e27221d
chore: fix eslint fix link ( #281 )
2022-09-29 07:15:07 -04:00
Charlie Marsh
c7349b69c1
Bump version to 0.0.47
2022-09-28 22:30:48 -04:00
Charlie Marsh
7f84753f3c
Improve rendering of --show-settings
2022-09-28 22:30:20 -04:00
Charlie Marsh
e2ec62cf33
Misc. follow-up changes to #272 ( #278 )
2022-09-28 22:15:58 -04:00
Charlie Marsh
1d5592d937
Use take-while to terminate on parse errors ( #279 )
2022-09-28 22:06:35 -04:00
Anders Kaseorg
886def13bd
Upgrade to clap 4 ( #272 )
2022-09-28 17:11:57 -04:00
Charlie Marsh
949e4d4077
Bump version to 0.0.46
2022-09-24 13:10:10 -04:00
Charlie Marsh
c8cb2eead2
Remove README note about noqa patterns
2022-09-24 13:09:45 -04:00
Seamooo
02ae494a0e
Enable per-file ignores ( #261 )
2022-09-24 13:02:34 -04:00
Harutaka Kawamura
dce86e065b
Make unused variable pattern configurable ( #265 )
2022-09-24 10:43:39 -04:00
Harutaka Kawamura
d77979429c
Print warning and error messages in stderr ( #267 )
2022-09-24 09:27:35 -04:00
Adrian Garcia Badaracco
a3a15d2eb2
error invalid pyproject.toml configs ( #264 )
2022-09-23 21:16:07 -04:00
Charlie Marsh
5af95428ff
Tweak import
2022-09-23 18:53:57 -04:00
Harutaka Kawamura
6338cad4e6
Remove python 3.6 classifier ( #260 )
2022-09-22 20:38:09 -04:00
Harutaka Kawamura
485881877f
Include error code and message in JSON output ( #259 )
2022-09-22 20:29:21 -04:00
Charlie Marsh
b8f517c70e
Bump version to 0.0.45
2022-09-22 14:11:09 -04:00
Charlie Marsh
9f601c2abd
Document noqa workflows
2022-09-22 14:10:02 -04:00
Charlie Marsh
c0ce0b0c48
Enable automatic noqa insertion ( #256 )
2022-09-22 13:59:06 -04:00
Charlie Marsh
e5b16973a9
Enable autofix for M001 ( #255 )
2022-09-22 13:21:03 -04:00
Charlie Marsh
de9ceb2fe1
Only enforce multi-line noqa directives for strings ( #258 )
2022-09-22 13:09:02 -04:00
Charlie Marsh
38b19b78b7
Enable noqa directives on logical lines ( #257 )
2022-09-22 12:56:15 -04:00
Charlie Marsh
7043e15b57
Move noqa to a separate module
2022-09-22 09:04:54 -04:00
Charlie Marsh
9594079235
Add --extend-select and --extend-ignore ( #254 )
2022-09-21 19:56:43 -04:00
Charlie Marsh
732f208e47
Add a lint rule to enforce noqa validity ( #253 )
2022-09-21 19:56:38 -04:00
Charlie Marsh
32e62d9209
Use specific version tags
2022-09-21 15:11:53 -04:00
Charlie Marsh
d9e4b0cdc1
Implement --show-settings and --show-files ( #246 )
2022-09-21 15:08:50 -04:00
Charlie Marsh
36fcfad56a
Remove empty comment
2022-09-21 13:44:49 -04:00
Charlie Marsh
65d29d9734
Adjust line numbers when reporting rules in f-strings ( #244 )
2022-09-21 13:42:58 -04:00
Charlie Marsh
1e171ce0e8
Bump version to 0.0.44
2022-09-21 12:25:14 -04:00
Charlie Marsh
2bdc500c61
Re-run cargo insta
2022-09-21 12:24:46 -04:00
Charlie Marsh
f453e429b6
Add a note on parity
2022-09-21 12:24:04 -04:00
Charlie Marsh
73874f4788
Remove proof-of-concept caveat
2022-09-21 12:18:01 -04:00
Charlie Marsh
8846dcdf6a
Update README
2022-09-21 12:17:41 -04:00
Charlie Marsh
d827e6e36a
Implement F405 ( #243 )
2022-09-21 12:13:40 -04:00
Harutaka Kawamura
71d9b2ac5f
Implement F402 ( #221 )
2022-09-21 11:12:55 -04:00
Anders Kaseorg
401b53cc45
Handle filesystem errors more consistently ( #240 )
2022-09-20 23:22:01 -04:00
Anders Kaseorg
aa9c1e255c
Simplify check_path type ( #239 )
2022-09-20 21:11:42 -04:00
Anders Kaseorg
f7fc702b2c
Include specified files, even if they lack a .py[i] extension ( #238 )
2022-09-20 20:53:52 -04:00
Anders Kaseorg
50ca0d7d0a
Correctly display the location of parse errors ( #237 )
2022-09-20 20:53:22 -04:00
Anders Kaseorg
65e0284698
Suppress “Found 0 error(s)” message ( #236 )
2022-09-20 19:32:39 -04:00
Charlie Marsh
e4f571ea61
Bump version to 0.0.43
2022-09-20 12:26:49 -04:00
Charlie Marsh
4ed88dd245
Follow-up fixes to path absolution ( #235 )
2022-09-20 12:26:32 -04:00
Charlie Marsh
09b926fd59
Optimize imports
2022-09-20 09:10:39 -04:00
Charlie Marsh
a4869e4974
Update benchmark in README
2022-09-20 07:06:12 -06:00
Charlie Marsh
f53c4fc221
Bump version to 0.0.42
2022-09-19 21:14:17 -06:00
Charlie Marsh
3892a49a97
Bump version to 0.0.41
2022-09-19 21:09:33 -06:00
Charlie Marsh
27cc7e236c
Use a separate repo for pre-commit ( #229 )
2022-09-19 21:06:39 -06:00
Charlie Marsh
fa0954fe47
Treat relative excludes as relative to project root ( #228 )
2022-09-19 20:45:02 -06:00
Charlie Marsh
a0b50d7ebc
Use absolute paths for exclusion matching ( #213 )
2022-09-19 20:32:31 -06:00
Charlie Marsh
afe7a04211
Ignore F841 violations when locals() is in scope ( #226 )
2022-09-19 20:13:55 -06:00
Charlie Marsh
14806c62ca
Reduce number of sites for new check definitions ( #227 )
2022-09-19 20:13:46 -06:00
Suguru Yamamoto
0d0c8730fa
fix: Use UTF-32 char count for line length ( #223 ) ( #224 )
2022-09-18 10:45:41 -06:00
Harutaka Kawamura
cf6a23b83c
Add --version flag ( #222 )
2022-09-18 09:15:15 -06:00
Anders Kaseorg
9e0daac561
Enable F404 by default ( #219 )
2022-09-18 09:13:23 -06:00
Anders Kaseorg
f2fd7335ce
Use a platform-appropriate location for user configuration ( #215 )
2022-09-17 13:29:17 -06:00
Anders Kaseorg
b8f878df5e
Find user configuration even if there’s no project directory ( #216 )
2022-09-16 21:47:15 -06:00
Anders Kaseorg
9bdb922c75
Detect multi-target assignment as unpacking if *any* target is unpacking ( #217 )
2022-09-16 21:45:44 -06:00
Anders Kaseorg
edecc1bba6
Fix find_project_root with relative paths ( #214 )
2022-09-16 18:04:35 -06:00
Charlie Marsh
8e903153f6
Update README to include more badges
2022-09-16 12:18:03 -06:00
Charlie Marsh
3937885f37
Bump version to 0.0.40
2022-09-16 04:57:21 -04:00
Charlie Marsh
24de97d951
Create cache directory prior to writing .gitignore
2022-09-16 04:56:58 -04:00
Charlie Marsh
06e5b3e457
Bump version to 0.0.39
2022-09-15 21:41:14 -04:00
Charlie Marsh
68a0e6dc19
Remove erroneous test dir
2022-09-15 21:41:00 -04:00
Charlie Marsh
9d4a4478f7
Improve exclusion syntax to match exact files ( #209 )
2022-09-15 21:40:49 -04:00
Charlie Marsh
6bbf3f46c4
Add .gitignore to .ruff_cache ( #208 )
2022-09-15 20:40:06 -04:00
Charlie Marsh
4ac4e8c991
Exclude .ruff_cache by default ( #207 )
2022-09-15 20:39:39 -04:00
Dmitry Dygalo
0091a3ae5f
chore: Do not read the same file twice ( #206 )
2022-09-15 16:05:29 -04:00
Patrick Haller
17b3109a8b
Update docs with --format flag ( #205 )
2022-09-15 16:04:07 -04:00
Charlie Marsh
71520213c1
Allow __path__ in __init__.py ( #201 )
2022-09-15 09:44:03 -04:00
Charlie Marsh
f24e7a0052
Add trailing period to help message
2022-09-15 09:43:51 -04:00
Patrick Haller
507e9f7ec3
Fix: Structured output Issue Fix ( #186 )
2022-09-15 09:43:10 -04:00
Charlie Marsh
592c53c8bf
Use binding location when reporting F821 errors ( #200 )
2022-09-14 22:51:07 -04:00
Charlie Marsh
a2df89dedd
Bump version to 0.0.38
2022-09-14 22:38:42 -04:00
Charlie Marsh
b8f12d2e79
Raise error when failing to parse ( #199 )
2022-09-14 22:37:55 -04:00
Charlie Marsh
67b1d0463a
Pull in pycodestyle tests for E checks ( #195 )
2022-09-14 22:22:53 -04:00
Charlie Marsh
d008a181ec
Improve default exclusions and support extend-exclude ( #188 )
2022-09-14 22:21:17 -04:00
Charlie Marsh
6d612a428a
Migrate linter tests to insta ( #194 )
2022-09-14 21:52:44 -04:00
Charlie Marsh
c0cb73ab16
Implement E721 ( #193 )
2022-09-14 21:10:29 -04:00
Charlie Marsh
2e1eb84cbf
Implement F632 ( #190 )
2022-09-14 18:22:35 -04:00
Charlie Marsh
b03a8728b5
Add support for from __future__ import annotations ( #189 )
2022-09-14 18:22:19 -04:00
Charlie Marsh
1dd3350a30
Revert "Adding flag and logic for different output format" ( #187 )
2022-09-14 14:20:02 -04:00
Patrick Haller
bda34945a5
Adding flag and logic for different output format ( #185 )
2022-09-14 10:43:32 -04:00
Dmitry Dygalo
85dcaa8d3c
chore: Avoid collect in inner_main ( #184 )
2022-09-14 08:16:04 -04:00
Charlie Marsh
4ac74ed0ad
Revert erroneous pyproject.toml changes
2022-09-14 08:14:26 -04:00
Dmitry Dygalo
b7e2a4b9a9
feat: Implement InvalidPrintSyntax (F633) ( #182 )
2022-09-13 21:10:20 -04:00
Dmitry Dygalo
53a7758248
Avoid some allocations ( #179 )
2022-09-13 10:07:22 -04:00
Dmitry Dygalo
2ba767957d
refactor: Use while let Some instead of calling is_empty ( #180 )
2022-09-13 10:06:49 -04:00
Dmitry Dygalo
08152787e1
chore: Use once_cell instead of lazy_static ( #178 )
2022-09-13 10:06:21 -04:00