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.

  • #858 by @alexchen-sys — closed without merging

Assessment

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

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.

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

Dominant language
Python
Stars
1.5k
Forks
207
Avg merge
4m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from PyCQA/pyflakes

All issues in PyCQA/pyflakes

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.