Я пытаюсь проверить Pylint с настройками по умолчанию и (см. python код ниже) получить предупреждение:
>pylint pylint_test_01.py
>pylint_test_01.py:24:7: W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)
Как мне избавиться от этого предупреждения Pylint, не нарушая этот алгоритм и не отключая Pylint проверяет (т.е. с настройками по умолчанию)? Общий принцип перечисления функций из списка должен остаться.
'''Test pylint with default settings warnings'''
from random import randint
def sortaray_builtin(arr):
'''This is built in Python sort function'''
return sorted(arr.copy())
def sortaray_bubble(arr):
'''Bubble sorting algorithm -- is a simplest of sorting algorithms. Perfomance: O(N**2)'''
brr = arr.copy()
for i, _ in enumerate(brr[:-1]):
for j in range(i, len(brr)):
if brr[i] > brr[j]:
brr[i], brr[j] = brr[j], brr[i]
return brr
SFUNCTIONS = [
sortaray_builtin,
sortaray_bubble
]
ARSIZE = 20
ARRY = [randint(0, ARSIZE) for i in range(ARSIZE)]
for SrtFunc in SFUNCTIONS:
# Line below cause an W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)
if SrtFunc == sortaray_builtin:
print("Builtin: ", end='', flush=True)
else:
print("Bubble : ", end='', flush=True)
print(SrtFunc(ARRY))