Not sure why this type warning pops up in PyCharm 2020.2
I am getting the following type warning from a section of my code:
Unexpected type(s):(int, List[int])Possible types:(int, int)(slice, Iterable[int])
The code creates a list of lists of integers, and then goes over it twice using for statements as shown here:
sets = []
p_matrix = [[0 for _ in range(2 ** (dimension - 1))] for _ in range(dimension)]
for i in range(dimension):
sets.append(clone_sets(dimension, i))
for row in range(len(p_matrix)):
for col in range(len(p_matrix[row])):
for i in range(len(p_matrix)):
for j in range(len(p_matrix[i])):
if p_matrix[row][col] == 0 and sets[row][col] == sets[i][j]:
p_matrix[row][col] = [i, j] # Warning shows up on this line from col in p_matrix[row][col]
break
else:
continue
break
What I don't understand is why since both row and col are of type int the warning comes only from col? And also, why does the warning come up in the first place?since as I said both row and col are already of type int and neither is of type List[int], I tried type hinting that col is int but it didn't solve the warning.
Please sign in to leave a comment.