14

I didn't find an answer to this question on the web, so I'll say it up front; this is NOT a question about SublimeLinter, and I do NOT want to format my python code according to the PEP8 standards.

How to disable the warning "Indentation contains tabs" in the Python Checker package?

Jonathan H
  • 7,591
  • 5
  • 47
  • 80
  • 1
    dv: explain yourself please – Jonathan H Apr 30 '14 at 08:53
  • I didn't downvote, but for what it's worth: the [Python Checker package page](https://sublime.wbond.net/packages/Python%20Checker) is the first hit on Google and it explained that it uses PEP8 config files right there. – Martijn Pieters Apr 30 '14 at 08:57
  • @MartijnPieters You are right actually... I'll probably delete my question then. I can't install `pep8` through pip on my machine though, as I do not have root access, will the configuration file still be read if I put it in `~/.config/pep8`? – Jonathan H Apr 30 '14 at 09:00
  • 1
    Yes, the same config file will still be used regardless of where `pep8` was installed (virtualenv, a custom directory, etc.) – Martijn Pieters Apr 30 '14 at 09:01
  • 1
    @MartijnPieters Thanks a lot for your help, I really don't understand this pep8 nonsense, forcing a language syntax at such a deep level is so intrusive, I've never seen that. I guess I need to read up on that, or remove the syntax checker altogether. Do you think I should delete my question? – Jonathan H Apr 30 '14 at 09:10
  • 2
    I don't see a reason to delete it, no. PEP8 is a guideline, it is not enforced; that's why the checker is also *configurable*. The guideline is born from experience, however, and if you are a Python beginner I'd heed it. – Martijn Pieters Apr 30 '14 at 09:12
  • And what's worse is that, there are some web environments using Sublime and is not configurable, until you mail the maintainer. – user26742873 Jan 04 '21 at 02:05

4 Answers4

22

The project uses the standard pycodestyle (formerly pep8) configuration files; just add an ignore line:

[pycodestyle]
ignore = W191

where W191 is the error code for indentation contains tabs.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • This actually did not work for me on SublimeText3. Neither as a setup.cfg file in the project folder, nor at user level. – AruniRC Oct 29 '16 at 07:48
  • @AruniRC the pep8 tool was renamed to pycodestyle. The linked documentation is up-to-date for that change. I'll update this answer later when not on mobile. – Martijn Pieters Oct 29 '16 at 08:41
6

You can use set sublime as: view -> Indentation -> Convert indentation to spaces

This will enable your tabs to be converted to 4(according your setting) spaces. It works on my machine.

And modify the existing tabs in the file to spaces: View -> Indentation -> Convert Indentation to Spaces

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
Solomon
  • 103
  • 1
  • 1
  • I want to use tabs for indentation, and align my comments manually with spaces. But thanks for the answer :) – Jonathan H Dec 23 '14 at 14:13
  • 1
    @Sh3ljohn FYI, In Python 3, mixed tabs and spaces in a file is a Syntax Error, so you should plan to indent with one or the other, and the Python community has settled on spaces. I still use tabs personally, but I use several techniques to avoid mixed indentation (no hanging indents, comments on line above). – Jason R. Coombs Jun 12 '15 at 18:42
2

in sublime 2 select Prefences > Package setting > Python Fake8 Lint. Chose Setting-default. At this opened file, find line 81.

// skip errors and warnings (e.g. ["E303", "E4", "W"])
"ignore": [],`

then add "W191" in square brackets [] and save.

Good luck!!! ^^

hieutran89
  • 21
  • 2
1

For SublimeText 3 & pycodestyle:

Select Preferences > Package Settings > SublimeLinter > Settings and add / change to this:

// SublimeLinter Settings - User
{
    "linters": {
    // The name of the linter you installed
        "pycodestyle": {
            "ignore": ["W191"]
        }
    }
}
drct
  • 361
  • 4
  • 12