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