how can i retrieve column offsets for pylint messa

2019-08-02 13:02发布

问题:

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



标签: pylint