Closed
Description
Bug description
Pylint fails to parse this file and crashes. The error is the temp_post_data[key] = None
as removing that line works, additionally change from for key in self.request_data:
to for key, _ in self.request_data.items():
also works
"""
Simple test class to show astroid error
"""
import unittest
class AstroidErrorTest(unittest.TestCase):
"""simple test class to show astroid error"""
@property
def request_data(self):
"""Data that would be POSTed"""
return {"ref": 'ref',
"project_id": 12,
"checkout_sha": 'hash'}
def test_key_is_none(self):
"""Failure case where the data being POSTed has an expected key being None
Expected Behaviour: POST with no data. Should return 400 json response."""
for key in self.request_data:
temp_post_data= self.request_data.copy()
temp_post_data[key] = None
self.assertIsNone(temp_post_data[key])
# Do the post and validation
if __name__ == '__main__':
unittest.main()
pylint-crash-2022-09-14-14-14-11.zip
Configuration
No response
Command used
pylint testfile.py
Pylint output
Exception on node <For l.20 at 0x242c2610070> in file 'C:\Work\cdt\testfile.py'
Traceback (most recent call last):
File "C:\Work\cdt\venv\lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
callback(astroid)
File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 60, in visit_for
self._modified_iterating_check_on_node_and_children(body_node, iter_obj)
File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 66, in _modified_iterating_check_on_node_and_children
self._modified_iterating_check(body_node, iter_obj)
File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 88, in _modified_iterating_check
elif self._modified_iterating_dict_cond(node, iter_obj):
File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 162, in _modified_iterating_dict_cond
return node.targets[0].value.name == iter_obj.name
AttributeError: 'Attribute' object has no attribute 'name'
************* Module testfile
testfile.py:1:0: F0002: testfile.py: Fatal error while checking 'testfile.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\jase.rieger\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-09-14-14-14-11.txt'. (astroid-error)
-----------------------------------
Your code has been rated at 0.00/10
Expected behavior
Pylint to pass the file.
Works with:
pylint 2.15.0
astroid 2.12.9
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
Pylint version
pylint 2.15.2
astroid 2.12.9
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
OS / Environment
No response
Additional dependencies
No response