0

I am currently running VS code with pylint attached for python linting. One of the warnings pylint will give is that if a line ends in whitespace then it will complain and VS code will add it in to the problems count.

If there are errors present then no warnings will be displayed until all errors are resolved, I want to add the reverse to trailing-whitespace. trailing-whitespace will display only if no other warnings are present.

I will accept answers that change VS code or pylint I do not care which. I do not have a dedicated server for pylint.

Lincoln
  • 31
  • 7
  • what is the problem with removing the trailing whitespace with `Cltr+k Ctrl+x` – rioV8 Oct 21 '22 at 08:59
  • @rioV8 OK, that works but I do not understand why. Can you please explain what Cltr+k does and why Cltr+x is not just the cut operation? – Lincoln Oct 22 '22 at 00:26
  • it is a key-binding with a prefix, remove trailing whitespace, use keybind GUI to locate the command – rioV8 Oct 22 '22 at 01:44

1 Answers1

2

It's possible to make vs-code fix trailing white spaces automatically. See https://stackoverflow.com/a/30884298/2519059

Pierre.Sassoulas
  • 3,733
  • 3
  • 33
  • 48
  • That works and I will use it if nothing else comes up but I was hoping to use this for other types of warnings as well, not just `trailing-whitespace` – Lincoln Oct 22 '22 at 00:28
  • 1
    Then there's adding a comment ``# pylint: disable=trailing-whitespace,whatever-message`` – Pierre.Sassoulas Oct 22 '22 at 07:42
  • that will disable it completely, I want it to only disable it in the presence of other warnings. I know this can be done because a statement like `foo = ` will create a syntax-error that suppresses everything else. – Lincoln Oct 26 '22 at 21:45
  • I'm pylint's maintainer, this can't be done. The syntax error suppress everything else because we can't parse the file at all when there is a syntax error. – Pierre.Sassoulas Oct 27 '22 at 07:02
  • Good to know, in that case I will use the suggestion in the main answer. – Lincoln Oct 29 '22 at 02:34