PyCQA / PyCQA/pyflakes

Use of await in a function that is not async should be shown as a syntax error by flake8

Open
#818 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
190
Avg merge
8m
Merged PRs (30d)
13

Description

Hello,

Reporting here, since flake8 seems to want this sort of problem delegated to you.

The following code uses await in a function that is declared without the async keyword, which is a syntax error.

def foo():
    pass


def bar():
    await foo()

Running flake8 on this succeeds, no error is reported.

flake8 --version
7.1.1 (mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0) CPython 3.11.2 on
Linux
Debian 12.7
pyflakes 3.2.0 installed in a virtual environment

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with the supplied Python snippet and the stated pyflakes version. Trace how pyflakes handles await expressions inside a non-async function, then add coverage for this case and verify that running the checker reports the syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.