pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

False positive for unsubscriptable-object when dunder setitem is expected instead #705

Closed pylint-bot closed 8 years ago

pylint-bot commented 8 years ago

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


The current code of unsubscriptable-object treats all Subscript nodes the same, even though the context for them can be different. For instance, the context for the Subscript node from x[1] = 2 is Store, meaning that a __setitem__ method will be invoked instead of __getitem__ and it's not required for the said object to have it implemented.

For pylint 1.5.0 we might solve this by verifying explicitly on each side of the assignment operator the subscript node is, but for pylint 1.6.0 and onward, we might use the solution provided by https://bitbucket.org/logilab/astroid/issues/267/add-a-context-for-certain-nodes-similar-to in order to detect our current context.


pylint-bot commented 8 years ago

Original comment by BitBucket: dmand, GitHub: @dmand?:


I'm a bit confused here. Didn't you already fix that with 81b48b5? Or was this issue created as a reminder to use subscription contexts for 1.6.0?

pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Both of them. I fixed it without thinking on it, but we can leave it as a reminder. You can remove yourself from the assignee if you want, sorry about the noise. :-)

pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Use the new .ctx attribute for subscripts for detecting in which context the node was used. Closes issue #705.