Script works perfectly, random error in PyCharm

I’m half afraid to ask, but, why am I getting a random error. It works perfectly, sometimes it shows an error and sometimes PyCharm is happy with the script. Always works correctly. The program is long as it has a big dictionary in it. If needed I can post the full program. This is an isolated group of code, sorting the dictionary values into a new dictionary 'hex_dictionary, so it is ordered by low to high color value.

color = {...}  # Main dictionary
# Sort the dictionary by values
sorted_values = sorted(color.values())
hex_dictionary= {}  # hex sorted dictionary
for i in sorted_values:
    for k in color.keys():
        if color[k] == i:
            hex_dictionary[k] = color[k]

print(hex_dictionary.keys())  # This works, color key
print(hex_dictionary.values())  # This works, hex key
print(color.keys())  # This works, color key
print(color.values())  # This works, hex key

Output error in PyCharm…offending code above ’ hex_dictionary[k] = color[k]'. I believe the problem is in the color[k] part. That’s what is highlighted.

Class 'dict' does not define '__getitem__', so the '[]' operator cannot be used on its instances

Thanks, maybe it’s just PyCharm.

It’s not addressing PyCharm issue but the solution: alternatively one can sort color.items() by value and construct new dictionary:

dict(sorted(color.items(), key=lambda item: item[1]))

This is a message of the linter built into PyCharm. It seems to be a bug known for more that two years already. I got to the description from the first result in Google search:

Thanks! I know to ignore that warning. PyCharm is not perfect, but works well. Then the question comes to mind. Why have they not fixed this error?
I heard your suggestion to google errors or problems first. I wiil do that.