Charlie Marsh
1de36cfe4c
Fix wrong-size header in open-file-with-context-handler
( #14067 )
2024-11-03 19:06:40 +00:00
Charlie Marsh
66872a41fc
Detect items that hash to same value in duplicate sets ( #14064 )
...
## Summary
Like https://github.com/astral-sh/ruff/pull/14063 , but ensures that we
catch cases like `{1, True}` in which the items hash to the same value
despite not being identical.
2024-11-03 18:49:11 +00:00
Charlie Marsh
e00594e8d2
Respect hash-equivalent literals in iteration-over-set
( #14063 )
...
## Summary
Closes https://github.com/astral-sh/ruff/issues/14049 .
2024-11-03 18:44:52 +00:00
Steve C
ae9f08d1e5
[ruff
] - fix false positive for decorators (RUF028
) ( #14061 )
2024-11-03 11:49:03 +00:00
Steve C
f69712c11d
[flake8-pyi
] - include all python file types for PYI006
and PYI066
( #14059 )
2024-11-03 11:47:36 +00:00
Steve C
be485602de
Fix preview link references in 2 rule docs ( #14060 )
2024-11-03 11:45:35 +00:00
Steve C
bc7615af0e
[flake8-bugbear
] - do not run mutable-argument-default
on stubs (B006
) ( #14058 )
...
## Summary
Early-exits in `B006` when the file is a stub. Fixes #14026
## Test Plan
`cargo test`
2024-11-02 22:48:48 -04:00
Charlie Marsh
4a3eeeff86
Remove HashableExpr
abstraction ( #14057 )
...
## Summary
It looks like `ComparableExpr` now implements `Hash` so we can just
remove this.
2024-11-02 20:28:35 +00:00
Charlie Marsh
35c6dfe481
Avoid parsing joint rule codes as distinct codes in # noqa
( #12809 )
...
## Summary
We should enable warnings for unsupported codes, but this at least fixes
the parsing for `# noqa: F401F841`.
Closes https://github.com/astral-sh/ruff/issues/12808 .
2024-11-02 20:24:59 +00:00
Simon Brugman
f8374280c0
[flake8-simplify
] Implementation for split-of-static-string
(SIM905) ( #14008 )
...
## Summary
Closes https://github.com/astral-sh/ruff/issues/13944
## Test Plan
Standard snapshot testing
flake8-simplify surprisingly only has a single test case
---------
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-02 17:15:36 +00:00
Steve C
0925513529
[pyupgrade
] - ignore kwarg unpacking for UP044
( #14053 )
...
## Summary
Fixes #14047
## Test Plan
`catgo test`
---------
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-02 13:10:56 -04:00
Simon Brugman
5053d2c127
Doc: markdown link fix ( #14041 )
...
Typo in `mutable-contextvar-default` in `flake8-bugbear`
2024-11-01 14:19:00 +00:00
Dhruv Manilawala
ef72fd79a7
Bump version to 0.7.2 ( #14039 )
2024-11-01 19:09:07 +05:30
STACIA
658a51ea10
Fix typo for static method decorator ( #14038 )
2024-11-01 12:30:50 +00:00
Simon Brugman
9a6b08b557
[flake8-simplify
] Include caveats of enabling if-else-block-instead-of-if-exp
(SIM108) ( #14019 )
2024-10-31 17:26:22 +00:00
Steve C
2d917d72f6
[pyupgrade
] - add PEP646 Unpack conversion to *
with fix (UP044
) ( #13988 )
...
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-10-31 06:58:34 +00:00
Simon Brugman
f426349051
docs: typo in refurb-sorted-min-max ( #13993 )
2024-10-30 12:07:42 +00:00
Charlie Marsh
b6847b371e
Skip namespace package enforcement for PEP 723 scripts ( #13974 )
...
## Summary
Vendors the PEP 723 parser from
[uv](debe67ffdb/crates/uv-scripts/src/lib.rs (L283)
).
Closes https://github.com/astral-sh/ruff/issues/13912 .
2024-10-29 02:11:31 +00:00
Dhruv Manilawala
ec6208e51b
Treat return type of singledispatch
as runtime-required ( #13957 )
...
## Summary
fixes : #13955
## Test Plan
Update existing test case to use a return type hint for which `main`
flags `TCH003`.
2024-10-28 20:33:28 -04:00
Micha Reiser
9f3a38d408
Extract LineIndex
independent methods from Locator
( #13938 )
2024-10-28 07:53:41 +00:00
renovate[bot]
41f74512df
Update Rust crate insta to v1.41.0 ( #13956 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-10-28 06:51:53 +00:00
Dhruv Manilawala
5af0966057
Remove unreferenced snapshots ( #13958 )
2024-10-28 07:16:05 +01:00
Micha Reiser
5a56886414
TCH003: Fix false positive for singledispatchmethod
( #13941 )
...
## Summary
Fixes https://github.com/astral-sh/ruff/issues/13924
## Test Plan
Added test
2024-10-27 21:02:45 -04:00
Micha Reiser
32b57b2ee4
Enable nursery rules: 'redundant_clone', 'debug_assert_with_mut_call', and 'unused_peekable' ( #13920 )
2024-10-25 09:46:30 +02:00
Dhruv Manilawala
337af836d3
Bump version to 0.7.1 ( #13913 )
2024-10-24 20:57:07 +05:30
Micha Reiser
e402e27a09
Use referencial equality in traversal
helper methods ( #13895 )
2024-10-24 11:30:22 +02:00
Micha Reiser
72c18c8225
Fix E221 and E222 to flag missing or extra whitespace around ==
operator ( #13890 )
2024-10-23 15:02:29 +02:00
Shaygan Hooshyari
4d109514d6
[flake8-type-checking
] Support auto-quoting when annotations contain quotes ( #11811 )
...
## Summary
This PR updates the fix generation logic for auto-quoting an annotation
to generate an edit even when there's a quote character present.
The logic uses the visitor pattern, maintaining it's state on where it
is and generating the string value one node at a time. This can be
considered as a specialized form of `Generator`. The state required to
maintain is whether we're currently inside a `typing.Literal` or
`typing.Annotated` because the string value in those types should not be
un-quoted i.e., `Generic[Literal["int"]]` should become
`"Generic[Literal['int']]`, the quotes inside the `Literal` should be
preserved.
Fixes: https://github.com/astral-sh/ruff/issues/9137
## Test Plan
Add various test cases to validate this change, validate the snapshots.
There are no ecosystem changes to go through.
---------
Signed-off-by: Shaygan <hey@glyphack.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2024-10-23 16:34:03 +05:30
Micha Reiser
5d4edd61bf
Fix D204
's documentation to correctly mention the conventions when it is enabled ( #13867 )
2024-10-22 16:51:57 +02:00
Steve C
f3612c2717
[pylint
] - restrict iteration-over-set
to only work on sets of literals (PLC0208
) ( #13731 )
2024-10-21 12:14:02 +01:00
Alex Waygood
72adb09bf3
Simplify iteration idioms ( #13834 )
...
Remove unnecessary uses of `.as_ref()`, `.iter()`, `&**` and similar, mostly in situations when iterating over variables. Many of these changes are only possible following #13826 , when we bumped our MSRV to 1.80: several useful implementations on `&Box<[T]>` were only stabilised in Rust 1.80. Some of these changes we could have done earlier, however.
2024-10-20 22:25:27 +01:00
renovate[bot]
7ca3571194
Update Rust crate pep440_rs to 0.7.1 ( #13654 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-10-20 11:52:55 +02:00
Micha Reiser
27c50bebec
Bump MSRV to Rust 1.80 ( #13826 )
2024-10-20 10:55:36 +02:00
Micha Reiser
2ff36530c3
Upgrade to Rust 1.82 ( #13816 )
2024-10-19 16:05:50 +02:00
Micha Reiser
6d7da7bdbe
Revert "Upgrade to Rust 1.82 toolchain" ( #13810 )
2024-10-18 12:18:26 +00:00
Micha Reiser
ff72055558
Upgrade to Rust 1.82 toolchain ( #13808 )
2024-10-18 12:08:15 +00:00
Matthew Spero
f80528fbf2
Make ARG002
compatible with EM101
when raising NotImplementedError
( #13714 )
...
## Summary
This pull request resolves some rule thrashing identified in #12427 by
allowing for unused arguments when using `NotImplementedError` with a
variable per [this
comment](https://github.com/astral-sh/ruff/issues/12427#issuecomment-2384727468 ).
**Note**
This feels a little heavy-handed / edge-case-prone. So, to be clear, I'm
happy to scrap this code and just update the docs to communicate that
`abstractmethod` and friends should be used in this scenario (or
similar). Just let me know what you'd like done!
fixes : #12427
## Test Plan
I added a test-case to the existing `ARG.py` file and ran...
```sh
cargo run -p ruff -- check crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py --no-cache --preview --select ARG002
```
---------
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2024-10-18 06:44:22 +00:00
Alex Waygood
5e6de4e0c6
Changelog for Ruff v0.7 ( #13794 )
...
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2024-10-17 16:14:21 +00:00
Zanie Blue
70e5c4a8ba
Recode TRY302
to TRY203
( #13502 )
...
Closes https://github.com/astral-sh/ruff/issues/13492
2024-10-17 16:35:12 +01:00
Alex Waygood
1b79ae9817
[ruff-0.7] Stabilise the expansion of open-file-with-context-handler
to work with other standard-library IO modules (SIM115
) ( #13680 )
...
Closes #7313 .
2024-10-17 16:35:12 +01:00
Micha Reiser
202c6a6d75
Remove output-format=text
setting ( #12836 )
2024-10-17 16:35:12 +01:00
Santhosh Solomon
4ea4bbb155
[flake8-bandit
] Detect patterns from multi line SQL statements (S608
) ( #13574 )
...
Co-authored-by: Santhosh Solomon <santhosh@advarisk.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-10-17 05:42:03 +00:00
Micha Reiser
72ac6cd5a5
Fix TODO directive out of bounds acccess ( #13756 )
2024-10-15 10:49:53 +02:00
Sid
9bb4722ebf
[flake8-todos
] Allow words starting with todo ( #13640 )
...
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-10-14 10:21:45 +00:00
Steve C
46bc69d1d4
[flake8-pyi
] - fix dropped exprs in PYI030
autofix ( #13727 )
2024-10-13 11:33:03 +01:00
Alex Waygood
d6b24b690a
[pycodestyle
] Fix whitespace-related false positives and false negatives inside type-parameter lists ( #13704 )
2024-10-10 17:24:17 +01:00
Alex Waygood
5b4afd30ca
Harmonise methods for distinguishing different Python source types ( #13682 )
2024-10-09 13:18:52 +00:00
Zanie Blue
fb90f5a13d
Add known limitation to C416
with dictionaries ( #13627 )
...
Part of https://github.com/astral-sh/ruff/issues/13625
See also #13629
2024-10-07 16:20:45 +00:00
Dylan
14ee5dbfde
[refurb] Count codepoints not bytes for slice-to-remove-prefix-or-suffix (FURB188)
( #13631 )
2024-10-07 16:13:28 +02:00
Alex Waygood
27ac34d683
Rework S606
(start-process-with-no-shell
) docs to make clear the security motivations ( #13658 )
...
Helps with #13614 . This docs rewrite draws on the [documentation for the
original bandit
rule](https://bandit.readthedocs.io/en/latest/plugins/b606_start_process_with_no_shell.html ).
2024-10-07 13:31:01 +01:00