'Python PIL - Cannot find reference '[' in 'None'

I've been searching answers for this for the past hour and I'm feeling like any already asked question just barely misses my case.

I have been tinkering with the PIL library in Python, trying my first time to manipulate pixels, when all of a sudden a "Cannot find reference '[' in 'None'" Warning pops out. Naturally, I tried to read the IDE's warning and looked up simillar warnings online but only ended up with "missing imports" or "wrongly set interpreters".

This is the code in question:

from PIL import Image

with Image.open("./shoop_da_whoop.jpg") as img:
    pixel = img.load()
    width, height = img.size

    for x in range(0, width, 2):
        for y in range(0, height, 2):
            pixel[x, y] = (255, 0, 0)

    img.show()

The warning is right under the bracket: pixel*[*x, y] = (255, 0, 0). I have no clue whats going on and I will gladly try every advise.

I'm running Python 3.10 on the PyCharm version 2022.1



Solution 1:[1]

PyCharm relies on typeshed stubs here and there is a mistake (or rather a missing type annotation) in them - load() method is declared to return None

class Image:
    ...
    def load(self) -> None: ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pavel Karateev