Description
stringy = "foo"
f"""\
{stringy.nope()}
""" # type: ignore
(ignore that this is a true positive - my real code is much more complicated and is actually valid, the above is just a contrived example to show the core problem)
In Python 3.7 with mypy 0.782, it reports the error on the closing """
(if you remove the # type: ignore
), so it picks up the ignore directive and all is well. In Python 3.8, it reports the error on the previous line. There's no way to add # type: ignore
on that line, and adding it anywhere else has no effect.
In other cases it tends to report the error as being on the line with the opening """
… I'm not sure why in this particular, contrived example it behaves differently. But either way, it's a major problem, since there's no practical workaround for this [in my much larger, real-world code]. It's blocking the upgrade to Python 3.8 for one of my major projects.
(the output from mypy w/ Python 3.8)
test.py:4: error: "str" has no attribute "nope"
Found 1 error in 1 file (checked 1 source file)