Closed
Description
Steps to reproduce
- cat sample6.py
import csv
def create_csv(output_file, columns, rows, transform_func=None, as_dict=False):
if transform_func is None:
def transform_func(x):
return x
if not as_dict:
with open(output_file, 'w') as f:
writer = csv.writer(f)
writer.writerow(columns)
for row in rows:
row = transform_func(row)
if not isinstance(row, (tuple, list)):
row = (row,)
writer.writerow(row)
- pylint sample6.py
Current behavior
************* Module sample6
/home/sussolan/git_repos/pylint/sample6.py:5:8: E0102: function already defined line 3 (function-redefined)
Your code has been rated at 6.43/10
Expected behavior
There should not be function-redefined error as originally transform_func is an argument and moreover function is defined only when the argument's value is None. Therefore function is defined only once.
pylint --version output
pylint 2.2.0
astroid 2.0.1
Python 3.6.4 (default, Jan 7 2018, 15:53:53)
[GCC 6.4.0]