1

I am using the Pylint linter package in atom on Windows when ever i use tab indentation it gives me the following error:

W0311 Bad indentation Found 1 spaces, Expected 4.

even though atom is using a 'tab' (tab type is hard)

I created a .pylintrc Pylint configuration file using :

pylint --generate-rcfile > .pylintrc

and added

--disable=W0311

under the [message control] section.

Also in the settings of the atom package i entered the location of the RC config file. I restarted atom and it's still producing the error message W0311 on every line.

How can I get rid of this message?

Or b
  • 666
  • 1
  • 5
  • 22
irfan43
  • 46
  • 3
  • Why do you want to use tabs? If you change the `tab type` to `soft` the warning is going. (Probably need to run `Change all tabs to spaces` to replace existing tabs. – rfkortekaas Jan 07 '21 at 09:22
  • I Prefer tabs, Is there anything wrong in using tabs then spaces? – irfan43 Jan 07 '21 at 09:23
  • 2
    See [this discussion](https://stackoverflow.com/questions/120926/why-does-python-pep-8-strongly-recommend-spaces-over-tabs-for-indentation) for some background (or better the discussions about PEP 8. All official (and almost) python packages are using this convention. Mixing tabs and spaces is not an option so when editing something from another source you are likely to get `IndentationError`s. – rfkortekaas Jan 07 '21 at 09:30
  • 1
    thanks, I get it but when i work on my own personal use code i stick to tabs as they are tabs before. I will be switching to spaces moving forward – irfan43 Jan 07 '21 at 10:16

2 Answers2

1

You could always disable specific messages using this template in the first line (top line) of your code:

#pylint: disable=<error_name/number>,..,..

In your example you could use:

#pylint: disable=W0311

Pylint recognizes this format and disables this message, so when you run Pylint it should not check for this error.

Or b
  • 666
  • 1
  • 5
  • 22
0

I should add the W0311 to the

disable=W0311

add a "," to the end is the config file already has something there which if ur using pylint to generate it, it will have a big list

irfan43
  • 46
  • 3