Fix line offsets with ScopeMismatch errors#4929
Conversation
| p = self._pyfuncitem.session.fspath.bestrelpath(fs) | ||
| args = _format_args(factory) | ||
| lines.append("%s:%d: def %s%s" % (p, lineno, factory.__name__, args)) | ||
| lines.append("%s:%d: def %s%s" % (p, lineno + 1, factory.__name__, args)) |
There was a problem hiding this comment.
this is incorrect for multi-decorated things and in python3.8 (where the ast now points us at the function itself)
There was a problem hiding this comment.
The test works for me with Python 3.8.0a2+ also.
Was this changed in the last days only?
Have to check multi-decorated things, but in general this is not the first time that line numbers are off, because they are zero-based internally..
There was a problem hiding this comment.
hmmm I was expecting python/cpython#9731 to change the outcome here 🤔
There was a problem hiding this comment.
Worth investigating probably, but since tests are passing also with 3.8-dev, I think this is fine for now.
| "* def arg2*", | ||
| "* def arg1*", | ||
| "test_receives_funcargs_scope_mismatch.py:6: def arg2(arg1)", | ||
| "test_receives_funcargs_scope_mismatch.py:2: def arg1()", |
There was a problem hiding this comment.
Hmm strange, def arg1 to me looks like in line 3, and def arg2 on line 7... 🤔
There was a problem hiding this comment.
It is referring to the decorator.
I've just tried with py38 again (given @asottile's comment), but there it is also line 6 and 2.
I think this is fine, since the error comes from the @fixture after all.
(But it refers to the first fixture)
The -1 is coming from vim/vim@461a7fc#diff-de9ab8906fef668ed8042046e0a1eb02L8145 btw.
Fixes #4928.