-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 on --py3k comprehension-escape (W1662) #2106
Comments
Thanks! This is a false positive, we'll fix it. |
This is likely related / same root cause to #2130 |
@PCManticore I can't test from master/1.9 right now; are you going to release 1.9.2 or this is something that will be included in 2.0? I can't find the information on the changelog. |
It's going to be released in 1.9.2 at some point. |
@hvelarde one way of testing is installing pylint in a virtualenv doing I'm not so sure if we're having false positives as well. When using 1.9.1, we get:
And when running your branch 1.9 at 6b4c4d2 with this fix now we get:
|
Thanks for testing it out @idgserpro ! Your two examples seem to also be false positives. |
I added this issue to the next bug fix release (that is 1.9.2). This check needs some more improvements as right now it emits quite a lot of false positives. |
Hey folks let me know if the linked commit works for you. If so, I'll cherry-pick in 1.9 as well (it's only on master for now). |
wfm given the examples I can find! thanks for the fix :) |
Well, it's me that should be thanking after this fast response 😆. How exactly should I test this? I installed pylint 1.9.1. Then, I added
Is this commit from Anyways, I will ignore, for now, these false positives in my code since I need to create a new release. |
@idgserpro I tried your file for ya:
|
… the corresponding nodes These two checks were implemented in terms of visit_namne, that is, for every name in the tree, we looked to see if that name leaked. This was resulting in a couple of false positives and also in a performance issue, since we were calling nodes_of_class() and scope() for each name node. Instead, this approach uses the visit methods for exception and comprehension nodes and looks to see from there if the current scope uses leaked names. This is not the ideal situation as well, ideal would be to have access to the definition frame of each name, but that requires some extra engineering effort in astroid to get it right. Close #2106
I couldn't test that way (directly from master), stuck into Python 2.x, that's why I tried the workflow in #2106 (comment).
I decided to install in a Python3 like you did, but when running it against the whole package
(This file here https://github.com/plonegovbr/brasil.gov.tiles/blob/2fd15243b4134b2daf97984d2bcfbfe7863490ff/src/brasil/gov/tiles/tests/test_robot.py#L16 is the one with the W1662) And then a strange error:
After debugging (I added some prints to pylint), I discovered that this file https://github.com/plonegovbr/brasil.gov.tiles/blob/796a644875bb7ac01ae9cd4ea778bf7044e23c8f/src/brasil/gov/tiles/tiles/header.py is what breaks pylint above. Should we open a new issue? |
Hey @idgserpro Thanks for trying it out! It should also be available now in the 1.9 branch, which works on Python 2. I already pushed a fix for the bug you found in ea4b5d4, let me know if that works for you! |
@PCManticore what's available right now in 1.9 branch (37e6384) fixes what I post in #2106 (comment), but not what's in #2106 (comment), isn't what's in https://github.com/plonegovbr/brasil.gov.tiles/blob/2fd15243b4134b2daf97984d2bcfbfe7863490ff/src/brasil/gov/tiles/tests/test_robot.py#L16 a false positive as well? Running the 1.9 branch doesn't give the error |
Hey @idgserpro Sorry I missed that, this issue has so many different links that it's hard to keep track of them all. |
For reference this is the code that triggers the false positive:
|
Sorry about that. Next time we'll try to summarize at the first post. |
…king for comprehension-escape values. Close #2106
Thanks @idgserpro Let me know if this change stops the false positives for you. You can test them with the 1.9 branch. |
There's still an error in the file https://github.com/plonegovbr/brasil.gov.tiles/blob/2fd15243b4134b2daf97984d2bcfbfe7863490ff/src/brasil/gov/tiles/tests/test_robot.py#L16: pip install --upgrade git+https://github.com/PyCQA/pylint.git@1.9
wget https://raw.githubusercontent.com/plonegovbr/brasil.gov.tiles/2fd15243b4134b2daf97984d2bcfbfe7863490ff/src/brasil/gov/tiles/tests/test_robot.py
pylint --py3k --disable=no-absolute-import test_robot.py Output:
|
@PCManticore did you check #2106 (comment)? |
Seems fixed on [
x for x in range(1)
if x
] $ ./venv2/bin/pylint --py3k test.py
No config file found, using default configuration
************* Module test
W: 3, 7: Using a variable that was bound inside a comprehension (comprehension-escape)
--------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 10.00/10, -10.00)
$ ./venv3/bin/pylint --py3k test.py
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 0.00/10, +10.00)
|
No, I didn't check that comment as I am currently in vacation. Will take a look next week. |
…statement This works on Python 3 because scope() for a ListComp will always be the ListComp, but on Python 2 that's going to be the outer scope/frame instead. Close #2106
Hey folks, let me know if the latest commit from 1.9 fixes this problem for you. If so, I'll do another patch release these days. |
thanks! it's seems to be working now. |
* Fix xrange-builtin * Fix exception-message-attribute * Fix old-division * Fix bad-python3-import * Clean up code especific for Plone 5.0 only * Ignore Pylint's false positive warning refs. pylint-dev/pylint#2106 * Fix deprecated-urllib-function * Ignore pylint's round-builtin warning * Use human readable notation instead * Add changelog entry and XXX note * Do not allow further any issues with Python 3 compatibility
@PCManticore do you have a expected date for release 1.9.2? |
@hvelarde Just released. Let me know if it works for you! |
it's working, thanks! |
… the corresponding nodes These two checks were implemented in terms of visit_namne, that is, for every name in the tree, we looked to see if that name leaked. This was resulting in a couple of false positives and also in a performance issue, since we were calling nodes_of_class() and scope() for each name node. Instead, this approach uses the visit methods for exception and comprehension nodes and looks to see from there if the current scope uses leaked names. This is not the ideal situation as well, ideal would be to have access to the definition frame of each name, but that requires some extra engineering effort in astroid to get it right. Close pylint-dev#2106
…king for comprehension-escape values. Close pylint-dev#2106
Steps to reproduce
CI build ran automatically and started failing because of this; previously no warning was shown.
Current behavior
A warning is shown:
$ bin/pylint --py3k --disable=no-absolute-import src/collective/fingerpointing No config file found, using default configuration ************* Module collective.fingerpointing.tests.test_upgrades W: 85,17: Using a variable that was bound inside a comprehension (comprehension-escape) W: 85,45: Using a variable that was bound inside a comprehension (comprehension-escape) ------------------------------------------------------------------- Your code has been rated at 9.98/10 (previous run: 10.00/10, -0.02)
this is the offending code: https://github.com/collective/collective.fingerpointing/blob/1.7/src/collective/fingerpointing/tests/test_upgrades.py#L85
the exact same line is used above with no warnings: https://github.com/collective/collective.fingerpointing/blob/1.7/src/collective/fingerpointing/tests/test_upgrades.py#L75
Expected behavior
No warning shown (as previously with pylint 1.8.4).
pylint --version output
The text was updated successfully, but these errors were encountered: