It's a little hard to guess without a complete file, ideally in some format that accurately stores bytes.
:1:40 refers to the first line, char position 40. Line length - 38 characters.
Thus, suspicion falls on the newline marker.
Most likely, a new line (single char) is not recognized, and Python (not flake8 btw) processes this line and the next and one long line. So the error is in column 40.
2 , char .
, .