Commit Graph
57 Commits
Author SHA1 Message Date
Brent Westbrook d936a5566e Rename 17 rules for source layout, imports, and directives (#30477)
| Code | Old name | New name |
|---|---|---|
| [`COM819`](https://docs.astral.sh/ruff/rules/COM819/) |
`prohibited-trailing-comma` | `unnecessary-trailing-comma` |
| [`E301`](https://docs.astral.sh/ruff/rules/E301/) |
`blank-line-between-methods` | `missing-blank-line-before-method` |
| [`E302`](https://docs.astral.sh/ruff/rules/E302/) |
`blank-lines-top-level` |
`missing-blank-lines-before-top-level-definition` |
| [`E305`](https://docs.astral.sh/ruff/rules/E305/) |
`blank-lines-after-function-or-class` |
`missing-blank-lines-after-top-level-definition` |
| [`E306`](https://docs.astral.sh/ruff/rules/E306/) |
`blank-lines-before-nested-definition` |
`missing-blank-line-before-nested-definition` |
| [`EXE001`](https://docs.astral.sh/ruff/rules/EXE001/) |
`shebang-not-executable` | `non-executable-file-with-shebang` |
| [`EXE002`](https://docs.astral.sh/ruff/rules/EXE002/) |
`shebang-missing-executable-file` | `executable-file-without-shebang` |
| [`F403`](https://docs.astral.sh/ruff/rules/F403/) |
`undefined-local-with-import-star` | `star-import` |
| [`F405`](https://docs.astral.sh/ruff/rules/F405/) |
`undefined-local-with-import-star-usage` |
`possibly-undefined-name-with-star-import` |
| [`F406`](https://docs.astral.sh/ruff/rules/F406/) |
`undefined-local-with-nested-import-star-usage` |
`non-module-level-star-import` |
| [`PLE2510`](https://docs.astral.sh/ruff/rules/PLE2510/) |
`invalid-character-backspace` | `unescaped-backspace-character` |
| [`PLE2512`](https://docs.astral.sh/ruff/rules/PLE2512/) |
`invalid-character-sub` | `unescaped-substitute-character` |
| [`PLE2513`](https://docs.astral.sh/ruff/rules/PLE2513/) |
`invalid-character-esc` | `unescaped-escape-character` |
| [`PLE2514`](https://docs.astral.sh/ruff/rules/PLE2514/) |
`invalid-character-nul` | `unescaped-null-character` |
| [`PLE2515`](https://docs.astral.sh/ruff/rules/PLE2515/) |
`invalid-character-zero-width-space` |
`unescaped-zero-width-space-character` |
| [`RUF100`](https://docs.astral.sh/ruff/rules/RUF100/) | `unused-noqa`
| `unused-suppression-comment` |
| [`RUF101`](https://docs.astral.sh/ruff/rules/RUF101/) |
`redirected-noqa` | `renamed-rule-in-suppression-comment` |
2026-11-19 19:12:57 -05:00
Brent Westbrook af3adfd58b Rename 25 rules for definitions, naming, and typing (#30476)
| Code | Old name | New name |

|---------------------------------------------------------|------------------------------------------------|-----------------------------------------------------|
| [`FBT001`](https://docs.astral.sh/ruff/rules/FBT001/) |
`boolean-type-hint-positional-argument` |
`boolean-annotated-positional-parameter` |
| [`FBT002`](https://docs.astral.sh/ruff/rules/FBT002/) |
`boolean-default-value-positional-argument` |
`boolean-default-value-positional-parameter` |
| [`N801`](https://docs.astral.sh/ruff/rules/N801/) |
`invalid-class-name` | `non-camel-case-class-name` |
| [`N802`](https://docs.astral.sh/ruff/rules/N802/) |
`invalid-function-name` | `non-lowercase-function-name` |
| [`N803`](https://docs.astral.sh/ruff/rules/N803/) |
`invalid-argument-name` | `non-lowercase-parameter-name` |
| [`N804`](https://docs.astral.sh/ruff/rules/N804/) |
`invalid-first-argument-name-for-class-method` |
`class-method-receiver-not-named-cls` |
| [`N805`](https://docs.astral.sh/ruff/rules/N805/) |
`invalid-first-argument-name-for-method` |
`instance-method-receiver-not-named-self` |
| [`N813`](https://docs.astral.sh/ruff/rules/N813/) |
`camelcase-imported-as-lowercase` | `camel-case-imported-as-lowercase` |
| [`N814`](https://docs.astral.sh/ruff/rules/N814/) |
`camelcase-imported-as-constant` | `camel-case-imported-as-constant` |
| [`N817`](https://docs.astral.sh/ruff/rules/N817/) |
`camelcase-imported-as-acronym` | `camel-case-imported-as-acronym` |
| [`N818`](https://docs.astral.sh/ruff/rules/N818/) |
`error-suffix-on-exception-name` |
`exception-class-without-error-suffix` |
| [`PLR0202`](https://docs.astral.sh/ruff/rules/PLR0202/) |
`no-classmethod-decorator` | `non-decorator-classmethod` |
| [`PLR0203`](https://docs.astral.sh/ruff/rules/PLR0203/) |
`no-staticmethod-decorator` | `non-decorator-staticmethod` |
| [`PLR6301`](https://docs.astral.sh/ruff/rules/PLR6301/) |
`no-self-use` | `unused-self` |
| [`PYI011`](https://docs.astral.sh/ruff/rules/PYI011/) |
`typed-argument-default-in-stub` |
`complex-default-for-annotated-parameter-in-stub` |
| [`PYI014`](https://docs.astral.sh/ruff/rules/PYI014/) |
`argument-default-in-stub` |
`complex-default-for-unannotated-parameter-in-stub` |
| [`PYI026`](https://docs.astral.sh/ruff/rules/PYI026/) |
`type-alias-without-annotation` | `unannotated-type-alias-in-stub` |
| [`PYI050`](https://docs.astral.sh/ruff/rules/PYI050/) |
`no-return-argument-annotation-in-stub` |
`parameter-annotated-with-no-return` |
| [`PYI051`](https://docs.astral.sh/ruff/rules/PYI051/) |
`redundant-literal-union` | `literal-union-with-supertype` |
| [`PYI057`](https://docs.astral.sh/ruff/rules/PYI057/) |
`byte-string-usage` | `deprecated-byte-string-type` |
| [`PYI058`](https://docs.astral.sh/ruff/rules/PYI058/) |
`generator-return-from-iter-method` |
`iter-method-with-generator-return-annotation` |
| [`TC006`](https://docs.astral.sh/ruff/rules/TC006/) |
`runtime-cast-value` | `cast-with-unquoted-type` |
| [`UP013`](https://docs.astral.sh/ruff/rules/UP013/) |
`convert-typed-dict-functional-to-class` | `functional-typed-dict` |
| [`UP014`](https://docs.astral.sh/ruff/rules/UP014/) |
`convert-named-tuple-functional-to-class` | `functional-named-tuple` |
| [`UP042`](https://docs.astral.sh/ruff/rules/UP042/) |
`replace-str-enum` | `manual-str-enum` |
2026-11-19 15:07:50 -05:00
Brent Westbrook b444480b79 Rename 20 pydocstyle rules (#30465)
Summary
--

This is the first in a series of rule rename PRs. I started here because
the renames are fairly straightforward and are within a single linter
group. Most of these rules were missing some mention of docstrings in
their names or were missing or misusing something like `missing` or
`incorrect`. For example, many of the rules that start with `missing-`
actually enforce a single line somewhere, so they flag 2+ lines as well
as zero.

The first commit contains the changes in `codes.rs`, which I thought was
probably easiest to review
and comment on if any of the names need further refinement. The second
commit contains the rest of
the downstream changes.

| Code | Old name | New name |

|---------------------------------------------------|-----------------------------------------|---------------------------------------------------|
| [`D201`](https://docs.astral.sh/ruff/rules/D201/) |
`blank-line-before-function` | `blank-line-before-function-docstring` |
| [`D202`](https://docs.astral.sh/ruff/rules/D202/) |
`blank-line-after-function` | `blank-line-after-function-docstring` |
| [`D203`](https://docs.astral.sh/ruff/rules/D203/) |
`incorrect-blank-line-before-class` |
`incorrect-blank-line-before-class-docstring` |
| [`D204`](https://docs.astral.sh/ruff/rules/D204/) |
`incorrect-blank-line-after-class` |
`incorrect-blank-line-after-class-docstring` |
| [`D205`](https://docs.astral.sh/ruff/rules/D205/) |
`missing-blank-line-after-summary` |
`incorrect-blank-line-after-docstring-summary` |
| [`D207`](https://docs.astral.sh/ruff/rules/D207/) |
`under-indentation` | `under-indented-docstring-line` |
| [`D208`](https://docs.astral.sh/ruff/rules/D208/) | `over-indentation`
| `over-indented-docstring-line` |
| [`D209`](https://docs.astral.sh/ruff/rules/D209/) |
`new-line-after-last-paragraph` |
`missing-new-line-after-last-docstring-paragraph` |
| [`D210`](https://docs.astral.sh/ruff/rules/D210/) |
`surrounding-whitespace` | `whitespace-around-docstring-text` |
| [`D211`](https://docs.astral.sh/ruff/rules/D211/) |
`blank-line-before-class` | `blank-line-before-class-docstring` |
| [`D212`](https://docs.astral.sh/ruff/rules/D212/) |
`multi-line-summary-first-line` |
`multiline-docstring-summary-on-separate-line` |
| [`D213`](https://docs.astral.sh/ruff/rules/D213/) |
`multi-line-summary-second-line` |
`multiline-docstring-summary-on-first-line` |
| [`D214`](https://docs.astral.sh/ruff/rules/D214/) |
`overindented-section` | `over-indented-docstring-section` |
| [`D215`](https://docs.astral.sh/ruff/rules/D215/) |
`overindented-section-underline` |
`over-indented-docstring-section-underline` |
| [`D300`](https://docs.astral.sh/ruff/rules/D300/) |
`triple-single-quotes` | `unconventional-docstring-quotes` |
| [`D408`](https://docs.astral.sh/ruff/rules/D408/) |
`missing-section-underline-after-name` |
`blank-line-before-docstring-section-underline` |
| [`D410`](https://docs.astral.sh/ruff/rules/D410/) |
`no-blank-line-after-section` |
`missing-blank-line-after-docstring-section` |
| [`D411`](https://docs.astral.sh/ruff/rules/D411/) |
`no-blank-line-before-section` |
`missing-blank-line-before-docstring-section` |
| [`D413`](https://docs.astral.sh/ruff/rules/D413/) |
`missing-blank-line-after-last-section` |
`missing-blank-line-after-last-docstring-section` |
| [`D417`](https://docs.astral.sh/ruff/rules/D417/) |
`undocumented-param` | `undocumented-parameter` |
2026-11-19 11:59:53 -05:00
Micha ReiserandAlex Waygood 0222c19dd8 Share ty configuration for Ruff’s standalone scripts (#30463)
## Summary

Use a shared ty override for Ruff’s standalone scripts now that PEP 723
scripts can inherit project settings. Fix the diagnostics in the two PR
automation scripts so they can use the same checks.

## Notes to reviewers

All 28 standalone scripts passed ty with locked dependencies, and the
changed-file hooks and mocked workflow checks passed.

---------

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2026-11-16 17:35:08 +00:00
Alex WaygoodandMicha Reiser 22e77392fb [ty] Split invalid-return-type into 3 focussed rules; rename empty-body and unsound-return (#29947)
Co-authored-by: Micha Reiser <micha@reiser.io>
2026-11-11 16:59:57 +00:00
David Peter c64734bcea [ty] Enable return type inference in scripts and tools (#29439)
## Summary

Enable return type inference for all 24 standalone Python scripts
checked by ty in CI, along with `py-fuzzer` and `ty_benchmark`.
2026-10-16 12:41:30 +00:00
Zanie Blueandzaniebot c79af46103 Require hashes for build dependencies (#29336)
Enable `require-build-hashes` for the Python projects and inline scripts
so isolated builds require declared hashes for their build dependencies.
Pin the build backends and their dependencies with hashes.

---------

Co-authored-by: zaniebot <242828183+zaniebot@users.noreply.github.com>
2026-10-15 20:15:23 +01:00
David Peter de9071547c [ty] Enable None-union truthiness checks in Python scripts and tools (#28911)
## Summary

Enable `truthiness-test-of-none-union` in the standalone scripts' inline
configuration and in the `py-fuzzer` and `ty_benchmark` projects,
following #28889.
2026-09-28 11:47:03 +00:00
Alex Waygood cbb1cdc35e [ty] Dogfood more ty rules on our own scripts (#28387) 2026-09-07 10:04:25 +01:00
Brent Westbrook 947179d7c6 Enable lint.preview and missing default rules in our Ruff config (#28112)
Summary
--

This PR updates our ruff-pre-commit dependency to 0.16.5, which supports
the new category selectors,
and then enables `lint.preview` and the new default categories so that
we can dogfood them on our
code. There were 66 diagnostics initially, which I also fixed or
ignored:

```
28	FURB113 	[ ] repeated-append
12	ASYNC240	[ ] blocking-path-method-in-async-function
 6	RUF105  	[*] noqa-comments
 5	PLW1510 	[ ] subprocess-run-without-check
 3	PLW0108 	[ ] unnecessary-lambda
 2	EXE001  	[ ] shebang-not-executable
 2	RUF039  	[*] unraw-re-pattern
 1	B024    	[ ] abstract-base-class-without-abstract-method
 1	FURB142 	[*] for-loop-set-mutations
 1	PERF102 	[ ] incorrect-dict-iterator
 1	PLC0207 	[*] missing-maxsplit-arg
 1	PLW0127 	[ ] self-assigning-variable
 1	TRY004  	[ ] type-check-without-type-error
 1	PLW0120 	[*] useless-else-on-loop
 1	TRY201  	[ ] verbose-raise
 ```

Of these, I ignored `repeated-append` and `blocking-path-method-in-async-function`. I think they are
still reasonable defaults, just less useful/important in our uses.

0.16.5 also includes https://github.com/astral-sh/ruff-pre-commit/pull/159, so I removed `markdown` from our main `ruff-format` hook, leaving it for the later mdtest formatting stage.

I also had to make a few changes related to config discovery in tests:
- move our cached ecosystem checkouts to `$RUNNER_TEMP` instead of inside of our checkout
- convert some CLI tests to use the `CliTest` helpers
- add `configurationPreference: editorOnly` to some notebook tests

In these cases, our own Ruff settings were being inherited by test code. This likely affects many other tests, but I only updated the obviously failing ones for now. I'm least confident about the notebook tests, but as far as I can tell from the history (https://github.com/astral-sh/ruff/pull/11944, https://github.com/astral-sh/ruff/pull/22810), the specific diagnostics are not the important parts being asserted.

Test Plan
--

CI on this PR
2026-08-28 12:24:36 -04:00
Alex Waygood b33f21debe [ty] Dogfood standalone scripts with inline configuration (#27885) 2026-08-19 15:55:30 +01:00
zaniebotandzaniebot 6dd1fa88eb Require wheels for Python tooling dependencies (#27861)
Python tooling can currently build third-party source distributions. Set
`no-build` in the maintained Python projects and PEP 723 scripts,
retaining named exceptions for Git-pinned tooling and the local
ecosystem runner. Pin the isolated build dependencies for those
exceptions, including their transitive requirements.

Follows merged astral-sh/ruff#27856, which gives the legacy `ruff-lsp`
suite a dedicated, locked Python 3.12 test environment.

Follow-up to astral-sh/ruff#27843. Replaces astral-sh/ruff#27840, which
closed when the merged docs branch was deleted.

Co-authored-by: zaniebot <242828183+zaniebot@users.noreply.github.com>
2026-08-19 14:31:32 +00:00
William WoodruffandAlex Waygood 7ed8d1fbdd Manage docs build with a dep group (#27843)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Signed-off-by: William Woodruff <william@yossarian.net>
2026-08-18 20:56:20 +00:00
Charlie MarshandBrent Westbrook 41f8a525b3 Add a rule to flag lazy imports that are eagerly evaluated (#25016)
## Summary

This PR adds a new rule (`TID255`) to flag PEP 810 lazy imports that are
resolved immediately during module import execution.

For example:

```python
lazy import foo

class Bar(foo.Foo): ...
```

Here, `foo` is evaluated while the module is being loaded, so the import
is not meaningfully lazy.

We're also offering an unsafe fix to remove `lazy` when the import
statement imports a single member.

Closes https://github.com/astral-sh/ruff/issues/25014.

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
2026-05-06 20:48:23 +00:00
Charlie Marsh e46e458eae Allow users to ban lazy imports (#23847)
## Summary

This PR renames TID254 to `lazy-import-mismatch` and expands it into a
single rule with two complementary settings: `require-lazy` and
`ban-lazy`. Both settings accept `"all"`, `list[str]`, or `{ include =
..., exclude = [...] }`, and we validate that the two selectors don’t
overlap.

This covers the two main use-cases users asked for:

- Require lazy imports by default, except for known side-effectful
modules. Example:

  ```toml
  require-lazy = { include = "all", exclude = ["sitecustomize"] }
  ```
This enforces lazy imports everywhere Ruff can rewrite them, while
leaving sitecustomize eager.

- Forbid lazy imports for modules that must stay eager, or even forbid
lazy imports by default with a small allowlist.

  ```toml
  # Require `sitecustomize` to stay eager.
  ban-lazy = ["sitecustomize"]

  # Ban lazy imports everywhere except `typing`.
  ban-lazy = { include = "all", exclude = ["typing"] }
  ```
2026-03-10 14:27:53 -04:00
Charlie Marsh a76a6bf8b0 Use starred unpacking for RUF017 in Python 3.15+ (#23789)
## Summary

Closes https://github.com/astral-sh/ruff/issues/22230.
2026-03-09 19:15:27 +00:00
Charlie Marsh 2e227cdd5b Add a rule to enforce lazy imports (#23777)
## Summary

`TID254` enforces the use of `lazy` imports. You can specify a set of
modules, similar to `banned-module-level-imports`, or `"all"`:

```toml
# Require every module-level import to be lazy.
banned-eager-imports = "all"

# Require lazy imports for specific modules.
banned-eager-imports = [
    "boto3",
    "botocore",
]
```
2026-03-09 17:57:37 +00:00
GiGaGon d78d10dd94 [pycodestyle] Make example not raise unnecessary SyntaxError (E114) (#19190)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

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

Part of #18972

This PR makes [indentation-with-invalid-multiple-comment
(E114)](https://docs.astral.sh/ruff/rules/indentation-with-invalid-multiple-comment/#indentation-with-invalid-multiple-comment-e114)'s
example not raise a syntax error by adding a 4 space indented `...`. The
example still gave `E114` without this, but adding the `...` both makes
the change in indentation of the comment clearer, and makes it not give
a `SyntaxError`.

## Test Plan

<!-- How was it tested? -->

N/A, no functionality/tests affected
2025-07-08 10:00:14 -04:00
InSync 1db8392a5a Check for backtick-quoted shortcut links in CI (#16114)
## Summary

Follow-up to #16035.

`check_docs_formatted.py` will now report backtick-quoted shortcut links
in rule documentation. It uses a regular expression to find them. Such a
link:

* Starts with `[`, followed by <code>\`</code>, then a "name" sequence
of at least one non-backtick non-newline character, followed by another
<code>\`</code>, then ends with `]`.
* Is not followed by either a `[` or a `(`.
* Is not placed within a code block.

If the name is a known Ruff option name, that link is not considered a
violation.

## Test Plan

Manual.
2025-02-14 08:37:46 +01:00
InSync f367aa8367 [ruff] Indented form feeds (RUF054) (#16049)
## Summary

Resolves #12321.

The physical-line-based `RUF054` checks for form feed characters that
are preceded by only tabs and spaces, but not any other characters,
including form feeds.

## Test Plan

`cargo nextest run` and `cargo insta test`.
2025-02-09 19:23:48 -05:00
renovate[bot]andAlex Waygood c0259e7bf2 Update dependency ruff to v0.9.1 (#15432)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-01-11 17:18:38 +00:00
renovate[bot]andAlex Waygood 22edee2353 Update pre-commit dependencies (#15433)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2025-01-11 17:18:13 +00:00
Enoch Kan 5bc9d6d3aa Rename rules currently not conforming to naming convention (#15102)
## Summary

This pull request renames 19 rules which currently do not conform to
Ruff's [naming
convention](https://github.com/astral-sh/ruff/blob/main/CONTRIBUTING.md#rule-naming-convention).

## Description

Fixes astral-sh/ruff#15009.
2024-12-23 15:48:45 -06:00
Calum Young 2e75cfbfe7 Format PYI examples in docs as .pyi-file snippets (#13116) 2024-08-28 13:20:40 +01:00
Calum Young ab3648c4c5 Format docs with ruff formatter (#13087)
## Summary

Now that Ruff provides a formatter, there is no need to rely on Black to
check that the docs are formatted correctly in
`check_docs_formatted.py`. This PR swaps out Black for the Ruff
formatter and updates inconsistencies between the two.

This PR will be a precursor to another PR
([branch](https://github.com/calumy/ruff/tree/format-pyi-in-docs)),
updating the `check_docs_formatted.py` script to check for pyi files,
fixing #11568.

## Test Plan

- CI to check that the docs are formatted correctly using the updated
script.
2024-08-26 21:25:10 +05:30
Dhruv Manilawala c319414e54 Ignore blank line rules for docs formatting (#12934)
## Summary

fixes: #12933 

## Test Plan

`python scripts/check_docs_formatted.py --generate-docs`
2024-08-16 15:27:36 +00:00
Javier KauerandCharlie Marsh 1e07bfa373 [pycodestyle] Whitespace after decorator (E204) (#12140)
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
This is the implementation for the new rule of `pycodestyle (E204)`. It
follows the guidlines described in the contributing site, and as such it
has a new file named `whitespace_after_decorator.rs`, a new test file
called `E204.py`, and as such invokes the `function` in the `AST
statement checker` for functions and functions in classes. Linking #2402
because it has all the pycodestyle rules.

## Test Plan

<!-- How was it tested? -->
The file E204.py, has a `decorator` defined called wrapper, and this
decorator is used for 2 cases. The first one is when a `function` which
has a `decorator` is called in the file, and the second one is when
there is a `class` and 2 `methods` are defined for the `class` with a
`decorator` attached it.

Test file:

``` python
def foo(fun):
    def wrapper():
        print('before')
        fun()
        print('after')
    return wrapper

# No error
@foo
def bar():
    print('bar')

# E204
@ foo
def baz():
    print('baz')

class Test:
    # No error
    @foo
    def bar(self):
        print('bar')

    # E204
    @ foo
    def baz(self):
        print('baz')
```

I am still new to rust and any suggestion is appreciated. Specially with
the way im using native ruff utilities.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-07-04 23:31:03 +00:00
Charlie Marsh 24899efe50 Remove example from tab-indentation (#11462)
## Summary

I think the example is more confusing than helpful, since there's no
visual difference between the tab and space here (even if it rendered
properly).

Closes
https://github.com/astral-sh/ruff/issues/11460#issuecomment-2118397278.
2024-05-17 17:49:16 -04:00
Douglas Thor 0726e82342 [pyflakes] Update docs to describe WAI behavior (F541) (#11362)
Addresses this comment:
https://github.com/astral-sh/ruff/issues/11357#issuecomment-2104714029


## Summary

The docs for F541 did not mention some surprising, but WAI, behavior
regarding implicit string concatenation. Update the docs to describe the
behavior.

Here's how things rendered for me locally:


![image](https://github.com/astral-sh/ruff/assets/5386897/32067121-b190-4268-b987-ff37df11a618)
2024-05-10 19:10:34 +00:00
388658efdb Update pre-commit dependencies (#10698)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-04-06 23:00:41 +00:00
Auguste Lalande b117f33075 [pycodestyle] Implement blank-line-at-end-of-file (W391) (#10243)
## Summary

Implements the [blank line at end of
file](https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes)
rule (W391) from pycodestyle. Renamed to TooManyNewlinesAtEndOfFile for
clarity.

## Test Plan

New fixtures have been added

Part of #2402
2024-03-11 22:07:59 -04:00
Auguste Lalande c746912b9e [pycodestyle] Implement redundant-backslash (E502) (#10292)
## Summary

Implements the
[redundant-backslash](https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes)
rule (E502) from pycodestyle.

## Test Plan

New fixture has been added

Part of #2402
2024-03-11 21:15:06 -04:00
Hoël BagardandMicha Reiser 9027169125 [pycodestyle] Add blank line(s) rules (E301, E302, E303, E304, E305, E306) (#9266)
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-02-08 18:35:08 +00:00
Adrian 16060670b8 Add new rule to check for useless quote escapes (#8630)
When using the autofixer for `Q000` it does not remove the backslashes
from quotes that no longer need escaping.

This new rule checks for such backslashes (regardless whether they come
from the autofixer or not) and can remove them.

fixes #8617
2023-11-13 21:59:37 +00:00
Steve C 21ea290d6a [pylint] Implement PLR0916 (too-many-boolean-expressions) (#7975)
## Summary

Add
[R0916](https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/too-many-boolean-expressions.html),
no autofix available.

See: #970 

## Test Plan

`cargo test` and manually.
2023-10-17 04:44:25 +00:00
Tom Kuson dc51d03866 Fix documentation for no-return-argument-annotation-in-stub [PYI050] (#7708)
## Summary

The markdown documentation was present, but in the wrong place, so was
not displaying on the website. I moved it and added some references.

Related to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
2023-09-29 12:48:51 -04:00
Tom Kuson 36a60bd50e Add documentation to non-empty-stub-body (#7519)
## Summary

Add documentation to `non-empty-stub-body` (`PYI010`) rule. Related to
#2646.

## Test Plan

`python scripts/check_docs_formatted.py`
2023-09-19 13:21:11 -04:00
Tom Kuson 359f50e6dc Ignore pass-statement-stub-body documentation formatting (#7497)
## Summary

Fix CI (broken in #7496).

The code snippet was formatted as Black would format a stub file, but
the CI script doesn't know that (it assumes all code snippets are
non-stub files). Easier to ignore.

Sorry for breaking CI!

## Test Plan

`python scripts/check_docs_formatted.py`
2023-09-18 14:27:20 -04:00
Harutaka Kawamura 419615f29b Add docs for E275, E231, E251, and E252 (#6700) 2023-08-20 14:51:50 +00:00
Harutaka Kawamura c62e544cba Add doc for E999 (#6699) 2023-08-20 14:14:22 +00:00
Zanie Blue 718e3945e3 Add rule to upgrade type alias annotations to keyword (UP040) (#6289)
Adds rule to convert type aliases defined with annotations i.e. `x:
TypeAlias = int` to the new PEP-695 syntax e.g. `type x = int`.

Does not support using new generic syntax for type variables, will be
addressed in a follow-up.
Added as part of pyupgrade — ~the code 100 as chosen to avoid collision
with real pyupgrade codes~.

Part of #4617 
Builds on #5062
2023-08-03 16:13:06 +00:00
Aarni Koskela 3d54d31cd9 Implement E241 and E242 (tab/multiple ws after commas) (#6094)
## Summary

This PR implements pycodestyle's E241 (tab after comma) and E242
(multiple whitespace after comma) lints.

These are marked as nursery rules like many other pycodestyle rules.

Refs #2402

## Test Plan

E24.py copied from pycodestyle.
2023-07-27 18:58:41 +00:00
rembridge bb08eea5cc missing-whitespace-around-operators comment (#6106)
**Summary**

Updated doc comments for `missing_whitespace_around_operator.rs`. Online
docs also benefit from this update.

**Test Plan**

Checked docs via
[mkdocs](https://github.com/astral-sh/ruff/blob/389fe13c934fe73679474006412b1eded4a2cad0/CONTRIBUTING.md?plain=1#L267-L296)
2023-07-27 14:52:43 -04:00
konsti 2a65e6fc38 Explain check_docs_formatted.py error message (#6125)
## Summary

This is an error message only change to lead an implementor of a new
rule that has an unformatted or invalid bad example to the
right code.

## Test Plan

n/a
2023-07-27 10:22:13 -04:00
rembridge 132f07c27b whitespace-before-parameters comment (#6103) 2023-07-26 23:01:47 +00:00
rembridge 8c80bfa7da tab indentation comment (#6079)
## Summary

Updated doc comment for `tab_indentation.rs`. Online docs also benefit
from this update.

## Test Plan

Checked docs via
[mkdocs](https://github.com/astral-sh/ruff/blob/389fe13c934fe73679474006412b1eded4a2cad0/CONTRIBUTING.md?plain=1#L267-L296)
2023-07-25 23:14:43 +00:00
qdegraaf 93b2bd7184 [perflint] Add PERF401 and PERF402 rules (#5298)
## Summary

Adds `PERF401` and `PERF402` mirroring `W8401` and `W8402` from
https://github.com/tonybaloney/perflint

Implementation is not super smart but should be at parity with upstream
implementation judging by:
https://github.com/tonybaloney/perflint/blob/c07391c17671c3c9d5a7fd69120d1f570e268d58/perflint/comprehension_checker.py#L42-L73

It essentially checks:

- If the body of a for-loop is just one statement
- If that statement is an `if` and the if-statement contains a call to
`append()` we flag `PERF401` and suggest a list comprehension
- If that statement is a plain call to `append()` or `insert()` we flag
`PERF402` and suggest `list()` or `list.copy()`

I've set the violation to only flag the first append call in a long
`if-else` statement for `PERF401`. Happy to change this to some other
location or make it multiple violations if that makes more sense.

## Test Plan

Fixtures were added with the relevant scenarios for both rules

## Issue Links

Refers: https://github.com/astral-sh/ruff/issues/4789
2023-07-03 04:03:09 +00:00
Tom Kuson 035f8993f4 Complete documentation for pydocstyle rules (#5387)
## Summary

Completes the documentation for the `pydocstyle` ruleset. Related to
#2646.

## Test Plan

`python scripts/check_docs_formatted.py`
2023-06-27 18:12:21 +00:00
Tom Kuson fd0c3faa70 Add documentation to rules that check docstring quotes (D3XX) (#5351)
## Summary

Add documentation to the `D3XX` rules that check for issues with
docstring quotes. Related to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
2023-06-25 22:34:03 +00:00
Charlie Marsh f9f0cf7524 Use __future__ imports in scripts (#5301) 2023-06-22 11:40:16 -04:00