how can i retrieve column offsets for pylint messages?

半世苍凉 提交于 2019-12-13 00:06:23

问题


i want to format the output of pylint myself, so i'm calling pylint.lint.Run directly, and receiving callbacks to my add_message method. pretty smooth process, but i need the column offset for the messages to build my output (i'm highlighting sections of the offending lines).

pylint reports the line number of each message, where appropriate. however, it seems that pylint does not report any offset information - so it isn't reporting where in the line the problem was detected. under the hood pylint uses another library from logilab, called astng, which is an update to python's _ast. _ast parse nodes include offset information, but this doesn't seem to be replicated in astng.


回答1:


turns out that astng is built on ast, and the guys at logilab gave me instructions on how to patch both astng and pylint to get the offsets. links to the tickets with patches attached: astng: http://www.logilab.org/ticket/69217?vid=primary&_cwmsgid=091770639ada4996a455c48aa1eb70b3 pylint: http://www.logilab.org/ticket/69220?vid=primary&_cwmsgid=0660d106aa764a4189b1f4f1faa8aa82



来源:https://stackoverflow.com/questions/6350393/how-can-i-retrieve-column-offsets-for-pylint-messages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!