How do I disable these error messages from popping up in the problems box in vs code
Go to the menu File -> Preferences -> Settings (Or open directly with Command + , or Ctrl + , ). Then in the search box at the top of the window, search for pylint Args . Click on the button Add item and add the line --disable=W .
db' pylint(import-error) showing up. This is because VS Code is not running the Virtual Environment of the app. To fix it, run cmd-shift-p (or click View -> Command Palette and run the command Python: Select Interpreter. VS Code will show you a list of Python interpreters found.
you can ignore it by adding a comment in the format # pylint: disable=[problem-code] at the end of the line where [problem-code] is the value inside pylint(...) in the pylint message – for example, abstract-class-instantiated for the problem report listed above.
If you just want to disable pylint then the updated VSCode makes it much more easier. Just hit CTRL + SHIFT + P > Select linter > Disabled Linter. Hope this helps future readers.
As others have said, you can provide a disable argument to disable a specific message. I wanted to elaborate on that.
Here is the syntax for disabling multiple messages and for providing multiple arguments, which was not immediately obvious to me from googling it:
"python.linting.pylintArgs": [ "--max-line-length=80", "--disable=W0142,W0403,W0613,W0232,R0903,R0913,C0103,R0914,C0304,F0401,W0402,E1101,W0614,C0111,C0301" ]
You stated that you started seeing way more errors once you disabled that one message. That actually might make sense according to the documentation:
Python in Visual Studio code is configured by default to use a set of linting rules that are friendly to the largest number of Python developers:
- Enable all Error (E) and Fatal (F) messages.
- Disable all Convention (C) and Refactor (R) messages.
- Disable all Warning (W) messages except the following:
- unreachable (W0101): Unreachable code
- duplicate-key (W0109): Duplicate key %r in dictionary
- unnecessary-semicolon (W0301): Unnecessary semicolon
- global-variable-not-assigned (W0602): Using global for %r but no assignment is done
- unused-variable (W0612): Unused variable %r
- binary-op-exception (W0711): Exception to catch is the result of a binary "%s" operation
- bad-format-string (W1302): Invalid format string
- anomalous-backslash-in-string (W1401): Anomalous backslash in string
- bad-open-mode (W1501): "%s" is not a valid mode for open
These rules are applied through the following default arguments passed to Pylint:
--disable=all --enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode
These arguments are passed whenever the
python.linting.pylintUseMinimalCheckers
is set totrue
(the default). If you specify a value inpylintArgs
or use a Pylint configuration file (see the next section), thenpylintUseMinimalCheckers
is implicitly set tofalse
.
In other words, PyLint is supposedly pretty lax by default in VS Code, only showing you messages for errors and a few hand-picked warnings. But when you manually set pylintArgs
to something, pylintUseMinimalCheckers
is ignored, opening the floodgates to all messages. That might be why disabling one message resulted in way more messages being shown. Then again, I'm not sure why you were seeing unused-import messages in the first place since it should have been suppressed by default according to the documentation.
Actually, this currently doesn't work: python.linting.pylintUseMinimalCheckers": true
(for me, at this particular moment in time, but hopefully it works fine for you, future reader). To get the same effect, I had to manually set pylintArgs
to the value it was supposed to be setting automatically:
"python.linting.pylintArgs": [ "--disable=all", "--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode" ]
BONUS: Here's an explanation of the list of disabled messages I use, as shown above in point 1. It's mostly taken from here:
# Disabled messages # Pointless # W0142 = *args and **kwargs support # W0403 = Relative imports # W0613 = Unused argument # W0232 = Class has no __init__ method # R0903 = Too few public methods # R0913 = Too many arguments # C0103 = Invalid name # R0914 = Too many local variables # C0304 = Final newline missing # # PyLint's module importation is unreliable # F0401 = Unable to import module # W0402 = Uses of a deprecated module # E1101 = Module x has no y member # # Already an error when wildcard imports are used # W0614 = Unused import from wildcard # # Stricter messages that can be disabled until everything else has been fixed # C0111 = Missing docstring # C0301 = Line too long
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With