python-lsp / pylsp-mypy

Mypy plugin for the Python LSP Server.
MIT License
129 stars 37 forks source link

Force not pretty output #83

Closed vusalalishov closed 4 months ago

vusalalishov commented 6 months ago

The projects using mypy in CI/CD pipeline usually have pretty = true set in their mypy configuration and this breaks the parsing of the output in the plugin itself.

This PR will force the non-pretty output of mypy diagnostics.

TheJJ commented 2 months ago

can you please release a new version containing this patch?

i had a fun journey of debugging emacs eglot, python-lsp-server and finally a pylsp-mypy parser error due to this missing flag... the report in eldoc and flycheck-list-errors was truncated due to the line wraps that were not parsed correctly due to the pretty mode.

for reference, my final debugging script to invoke and test this lsp plugin to figure out the mypy output parsing error:

import sys
import logging

from pylsp_mypy import plugin
import pprint

from argparse import ArgumentParser, Namespace

cli = ArgumentParser()
cli.add_argument("root", help="workspace root directory")
cli.add_argument("filepath", help="path to the file to analyze with mypy")

args = cli.parse_args()

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

workspace = Namespace(root_path=args.root)
document = Namespace(path=args.filepath)

pprint.pprint(plugin.get_diagnostics(workspace, document, {}, True))
Richardk2n commented 2 months ago

Has been released.