Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1142 false & missed alarms #10074

Open
jakkdl opened this issue Nov 8, 2024 · 0 comments
Open

E1142 false & missed alarms #10074

jakkdl opened this issue Nov 8, 2024 · 0 comments
Labels
False Negative 🦋 No message is emitted but something is wrong with the code False Positive 🦟 A message is emitted but nothing is wrong with the code

Comments

@jakkdl
Copy link

jakkdl commented Nov 8, 2024

Bug description

def foo():
    yield

async def agen():
    yield

def should_not_give_E1142():
    assert (await x for x in foo())

def should_give_E1142():
    # note the list comprehension
    assert [x async for x in agen()]

# these latter two are correctly handled
def correctly_gives_E1142():
    assert (x for x in await foo())

def correctly_does_not_give_E1142():
    assert (x async for x in agen())

See astral-sh/ruff#14167 for the report to ruff that contains a more concrete example.

Configuration

N/A

Command used

pylint --disable=C pylint_1142.py

Pylint output

************* Module pylint_1142
pylint_1142.py:8:12: E1142: 'await' should be used within an async function (await-outside-async)
pylint_1142.py:16:23: E1142: 'await' should be used within an async function (await-outside-async)

Expected behavior

The error on line 16 is correct, but the error on line 8 is a false alarm and it's missing an alarm on line 12.

Pylint version

$ pylint --version
pylint 3.3.1
astroid 3.3.5
Python 3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522]

OS / Environment

Arch Linux

Additional dependencies

No response

@jakkdl jakkdl added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 8, 2024
@zenlyj zenlyj added False Positive 🦟 A message is emitted but nothing is wrong with the code False Negative 🦋 No message is emitted but something is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

No branches or pull requests

2 participants