I just had this problem…
breaklines worked for me, though you do need to set it to true – the default is false:
\lstinputlisting[style=Python,
caption=My Class,
label={mine.py},
breaklines=true,
]{../python/mine.py}
is pretty much what I used