Spurious warning "Unused entry 'genexpr'"
See original GitHub issueCython version 0.25.2
l = [1,2,3] def f(): print(x for x in l)
$ cython -Wextra -Werror foo.pyx Error compiling Cython file: ------------------------------------------------------------ ... l = [1,2,3] def f(): print(x for x in l) ^ ------------------------------------------------------------ foo.pyx:4:12: Unused entry 'genexpr'
This only happens when the generator expression is in a function, rather than at the module level. Surrounding the expression with parentheses doesn’t help. Converting it to a list comprehension does remove the warning, but will make performance worse, especially if the generator expression would not have run to completion.
I like to use -Wextra -Werror
because the “unused” warnings often indicate a genuine error in my code.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:18 (8 by maintainers)
Top Results From Across the Web
0.29.24 Milestone - GitHub
Spurious warning "Unused entry 'genexpr'" defect Error Reporting. #1699 opened on May 6, 2017 by mhsmith.
Read more >Getting <generator object <genexpr> - python - Stack Overflow
I want to do the following math to it: Multiply 0.49 by 1.91 (the corresponding values from first_lst and second_lst ), and multiply...
Read more >Pylint Documentation - Read the Docs
Pylint is a tool that checks for errors in Python code, tries to enforce a coding standard and looks for code smells. It....
Read more >Pylint's ChangeLog — Pylint 2.4.4 documentation
This fixes a false negative with unused-variable which was no longer ... Warn about using the input() or round() built-ins for Python 3....
Read more >Cython Changelog — Cython 3.0.0a11 documentation
The cython and cythonize commands ignored non-existing input files without error. ... A C compiler warning about unused code was resolved.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@scoder: I’m sorry, but this isn’t fixed at all. My simple 3-line example above still fails, with almost the same message:
Please reopen the issue.
You can use lists explicitly instead of generator expressions. Obviously this doesn’t work in all cases, and can significantly increase memory usage, but it will work some of the time…
->