Sublime Text 3 - Disable Python Checker warning "indentation contains tabs"
Asked Answered
P

4

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?

Puppetry answered 30/4, 2014 at 8:52 Comment(7)
dv: explain yourself pleasePuppetry
I didn't downvote, but for what it's worth: the Python Checker package page is the first hit on Google and it explained that it uses PEP8 config files right there.Capitulary
@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?Puppetry
Yes, the same config file will still be used regardless of where pep8 was installed (virtualenv, a custom directory, etc.)Capitulary
@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?Puppetry
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.Capitulary
And what's worse is that, there are some web environments using Sublime and is not configurable, until you mail the maintainer.Consultation
C
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.

Capitulary answered 30/4, 2014 at 8:54 Comment(2)
This actually did not work for me on SublimeText3. Neither as a setup.cfg file in the project folder, nor at user level.Betteanne
@Betteanne 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.Capitulary
E
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

Equidistant answered 23/12, 2014 at 2:31 Comment(2)
I want to use tabs for indentation, and align my comments manually with spaces. But thanks for the answer :)Puppetry
@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).Bethought
G
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!!! ^^

Grose answered 14/1, 2016 at 13:49 Comment(0)
V
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"]
        }
    }
}
Vespid answered 2/11, 2018 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.