palantir / python-language-server

An implementation of the Language Server Protocol for Python
MIT License
2.61k stars 283 forks source link

Use Pylint read from stdin feature #796

Closed twmr closed 4 years ago

twmr commented 4 years ago

Since version 2.4 pylint has support for reading files from memory (stdin) by using the --from-stdin cmd line option

    --from-stdin        Interpret the stdin as a python script, whose filename
                        needs to be passed as the module_or_package argument.

https://github.com/palantir/python-language-server/blob/143d9931cd0cabe92e1370b344cb02c406e0b0f1/pyls/plugins/pylint_lint.py#L51

goanpeca commented 4 years ago

Hi @thisch, what are you suggesting :-) ?

twmr commented 4 years ago

pylint can now read the source code from stdin in contrast to reading it from a normal file. Reading from stdin is already supported by many linters, but pylint got support for it last year.

To read the file from stdin you would have to call it like

cat  source.py  | pylint --from-stdin  source.py

IMO this new feature should be used in pyls, because then pyls could report issues of unsaved changes in files. See line 50 of pylint_lint.py