Redefining built-in 'format'
116 ('test.py', 'hello world', '%n', '\n'),
117 ('path/test.py', 'hello world', '%d %f %F %t %n', '00:00:00 path/test.py test.py hello world \n'),
118])
119def test_formatting_placeholders(file: str, text: str, format: str, expected: str):120 with patch('nukeserversocket.editor_controller.datetime') as mock_datetime:
121 mock_datetime.now.return_value = datetime(2000, 1, 1, 0, 0, 0)
122 output = format_output(file, text, format)
Description
Defining a local variable or function with the same name as a built-in object makes the built-in object unusable within the current scope and makes the code prone to bugs.
Bad practice
dict = {} # dict is a Python builtin!
for idx, student in enumerate(students):
dict[student] = idx
Preferred:
roll_number = {}
for idx, student in enumerate(students):
roll_number[student] = idx