ruff/crates/ruff_linter/resources/test/fixtures
Victor Hugo Gomes 06a78d0bd0
[`pylint`] Fix `PLC1802` autofix creating a syntax error and mark autofix as unsafe if there's comments in the `len` call (#18836)
<!--
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
I've also found another bug while fixing this, where the diagnostic
would not trigger if the `len` call argument variable was shadowed. This
fixed a few false negatives in the test cases.
Example:
```python
fruits = []
fruits = []
if len(fruits):  # comment
    ...
```

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

## Test Plan
Add regression test
<!-- How was it tested? -->

---------

Co-authored-by: Charlie Marsh <crmarsh416@gmail.com>
2025-06-23 00:32:57 +00:00
..
airflow [`airflow`] Add unsafe fix for module moved cases (`AIR312`) (#18363) 2025-05-30 09:36:20 -04:00
control-flow-graph [`pylint`] Fix `unreachable` infinite loop (`PLW0101`) (#15278) 2025-01-08 09:45:04 -06:00
eradicate [`eradicate`] Correctly handle metadata blocks directly followed by normal blocks (`ERA001`) (#15330) 2025-01-07 16:22:22 -05:00
fastapi [`fastapi`] Avoid false positive for class dependencies (`FAST003`) (#18271) 2025-06-02 14:34:50 -04:00
filesystem Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
flake8_2020 Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
flake8_annotations [ruff 0.8] [`flake8-annotations`] Remove deprecated rules ANN101 and ANN102 (#14384) 2024-11-20 13:11:51 +01:00
flake8_async [`flake8-async`] Mark autofix for `ASYNC115` as unsafe if the call expression contains comments (#18753) 2025-06-19 13:01:33 +02:00
flake8_bandit Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
flake8_blind_except Respect logged and re-raised expressions in nested statements (#11301) 2024-05-05 21:52:09 -04:00
flake8_boolean_trap FBT001: exclude boolean operators (#14203) 2024-11-10 22:40:37 +00:00
flake8_bugbear [`flake8-bugbear`] Mark autofix for `B004` as unsafe if the `hasattr` call expr contains comments (#18755) 2025-06-19 10:46:53 +00:00
flake8_builtins [flake8-builtins] Ignore variables matching module attribute names (A001) (#16454) 2025-03-03 11:10:23 +01:00
flake8_commas Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
flake8_comprehensions [`flake8-comprehensions`] Handle template strings for comprehension fixes (#18710) 2025-06-19 16:23:46 -05:00
flake8_datetimez [`flake8-datetime`] Ignore `.replace()` calls while looking for `.astimezone` (#16050) 2025-02-09 15:48:59 +00:00
flake8_debugger [`flake8-debugger`] Also flag `sys.breakpointhook` and `sys.__breakpointhook__` (`T100`) (#16191) 2025-02-16 14:50:16 -05:00
flake8_django [`flake8-django`] Recognize other magic methods (`DJ012`) (#15365) 2025-01-09 14:36:42 +01:00
flake8_errmsg Allow `EM` fixes even if `msg` variable is defined (#9059) 2023-12-08 15:16:15 -06:00
flake8_executable [`flake8-executables`] Allow `uv run` in shebang line for `shebang-missing-python` (`EXE003`) (#16849) 2025-03-19 10:35:07 -05:00
flake8_fixme Fix TODO directive out of bounds acccess (#13756) 2024-10-15 10:49:53 +02:00
flake8_future_annotations Avoid flagging `__future__` annotations as required for non-evaluated type annotations (#11414) 2024-05-21 18:57:13 +00:00
flake8_gettext Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
flake8_implicit_str_concat Add Autofix for ISC003 (#18256) 2025-05-28 09:30:51 +02:00
flake8_import_conventions [flake8-import-conventions] Add import `numpy.typing as npt` to default `flake8-import-conventions.aliases` (#17133) 2025-04-02 09:25:46 +02:00
flake8_logging [`flake8-logging`] Avoid false positive for `exc_info=True` outside `logger.exception` (`LOG014`) (#18737) 2025-06-20 14:43:08 -04:00
flake8_logging_format Include inline instantiations when detecting loggers (#11154) 2024-04-25 21:00:12 -04:00
flake8_no_pep420 Skip namespace package enforcement for PEP 723 scripts (#13974) 2024-10-29 02:11:31 +00:00
flake8_pie Handle parenthesized arguments in `remove_argument` (#18805) 2025-06-20 21:24:41 +00:00
flake8_print Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
flake8_pyi [`flake8_pyi`] Fix `PYI041`'s fix causing TypeError with `None | None | ...` (#18637) 2025-06-20 15:04:51 -04:00
flake8_pytest_style [`flake8-pytest-style`] Mark autofix for `PT001` and `PT023` as unsafe if there's comments in the decorator (#18792) 2025-06-20 08:23:59 +02:00
flake8_quotes Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
flake8_raise [`flake8-raise`] Make fix unsafe if it deletes comments (`RSE102`) (#18788) 2025-06-21 19:09:40 +02:00
flake8_return Mark `RET501` fix unsafe if comments are inside (#18780) 2025-06-19 11:12:12 +02:00
flake8_self [`flake8-self`] Ignore attribute accesses on instance-like variables (`SLF001`) (#16149) 2025-02-23 10:00:49 +00:00
flake8_simplify [`flake8-simplify`] Fix false negatives for shadowed bindings (`SIM910`, `SIM911`) (#18794) 2025-06-20 13:25:36 -04:00
flake8_slots Avoid recommending `__slots__` for classes that inherit from more than `namedtuple` (#12531) 2024-07-26 14:24:40 +00:00
flake8_tidy_imports Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
flake8_todos [`flake8-todos`] Allow VSCode GitHub PR extension style links in `missing-todo-link` (`TD003`) (#15519) 2025-01-15 23:47:33 +00:00
flake8_type_checking Fixes how the checker visits `typing.cast`/`typing.NewType` arguments (#17538) 2025-04-23 09:26:00 +02:00
flake8_unused_arguments Consider `__new__` methods as special function type for enforcing class method or static method rules (#13305) 2025-02-16 14:12:25 -06:00
flake8_use_pathlib [flake8_use_pathlib]: Replace os.symlink with Path.symlink_to (PTH211) (#18337) 2025-05-28 12:39:05 +02:00
flynt Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
isort enforce required imports even with useless alias (#14287) 2024-11-14 15:39:38 -06:00
mccabe Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
numpy Ignore `NPY201` inside `except` blocks for compatibility with older numpy versions (#12490) 2024-07-24 20:03:23 +00:00
pandas_vet Limit inplace diagnostics to methods that accept inplace (#9495) 2024-01-12 14:12:54 -05:00
pep8_naming [`pep8-naming`] Suppress fix for `N804` and `N805` if the recommend name is already used (#18472) 2025-06-11 07:58:55 +02:00
perflint [`perflint`] fix missing parentheses for lambda and ternary conditions (PERF401, PERF403) (#18412) 2025-06-05 09:57:08 -05:00
pycodestyle [`pycodestyle`] Fix `E731` autofix creating a syntax error for expressions spanned across multiple lines (#18479) 2025-06-13 08:44:15 +02:00
pydoclint Fix typos found by codespell (#14863) 2024-12-09 09:32:12 +00:00
pydocstyle [`pydocstyle`] Handle arguments with the same names as sections (`D417`) (#16011) 2025-02-11 12:05:29 -05:00
pyflakes [ty] Don't warn `yield` not in function when `yield` is in function (#18008) 2025-05-21 18:16:25 +02:00
pygrep_hooks Respect per-file ignores for blanket and redirected noqa rules (#11728) 2024-06-04 03:57:59 +00:00
pylint [`pylint`] Fix `PLC1802` autofix creating a syntax error and mark autofix as unsafe if there's comments in the `len` call (#18836) 2025-06-23 00:32:57 +00:00
pyupgrade [`pyupgrade`] Suppress `UP008` diagnostic if `super` symbol is not builtin (#18688) 2025-06-16 15:09:31 -04:00
refurb [`refurb`] Mark `FURB129` autofix as unsafe if there's comments in the `readlines` call (#18858) 2025-06-22 08:51:37 +01:00
ruff Handle parenthesized arguments in `remove_argument` (#18805) 2025-06-20 21:24:41 +00:00
syntax_errors [semantic-syntax-tests] Add test fixtures for `AwaitOutsideAsyncFunction` (#17785) 2025-05-05 14:02:06 -04:00
tryceratops Recode `TRY302` to `TRY203` (#13502) 2024-10-17 16:35:12 +01:00
__init__.py [`pylint`] (Re-)Implement `import-private-name` (`C2701`) (#9553) 2024-01-16 14:03:11 -05:00