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

Unnecessary generator warning #1020

Open
nickdrozd opened this issue Sep 20, 2023 · 0 comments
Open

Unnecessary generator warning #1020

nickdrozd opened this issue Sep 20, 2023 · 0 comments

Comments

@nickdrozd
Copy link

Because of python/mypy#14418, Mypyc emits a warning for generators: warning: Treating generator comprehension as list. But there is no need to emit this warning when the generator will be consumed in full anyway.

def f(self, xs: list[int]) -> dict[int, int]:
    return dict(
        enumerate(  # warning: Treating generator comprehension as list
            2 * x
            for x in xs
        )
    )

In this case, the warning is emitted for the enumerate generator. But the generator is immediately consumed by the dict call, and so it doesn't matter that the generator was compiled as a list.

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

No branches or pull requests

1 participant