ruff/crates/ruff_linter/resources/test/fixtures/pyflakes
Brent Westbrook 2250fa6f98
Fix syntax error false positives for `await` outside functions (#21763)
## Summary

Fixes #21750 and a related bug in `PLE1142`. We were not properly
considering generators to be valid `await` contexts, which caused the
`F704` issue. One of the tests I added for this also uncovered an issue
in `PLE1142` for comprehensions nested within async generators because
we were only checking the current scope rather than traversing the
nested context.

## Test Plan

Both of these rules are implemented as semantic syntax errors, so I
added tests (and fixes) in both Ruff and ty.
2025-12-02 21:02:02 +00:00
..
F401_24 F401 - Distinguish between imports we wish to remove and those we wish to make explicit-exports (#11168) 2024-05-02 16:10:32 -07:00
F401_25__all_nonempty F401 - Recommend adding unused import bindings to `__all__` (#11314) 2024-05-14 17:02:33 -07:00
F401_26__all_empty F401 - Recommend adding unused import bindings to `__all__` (#11314) 2024-05-14 17:02:33 -07:00
F401_27__all_mistyped F401 - Recommend adding unused import bindings to `__all__` (#11314) 2024-05-14 17:02:33 -07:00
F401_28__all_multiple F401 - Recommend adding unused import bindings to `__all__` (#11314) 2024-05-14 17:02:33 -07:00
F401_29__all_conditional F401 - Recommend adding unused import bindings to `__all__` (#11314) 2024-05-14 17:02:33 -07:00
F401_33 [`pyflakes`] Fix infinite loop with unused local import in `__init__.py` (`F401`) (#15517) 2025-01-16 10:43:32 -05:00
project/foo Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F50x.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_0.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_1.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_3.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_4.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_5.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_6.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_7.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_8.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_9.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_10.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_11.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_12.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_13.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_14.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_15.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_16.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_17.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_18.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F401_19.py Lazily evaluate all PEP 695 type alias values (#8033) 2023-10-17 21:50:26 -04:00
F401_20.py Iterate over lambdas in deferred type annotations (#9175) 2023-12-18 04:51:23 +00:00
F401_21.py Recursively visit deferred AST nodes (#9541) 2024-01-15 20:34:38 -05:00
F401_22.py Recursively visit deferred AST nodes (#9541) 2024-01-15 20:34:38 -05:00
F401_23.py Treat `typing.Annotated` subscripts as type definitions (#10285) 2024-03-07 19:51:54 -05:00
F401_30.py Fix NFKC normalization bug when removing unused imports (#12571) 2024-07-30 09:54:35 +00:00
F401_31.py Add `allow-unused-imports` setting for `unused-import` rule (`F401`) (#13601) 2024-10-03 19:44:44 +00:00
F401_32.py [`pyflakes`] Ignore errors in `@no_type_check` string annotations (`F722`, `F821`) (#15215) 2025-01-03 10:05:45 +01:00
F401_34.py [`pyflakes`] Visit forward annotations in `TypeAliasType` as types (`F401`) (#15829) 2025-01-30 18:06:38 -05:00
F401_35.py [`pyflakes`] Fix `allowed-unused-imports` matching for top-level modules (`F401`) (#20115) 2025-08-28 13:02:50 +00:00
F402.ipynb Add cell indexes to all diagnostics (#9387) 2024-01-04 14:02:23 +00:00
F402.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F403.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F404_0.py Remove special pre-visit for module docstrings (#9261) 2023-12-23 10:03:12 -05:00
F404_1.py Remove special pre-visit for module docstrings (#9261) 2023-12-23 10:03:12 -05:00
F405.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F406.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F407.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F502.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F503.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F504.py [`pyflakes`] Mark `F504`/`F522`/`F523` autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F521.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F522.py [`pyflakes`] Mark `F504`/`F522`/`F523` autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F523.py [`pyflakes`] Mark `F504`/`F522`/`F523` autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F524.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F525.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F541.py Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
F601.py Detect items that hash to same value in duplicate dictionaries (#14065) 2024-11-03 14:16:34 -05:00
F602.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F622.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F631.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F632.py Use `Tokens` from parsed type annotation or parsed source (#11740) 2024-06-05 07:50:33 +00:00
F633.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F634.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F701.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F702.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F704.py Fix syntax error false positives for `await` outside functions (#21763) 2025-12-02 21:02:02 +00:00
F706.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F707.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F722.py Parse triple quoted string annotations as if parenthesized (#15387) 2025-01-16 11:38:15 +05:30
F722_1.py [`pyflakes`] Ignore errors in `@no_type_check` string annotations (`F722`, `F821`) (#15215) 2025-01-03 10:05:45 +01:00
F811_0.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_1.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_3.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_4.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_5.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_6.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_7.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_8.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_9.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_10.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_11.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_12.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_13.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_14.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_15.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_16.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_17.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_18.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_19.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_20.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_21.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_22.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_23.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_24.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_25.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_26.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F811_27.py Don't flag `redefined-while-unused` in if branches (#9418) 2024-01-08 17:06:55 -05:00
F811_28.py Avoid removing shadowed imports that point to different symbols (#10387) 2024-03-13 15:44:28 +00:00
F811_29.pyi Don't treat annotations as redefinitions in `.pyi` files (#10512) 2024-03-21 12:22:50 -04:00
F811_30.py [`pyflakes`] Detect assignments that shadow definitions (`F811`) (#11961) 2024-06-23 13:29:32 -04:00
F811_31.py Consider `with` blocks as single-item branches (#12311) 2024-07-13 15:22:17 -04:00
F811_32.py Avoid removing too many imports in `redefined-while-unused` (#15585) 2025-01-19 13:28:08 -05:00
F821_0.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_1.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_3.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_4.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_5.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_5.pyi F821, F822: fix false positive for `.pyi` files; add more test coverage for `.pyi` files (#10341) 2024-03-11 22:15:24 +00:00
F821_6.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_7.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_8.pyi Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_9.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_10.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_11.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_11.pyi F821, F822: fix false positive for `.pyi` files; add more test coverage for `.pyi` files (#10341) 2024-03-11 22:15:24 +00:00
F821_12.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_13.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_14.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_15.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_16.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F821_17.py Evaluate default parameter value in enclosing scope (#12852) 2024-08-13 19:25:49 +05:30
F821_18.py Update default and latest Python versions for 3.14 (#20725) 2025-10-07 12:23:11 -04:00
F821_19.py Allow bindings to be created and referenced within annotations (#7885) 2023-10-10 03:51:00 +00:00
F821_20.py Lazily evaluate all PEP 695 type alias values (#8033) 2023-10-17 21:50:26 -04:00
F821_21.py Treat display as a builtin in IPython (#8707) 2023-11-16 01:58:44 +00:00
F821_22.ipynb Treat display as a builtin in IPython (#8707) 2023-11-16 01:58:44 +00:00
F821_23.py Respect dictionary unpacking in `NamedTuple` assignments (#8810) 2023-11-21 19:30:48 +00:00
F821_24.py Fix scoping for generators in named expressions in classes (#9248) 2023-12-22 18:06:40 +00:00
F821_25.py Respect attribute chains when resolving builtin call paths (#9309) 2023-12-29 15:13:24 +00:00
F821_26.py Update default and latest Python versions for 3.14 (#20725) 2025-10-07 12:23:11 -04:00
F821_26.pyi [`pyflakes`] Allow forward references in class bases in stub files (`F821`) (#10779) 2024-04-07 01:15:58 +01:00
F821_27.py Fix F821 false negatives when `from __future__ import annotations` is active (attempt 2) (#10524) 2024-03-22 18:11:16 +00:00
F821_28.py Apply NFKC normalization to unicode identifiers in the lexer (#10412) 2024-03-18 11:56:56 +00:00
F821_29.py 'Revert "F821: Fix false negatives in .py files when `from __future__ import annotations` is active (#10362)"' (#10513) 2024-03-21 16:41:05 +00:00
F821_30.py Visit PEP 764 inline `TypedDict`s' keys as non-type-expressions (#15073) 2024-12-30 15:04:55 +05:30
F821_31.py [`pyflakes`] Ignore errors in `@no_type_check` string annotations (`F722`, `F821`) (#15215) 2025-01-03 10:05:45 +01:00
F821_32.pyi [`pyflakes`] Treat arguments passed to the `default=` parameter of `TypeVar` as type expressions (`F821`) (#15679) 2025-01-22 23:04:20 +00:00
F821_33.py [`pyflakes`] Fix false positive for `__class__` in lambda expressions within class definitions (`F821`) (#20564) 2025-10-24 10:07:19 -04:00
F822_0.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F822_0.pyi F821, F822: fix false positive for `.pyi` files; add more test coverage for `.pyi` files (#10341) 2024-03-11 22:15:24 +00:00
F822_1.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F822_1b.py Improve `ruff_python_semantic::all::extract_all_names()` (#11335) 2024-05-08 17:09:31 +01:00
F822_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F822_3.py Respect `# noqa` directives on `__all__` openers (#10798) 2024-04-06 14:51:17 +00:00
F823.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F841_0.py Add a `ScopeKind` for the `__class__` cell (#20048) 2025-08-26 09:49:08 -04:00
F841_1.py Fix `F841` false negative on assignment to multiple variables (#8489) 2023-11-05 12:01:10 -05:00
F841_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F841_3.py Rename `Autofix` to `Fix` (#7657) 2023-09-28 10:53:05 +00:00
F842.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
F901.py Improve handling of builtin symbols in linter rules (#10919) 2024-04-16 11:37:31 +01:00
__init__.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
builtins.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
future_annotations.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
multi_statement_lines.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
typing_modules.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00