Open
Description
At runtime, this displays the image with no errors. It should type-check without errors, but it doesn't.
import tkinter
with open("my_image.png", "rb") as file:
data = file.read()
label = tkinter.Label()
image = tkinter.PhotoImage()
image.put(data, to=(0, 0)) # This line is a mypy error
label.config(image=image)
label.pack()
tkinter.mainloop()
Mypy error is:
asd.py:8: error: Argument 1 to "put" of "PhotoImage" has incompatible type "bytes"; expected "str | list[str] | list[list[str]] | list[tuple[str, ...]] | tuple[str, ...] | tuple[list[str], ...] | tuple[tuple[str, ...], ...]" [arg-type]