Commit Graph

1267 Commits

Author SHA1 Message Date
Charlie Marsh 5370968839
Add some additional users and alphabetize (#3882) 2023-04-05 02:40:02 +00:00
Charlie Marsh 255b094b33
Bump version to 0.0.261 (#3881) 2023-04-04 22:31:01 -04:00
Charlie Marsh 251340a246
Add LangChain and LlamaIndex (#3879) 2023-04-04 19:36:31 +00:00
brucearctor e006b922a6
Add documentation for `ruff-action` (GitHub Action!) (#3857) 2023-04-03 23:47:26 +00:00
Nicolas Vuillamy b52cb93e58
Add thank you in README.md + usage in MegaLinter (#3848) 2023-04-03 15:45:25 +00:00
Madison Swain-Bowden a142d71e0b
Add Openverse to users of ruff in README (#3806) 2023-03-30 09:14:47 -04:00
Charlie Marsh 9d3b8eb67b
Bump version to v0.0.260 (#3799) 2023-03-29 14:51:50 -04:00
Charlie Marsh 5977862a60
Enumerate all codes in default configuration example (#3790) 2023-03-28 23:36:22 +00:00
Leiser Fernández Gallo 224e85c6d7
Implement `flake8-gettext` (#3785) 2023-03-28 23:32:02 +00:00
Charlie Marsh c3917eab38
Revert "Implement `flake8-i18n` (#3741)" (#3765) 2023-03-27 21:14:38 +00:00
Leiser Fernández Gallo 5cb120327c
Implement `flake8-i18n` (#3741) 2023-03-27 18:03:39 +00:00
Charlie Marsh f58345dee3
Bump version to v0.0.259 (#3691) 2023-03-23 14:52:42 -04:00
Charlie Marsh 615887a7fe
Bump version to v0.0.258 (#3671) 2023-03-22 15:02:57 -04:00
Charlie Marsh 1e45b13958
Remove linked issue from `flake8-django` (#3664) 2023-03-22 03:26:22 +00:00
James Greenhill b06ca25421
Add PostHog to users of Ruff in README (#3641) 2023-03-21 10:05:35 -04:00
Charlie Marsh 621e4353e3
Re-add the list of supported plugins to the README (#3592) 2023-03-17 23:33:37 -04:00
Charlie Marsh 0c4926ff7b
Bump version to v0.0.257 (#3591) 2023-03-17 22:34:10 -04:00
Charlie Marsh 667130a4c3
Add some additional users to the users list (#3565) 2023-03-16 23:32:17 +00:00
Nyakku Shigure 72febf98b7
add PaddlePaddle to `Who's Using Ruff?` (#3562) 2023-03-16 14:20:11 -04:00
Charlie Marsh 12dfd57211
Bump version to v0.0.256 (#3531) 2023-03-14 22:52:21 -04:00
Charlie Marsh aa97a092bd
Bump version to v0.0.255 (#3485) 2023-03-13 14:06:51 -04:00
Charlie Marsh cd192eddf9
Add some new users to the README (#3471) 2023-03-13 00:08:58 +00:00
Charlie Marsh bbbc44336e
Bump version to 0.0.254 (#3331) 2023-03-03 19:11:07 -05:00
Charlie Marsh 8066607ea3
Add a preliminary tutorial (#3281) 2023-02-28 20:31:27 +00:00
Jonathan Plasse d285f5c90a
Run automatically format code blocks with Black (#3191) 2023-02-27 10:14:05 -05:00
Charlie Marsh 386ca7c9a1
Bump version to 0.0.253 (#3245) 2023-02-26 23:10:04 -05:00
Charlie Marsh 36d134fd41
Bump lint rule count to 500+ (#3240) 2023-02-26 18:10:09 -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
Jonathan Plasse 6e54cd8233
Normalize relative markdown links (#3190) 2023-02-23 16:24:31 -05:00
Charlie Marsh 74e18b6cff
Split up some docs sections (#3154) 2023-02-22 20:18:10 -05:00
Charlie Marsh b9bfb81e36
Move configuration out of README and into permanent docs (#3150) 2023-02-22 19:25:53 -05:00
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
Marijn Valk 7d55b417f7
add delta-rs to list of users (#3133) 2023-02-22 13:07:58 -05:00
Charlie Marsh fd638a2e54
Bump version to 0.0.251 (#3105) 2023-02-21 18:13:59 -05:00
Charlie Marsh 06e426f509
Bump version to 0.0.250 (#3095) 2023-02-21 15:20:46 -05:00
Charlie Marsh 37df07d2e0
Re-add compatibility to README (#3091) 2023-02-21 18:57:47 +00:00
Charlie Marsh 4cfa350112
Bump version to 0.0.249 (#3063) 2023-02-20 13:11:29 -05:00
Matthew Lloyd 3ad257cfea
Add PDM to "Who's Using Ruff?" (#3048) 2023-02-20 03:58:22 +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
Simon Brugman cfa6883431
docs(readme): add Diffusers (#3029) 2023-02-19 07:10:02 -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
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 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
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
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
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
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 39fdc71b49
Bump version to 0.0.247 (#2932) 2023-02-15 12:06:58 -05:00
Sawbez 9168a12679
[docs] `flake8-self` Private member access docs (#2912) 2023-02-15 15:42:38 +00: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 23d9309111
Remove JetBrains webinar badge (#2910) 2023-02-15 03:28:12 +00: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
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
Simon Legner 2d95912699
docs: fix `ruff generate-shell-completion` (#2904) 2023-02-14 22:38:29 +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
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
Sawbez 53e810ed3e
[docs] Add docs for the entirety of `flake8-builtins` (#2840) 2023-02-14 04:30:30 +00:00
Charlie Marsh 6d1adc85fc
Remove autofix for prefer-type-error (#2880) 2023-02-14 02:26:22 +00:00
Martin Fischer 8120d7c974 Change rule page links in README from GitHub to beta.ruff.rs 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 3c03e2cb2e
Rename flake8-django rules to match convention (#2861) 2023-02-13 15:30:04 +00:00
Charlie Marsh 6128346b08
Re-show --target-version on CLI interface (#2859) 2023-02-13 15:04:11 +00:00
Ville Skyttä d1cf0ee52b
Remove "blanket" from RUF100 README message (#2844) 2023-02-13 14:43:35 +00:00
Charlie Marsh 63f3d5e610
Update pre-commit instructions (#2838) 2023-02-13 00:06:40 +00:00
Charlie Marsh 83f6e52c92
Bump version to 0.0.246 (#2834) 2023-02-12 23:39:51 +00:00
Charlie Marsh 8b35b052b8
Avoid duplicates in if-with-same-arms (#2827) 2023-02-12 22:22:19 +00: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
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
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
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 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
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
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 19fc410683
Remove raw string from hardcoded-sql-expression (#2780) 2023-02-11 20:05:57 +00:00
Charlie Marsh 97dcb738fa Run cargo dev generate-all 2023-02-11 12:43:48 -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
Charlie Marsh 24faabf1f4 Bump version to 0.0.245 2023-02-10 22:15:27 -05:00
Simon Brugman e83ed0ecba
Implement autofix for relative imports (TID252) (#2739) 2023-02-10 22:05:47 -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 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 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
Florian Best 8aab96fb9e
feat(isort): Implement known-local-folder (#2657) 2023-02-10 13:15: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
Colin Delahunty 48daa0f0ca
[`pylint`]: bad-string-format-type (#2572) 2023-02-09 20:08:56 -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
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 7d5fb0de8a
Add documentation for mccabe, isort, and flake8-annotations (#2691) 2023-02-09 11:56:18 -05:00
Charlie Marsh 54d1719424
Hide rule configuration settings on CLI (#2687) 2023-02-09 11:13:04 -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 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 75fad989f4
Add `--exit-non-zero-on-fix` (#2668) 2023-02-08 14:27:54 -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 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 271e4fda8c
Create per-rule pages and link from README (#2644) 2023-02-07 18:15:05 -05:00
Charlie Marsh be08384fb0 Run cargo dev generate-all 2023-02-07 16:48:06 -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
Colin Delahunty 7647cafe12
[`pylint`]: bidirectional-unicode (#2589) 2023-02-06 22:49:18 -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 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
Colin Delahunty 6272293180
[`pylint`]: bad-str-strip-call (With Autofix) (#2570) 2023-02-06 15:34:37 -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
Colin Delahunty 1e1dc3a7ed
[`pyupgrade`]: Removes quotes from annotations (#2431) 2023-02-05 09:43:09 -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 7d4f0a8320 Bump Ruff version to 0.0.241 2023-02-03 19:25:12 -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 b9c1a3c5c1
Move benchmarking instructions to CONTRIBUTING.md (#2554) 2023-02-03 14:53:53 -05:00
Aarni Koskela 38addbe50d
Soft-deprecate update_check (#2530) 2023-02-03 11:33:38 -05:00
Jacob Coffee 04ef674195
Add Jetbrains Webinar Event (Temporary) (#2516) 2023-02-03 08:08:27 -05:00
Florian Best 7e9b9cc7b3
feat: add autofix for PLR0402 (#2504) 2023-02-02 23:25:16 -05:00
Jonathan Plasse bdcab87d2f
Add `markdownlint` and dev Ruff to `pre-commit` (#2303) 2023-02-02 16:29:07 -05:00
Charlie Marsh 651f6b6bce Bump Ruff version to 0.0.240 2023-02-02 12:45:23 -05:00
Charlie Marsh 668860cba3 Add more information to Pylint FAQ section 2023-02-02 11:08:17 -05:00
Chris Chan 8136cc9238
Implement pylint's `too-many-statements` rule (`PLR0915`) (#2445) 2023-02-02 08:18:37 -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
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 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
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 c15595325c Bump version to 0.0.239 2023-01-31 19:06:22 -05:00
Maksudul Haque 7c1a6bce7b
[`flake8-raise`] Add Plugin and `RSE102` Rule (#2354) 2023-01-31 18:09:40 -05:00
Thomas M Kehrenberg c3a3195922
Fix option name "max-args" in the documentation (#2401) 2023-01-31 12:30:05 -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
Erik Welch adc134ced0
Fix typos: s/scripy/scipy/g (#2380) 2023-01-31 07:17:18 -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 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 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 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
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
Akhil 8e5a944ce1
Implement Pylint's `too-many-arguments` rule (`PLR0913`) (#2308) 2023-01-30 07:34:37 -05:00
Simon Brugman 2ef28f217c pandas vet autofix for PD002 and general refactor 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
Charlie Marsh 3ee6a90905
Remove remove-six-compat (UP016) (#2332) 2023-01-29 21:19:59 -05:00
Simon Brugman 5165b703d9
Add VS Code to gitignore; fix typos (#2333) 2023-01-29 21:14:38 -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 546413defb Fix remaining RelativeImportsOrder typo 2023-01-29 11:33:12 -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
Charlie Marsh add7fefeb5 Bump version to 0.0.237 2023-01-28 10:52:14 -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
Matt Morris caada2f8bb
add missing backticks to flake8 plugin urls in `README` (#2291) 2023-01-28 07:16:23 -05:00
Charlie Marsh fd56414b2f Re-add ALL disclaimer 2023-01-27 22:18:20 -05:00
Charlie Marsh 1a0191f1ac Add release to breaking changes 2023-01-27 20:34:24 -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
Samuel Cormier-Iijima dd15c69181
[`flake8-bandit`] Add Rule S110 (try/except/pass) (#2197) 2023-01-27 18:52:55 -05:00
Charlie Marsh df44c5124e Add missing autofix levels to sometimes-fixable rules 2023-01-27 18:25:23 -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ä 221b87332c
feat: add more DTZ fix suggestions in messages (#2274) 2023-01-27 18:14:17 -05:00
Simon Brugman 94551a203e
feat: pylint `PLE0604` and `PLE0605` (#2241) 2023-01-27 11:26:33 -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 615e62ae24
Clarify E-category rule support (#2239) 2023-01-26 18:12:28 -05:00
Simon Brugman 8766e6a666
docs(readme): add featuretools (#2236) 2023-01-26 17:24:45 -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 5f8810e987
Add strictness setting for `flake8-typing-imports` (#2221) 2023-01-26 16:04:21 -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
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
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
Charlie Marsh b346f74915
Run cargo update (#2185) 2023-01-25 21:32:44 -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
Charlie Marsh edd0e16a02 Bump version to 0.0.235 2023-01-25 18:28:27 -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 35cf9e242e
Rename TYP rules to TYC (#2175) 2023-01-25 16:26:22 -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 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 6978dcf035
Add an FAQ on autofix (#2163) 2023-01-25 13:09:16 -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 605416922d Bump version to 0.0.233 2023-01-24 10:46:49 -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
Ville Skyttä 7e92485f43
feat: autofix `multi-line-summary-*-line` (#2093) 2023-01-24 08:17:13 -05:00
Edgar R. M f5f0ed280a
Implement `EXE001` and `EXE002` from `flake8-executable` (#2118) 2023-01-24 08:02:47 -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
Denis Gavrilyuk d65ce6308b
feat: implement TRY200 (#2087)
#2056
2023-01-23 14:12:42 -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
Simon Brugman f472fbc6d4
docs(readme): add pypa cibuildwheel (#2107) 2023-01-23 11:39:23 -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 f40ae943a7 Fix bad documentation message for init option 2023-01-22 19:25:23 -05:00
alm 4fb0c6e3ad
feat: Implement TRY201 (#2073) 2023-01-22 17:08:57 -05:00
Simon Brugman 11f06055a0
feat: flake8-use-pathlib PTH100-124 (#2090) 2023-01-22 15:17:25 -05:00
Charlie Marsh 23b622943e Bump version to 0.0.230 2023-01-22 13:58:41 -05:00
alm e11cf1bf65
Update linters PyPI links to latest version (#2062) 2023-01-22 13:10:22 -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
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
Cosmo 39aed6f11d
Update link to Pylint parity tracking issue (#2074) 2023-01-21 17:46:55 -05:00
Simon Brugman 67de8ac85e
feat: implementation for TRY004 (#2066)
See: #2056.
2023-01-21 14:58:59 -05:00
Charlie Marsh 84300e00ff Bump version to 0.0.229 2023-01-21 13:18:06 -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
Colin Delahunty 80295f335b
Pyupgrade: Printf string formatting (#1803) 2023-01-21 09:37:22 -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 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
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
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 5377d24507 Bump version to 0.0.228 2023-01-20 09:58:56 -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
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
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
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
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
Charlie Marsh d8645acd1f Bump version to 0.0.226 2023-01-18 20:54:38 -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 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