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

False positive assignment-from-no-return on generator #3904

Closed
xbe opened this issue Oct 18, 2020 · 2 comments · Fixed by pylint-dev/astroid#877
Closed

False positive assignment-from-no-return on generator #3904

xbe opened this issue Oct 18, 2020 · 2 comments · Fixed by pylint-dev/astroid#877
Assignees
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Good first issue Friendly and approachable by new contributors

Comments

@xbe
Copy link

xbe commented Oct 18, 2020

Steps to reproduce

from typing import Callable, Generator

CHUNK_SIZE = 5


def chunk(handler: Callable[[str], None]) -> Generator[None, str, None]:
    buf = ''
    while True:
        while len(buf) < CHUNK_SIZE:
            buf += yield
        head, buf = buf[:CHUNK_SIZE], buf[CHUNK_SIZE:]

        handler(head)


def handle(contents: str) -> None:
    print(f'Got: {contents}')


streamer = chunk(handle)
next(streamer)  # start streaming
streamer.send('foo')

Current behavior

************* Module iter
iter.py:20:0: E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)

Expected behavior

No error.

pylint --version output

With pip install pylint astroid --pre -U:

pylint 2.6.0
astroid 2.4.2
Python 3.8.5 (default, Jul 20 2020, 18:32:44) 
[GCC 9.3.0]
@hippo91
Copy link
Contributor

hippo91 commented Oct 22, 2020

@xbe thanks for the report. I can reproduce it.

@hippo91 hippo91 added Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code labels Oct 22, 2020
@PCManticore PCManticore added the Good first issue Friendly and approachable by new contributors label Dec 28, 2020
PCManticore added a commit to pylint-dev/astroid that referenced this issue Jan 1, 2021
This fixes a false positive with the `assignment-from-no-return` pylint check.

Close pylint-dev/pylint#3904
@PCManticore PCManticore self-assigned this Jan 1, 2021
@PCManticore
Copy link
Contributor

This will be fixed by https://github.com/PyCQA/astroid/pull/877/files.

PCManticore added a commit to pylint-dev/astroid that referenced this issue Jan 1, 2021
This fixes a false positive with the `assignment-from-no-return` pylint check.

Close pylint-dev/pylint#3904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Good first issue Friendly and approachable by new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants