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

"assignment-from-none" false positive on generator #3519

Closed
CrepeGoat opened this issue Apr 26, 2020 · 1 comment
Closed

"assignment-from-none" false positive on generator #3519

CrepeGoat opened this issue Apr 26, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@CrepeGoat
Copy link

Steps to reproduce

  1. Create a new .py file with the following contents:
def paused_iter(iterable):
    """Iterate an iterable, yielding the previous item using `i.send(True)`."""
    iterator = iter(iterable)

    while True:
        try:
            value = next(iterator)
        except StopIteration:
            return

        # Continue to yield the same item until `next(i)` or `i.send(False)`
        while (yield value):
            pass


ITERATOR = paused_iter(range(3))
  1. Run pylint on this file.

Current behavior

Pylint reports the following error:

/path/to/file.py:15:0: E1128: Assigning result of a function call, where the function returns None (assignment-from-none)

Expected behavior

The above error does not apply to the above valid code since the function that "returns None" is a generator. Thus, I expect that no such error should be reported.

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0]
@CrepeGoat CrepeGoat changed the title "assignment-from-none" false positive on generators "assignment-from-none" false positive on generator Apr 26, 2020
@PCManticore
Copy link
Contributor

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants