Commit graph

2115 commits

Author SHA1 Message Date
Dhruv Manilawala
b0e26e6fc8
Bump version to 0.8.2 (#14789) 2024-12-05 18:06:35 +05:30
InSync
fda8b1f884
[ruff] Unnecessary cast to int (RUF046) (#14697)
## Summary

Resolves #11412.

## Test Plan

`cargo nextest run` and `cargo insta test`.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2024-12-05 10:30:06 +01:00
Well404
04c887c8fc
Fix references for async-busy-wait (#14775) 2024-12-04 18:05:49 +01:00
Harutaka Kawamura
614917769e
Remove @ in pytest.mark.parametrize rule messages (#14770) 2024-12-04 16:01:10 +01:00
David Salvisberg
e67f7f243d
[flake8-type-checking] Expands TC006 docs to better explain itself (#14749)
Closes: #14676

I think the consensus generally was to keep the rule as-is, but expand
the docs.

## Summary

Expands the docs for TC006 with an explanation for why the type
expression is always quoted, including mention of another potential
benefit to this style.
2024-12-04 13:16:31 +00:00
Dylan
c617b2a48a
[pycodestyle] Handle f-strings properly for invalid-escape-sequence (W605) (#14748)
When fixing an invalid escape sequence in an f-string, each f-string
element is analyzed for valid escape characters prior to creating the
diagnostic and fix. This allows us to safely prefix with `r` to create a
raw string if no valid escape characters were found anywhere in the
f-string, and otherwise insert backslashes.

This fixes a bug in the original implementation: each "f-string part"
was treated separately, so it was not possible to tell whether a valid
escape character was or would be used elsewhere in the f-string.

Progress towards #11491 but format specifiers are not handled in this
PR.
2024-12-04 06:59:14 -06:00
Dhruv Manilawala
575deb5d4d
Check AIR001 from builtin or providers operators module (#14631)
## Summary

This PR makes changes to the `AIR001` rule as per
https://github.com/astral-sh/ruff/pull/14627#discussion_r1860212307.

Additionally,
* Avoid returning the `Diagnostic` and update the checker in the rule
logic for consistency
* Remove test case for different keyword position (I don't think it's
required here)

## Test Plan

Add test cases for multiple operators from various modules.
2024-12-04 13:30:47 +05:30
Wei Lee
edce559431
[airflow]: extend removed names (AIR302) (#14734) 2024-12-03 21:39:43 +00:00
Brent Westbrook
62e358e929
[ruff] Extend unnecessary-regular-expression to non-literal strings (RUF055) (#14679)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-12-03 15:17:20 +00:00
Alex Waygood
81bfcc9899
Minor followups to RUF052 (#14755)
## Summary

Just some minor followups to the recently merged RUF052 rule, that was
added in bf0fd04:
- Some small tweaks to the docs
- A minor code-style nit
- Some more tests for my peace of mind, just to check that the new
methods on the semantic model are working correctly

I'm adding the "internal" label as this doesn't deserve a changelog
entry. RUF052 is a new rule that hasn't been released yet.

## Test Plan

`cargo test -p ruff_linter`
2024-12-03 13:33:29 +00:00
Alex Waygood
70bd10614f
Improve docs for flake8-use-pathlib rules (#14741)
Flag the perf impact more clearly, add more links, clarify the rule
about the glob module
2024-12-03 07:47:31 +00:00
Lokejoke
bf0fd04e4e
[ruff] Implemented used-dummy-variable (RUF052) (#14611)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-12-03 08:36:16 +01:00
Dylan
91e2d9a139
[refurb] Handle non-finite decimals in verbose-decimal-constructor (FURB157) (#14596)
This PR extends the Decimal parsing used in [verbose-decimal-constructor
(FURB157)](https://docs.astral.sh/ruff/rules/verbose-decimal-constructor/)
to better handle non-finite `Decimal` objects, avoiding some false
negatives.

Closes #14587

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2024-12-02 18:13:20 -06:00
Matt Ord
83651deac7
[pylint] Ignore overload in PLR0904 (#14730)
Fixes #14727

## Summary

Fixes #14727

## Test Plan

cargo test

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-12-02 14:36:51 +00:00
Alex Waygood
6dfe125f44
Improve error messages and docs for flake8-comprehensions rules (#14729) 2024-12-02 13:36:15 +00:00
Micha Reiser
f96dfc179f
Revert: [pyflakes] Avoid false positives in @no_type_check contexts (F821, F722) (#14615) (#14726) 2024-12-02 14:28:27 +01:00
Tzu-ping Chung
76d2e56501
[airflow] Avoid deprecated values (AIR302) (#14582) 2024-12-02 07:39:26 +00:00
Simon Brugman
48ec3a8add
[refurb] Guard hashlib imports and mark hashlib-digest-hex fix as safe (FURB181) (#14694)
## Summary

- Check if `hashlib` and `crypt` imports have been seen for `FURB181`
and `S324`
- Mark the fix for `FURB181` as safe: I think it was accidentally marked
as unsafe in the first place. The rule does not support user-defined
classes as the "fix safety" section suggests.
- Removed `hashlib._Hash`, as it's not part of the `hashlib` module.

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

## Test Plan

Updated the test snapshots
2024-12-01 20:24:49 -05:00
Brent Westbrook
9e017634cb
[pep8-naming] Avoid false positive for class Bar(type(foo)) (N804) (#14683) 2024-11-30 22:37:28 +00:00
Simon Brugman
56ae73a925
[pylint] Fix false negatives for ascii and sorted in len-as-condition (PLC1802) (#14692) 2024-11-30 14:10:30 -06:00
InSync
be07424e80
Increase rule set size (#14689) 2024-11-30 15:12:10 +01:00
Micha Reiser
90487b8cbd
Skip panda rules if panda module hasn't been seen (#14671) 2024-11-29 21:32:51 +00:00
Alex Waygood
f3d8c023d3
[ruff] Avoid emitting assignment-in-assert when all references to the assigned variable are themselves inside asserts (RUF018) (#14661) 2024-11-29 13:36:59 +00:00
Micha Reiser
b63c2e126b
Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
Simon Brugman
abb3c6ea95
[flake8-pyi] Avoid rewriting invalid type expressions in unnecessary-type-union (PYI055) (#14660) 2024-11-28 18:30:50 +00:00
Brent Westbrook
224fe75a76
[ruff] Implement unnecessary-regular-expression (RUF055) (#14659)
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Simon Brugman <sbrugman@users.noreply.github.com>
2024-11-28 18:29:23 +00:00
Simon Brugman
dc29f52750
[flake8-pyi, ruff] Fix traversal of nested literals and unions (PYI016, PYI051, PYI055, PYI062, RUF041) (#14641) 2024-11-28 18:07:12 +00:00
David Salvisberg
d9cbf2fe44
Avoids unnecessary overhead for TC004, when TC001-003 are disabled (#14657) 2024-11-28 16:28:24 +01:00
Dhruv Manilawala
976c37a849
Bump version to 0.8.1 (#14655) 2024-11-28 19:12:50 +05:30
Alex Waygood
d8bca0d3a2
Fix bug where methods defined using lambdas were flagged by FURB118 (#14639) 2024-11-28 12:58:23 +00:00
David Salvisberg
8a7ba5d2df
[flake8-type-checking] Fixes quote_type_expression (#14634) 2024-11-27 18:58:48 +01:00
Brent Westbrook
6fcbe8efb4
[ruff] Detect redirected-noqa in file-level comments (RUF101) (#14635) 2024-11-27 18:25:47 +01:00
Alexandra Valentine-Ketchum
c40b37aa36
N811 & N814: eliminate false positives for single-letter names (#14584)
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-11-27 14:38:36 +00:00
Alex Waygood
4fb1416bf4
Minor stylistic improvements for functions detecting PEP-604 unions (#14633) 2024-11-27 11:29:37 +00:00
Simon Brugman
11a2929ed7
[ruff] Implement unnecessary-nested-literal (RUF041) (#14323)
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-11-27 10:01:50 +00:00
InSync
187974eff4
[flake8-use-pathlib] Recommend Path.iterdir() over os.listdir() (PTH208) (#14509)
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-11-27 09:53:13 +00:00
Micha Reiser
14ba469fc0
Use a derive macro for Violations (#14557)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-11-27 09:41:40 +00:00
David Salvisberg
6fd10e2fe7
[flake8-type-checking] Adds implementation for TC007 and TC008 (#12927)
Co-authored-by: Simon Brugman <sbrugman@users.noreply.github.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-11-27 09:51:20 +01:00
Dhruv Manilawala
0d649f9afd
Check that airflow module is seen for AIR001 (#14627) 2024-11-27 07:25:08 +00:00
Lokejoke
82c01aa662
[pylint] Implement len-test (PLC1802) (#14309)
## Summary

This PR implements [`use-implicit-booleaness-not-len` /
`C1802`](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/use-implicit-booleaness-not-len.html)
> For sequences, (strings, lists, tuples), use the fact that empty
sequences are false.

---------

Co-authored-by: xbrtnik1 <524841@mail.muni.cz>
Co-authored-by: xbrtnik1 <xbrtnik1@mail.muni.cz>
2024-11-26 13:30:17 -06:00
Brent Westbrook
9f446faa6c
[pyflakes] Avoid false positives in @no_type_check contexts (F821, F722) (#14615) 2024-11-26 19:13:43 +00:00
Dylan
24c90d6953
[pylint] Do not wrap function calls in parentheses in the fix for unnecessary-dunder-call (PLC2801) (#14601) 2024-11-26 06:47:01 -06:00
Tzu-ping Chung
fbff4dec3a
[airflow] Avoid implicit DAG schedule (AIR301) (#14581) 2024-11-26 13:38:18 +01:00
Simon Brugman
e4cefd9bf9
Extend test cases for flake8-pyi (#14280) 2024-11-26 09:10:38 +01:00
Lokejoke
9e4ee98109
[ruff] Implement invalid-assert-message-literal-argument (RUF040) (#14488)
## Summary

This PR implements new rule discussed
[here](https://github.com/astral-sh/ruff/discussions/14449).
In short, it searches for assert messages which were unintentionally
used as a expression to be matched against.

## Test Plan

`cargo test` and review of `ruff-ecosystem`
2024-11-25 17:41:07 -06:00
Simon Brugman
c606bf014e
[flake8-pyi] Improve autofix safety for redundant-none-literal (PYI061) (#14583)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-11-25 17:40:57 +00:00
Simon Brugman
e8fce20736
[ruff] Improve autofix safety for never-union (RUF020) (#14589) 2024-11-25 18:35:07 +01:00
Harutaka Kawamura
fa22bd604a
Fix pytest.mark.parametrize rules to check calls instead of decorators (#14515)
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-11-25 13:55:18 +01:00
Alex Waygood
ac23c99744
[ruff] Mark fixes for unsorted-dunder-all and unsorted-dunder-slots as unsafe when there are complex comments in the sequence (RUF022, RUF023) (#14560) 2024-11-24 12:49:29 +00:00
Charlie Marsh
de62e39eba
Use truthiness check in auto_attribs detection (#14562) 2024-11-23 22:06:10 -05:00