Spyder: Cannot change PEP8 settings to ignore tabs instead of 4 spaces (W191)

Created on 16 Nov 2017  路  9Comments  路  Source: spyder-ide/spyder

Description of your problem

What steps will reproduce the problem?

  1. Insert a tab instead of the four spaces indent.
  2. Do a style guide analysis.
  3. PEP8 warning W191 shows up:

What is the expected output? What do you see instead?
I looked for an option to disable this (or any other) warning. Something similar to running pep8 --ignore=W191 script.py. There seems to have been a discussion about this a while ago but I couldn't find whether the option had finally been implemented.

Please provide any additional information below

Versions and main components

  • Spyder Version: 3.2.4
  • Python Version: 3.6.3
  • Qt Version: 5.6.2
  • PyQt Version: 5.6
  • Operating system: Windows 10

Dependencies

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:

Help wanted Editor Enhancement

All 9 comments

This relates to pep8/pycodestyle, not Spyder, but a quick Google revealed this page that discusses exactly how to make pylint ignore any given error: just create edit the .pycodestyle file in your home directory, so it reads

[pycodestyle]
ignore = W191

and it should work like a charm. Just tested it with a few warnings (blank space at end of line/on blank line) that I wanted it to ignore, and it did the trick. In any case, would therefore suggest this issue be closed.

It shouldn't be hard to implement, but we don't have time to do it right now, sorry.

@CAMGerlach-Baron - I meant that I can't change the settings of the PEP8 style checker in Python. It looks like pycodestyle is a separate package. Will it integrate inside Spyder's editor?

Since our 3.2 version, we use pycodestyle instead of pep8. That's because pep8 was renamed to pycodestyle.

@ccordoba12 Thanks for clarifying. So @paragrastogi are you asking for a GUI option in the preferences, or is just adding it in the .pycodestylerc file line any other exclusion, similar to the same with pylint for static analysis fine for you?

@CAMGerlach-Baron : GUI option is better for noobs like me, but I just implemented your suggestion and it works! Thanks all for your help.

@ccordoba12 Someone related: Given the transition to pycodestyle, I'm curious as to why the "Real-time code style analysis" checkbox apparently in both master and 3.x checks for the presence of pep8 (is_pep8 = get_checker_executable("pep8")) and not pycodestyle; the former is not listed in requirements.txt for Spyder in either branch, and thus the user cannot enable pep8 checking unless they separately install pep8 for get_checker_executable to find it.

However, this check seems like it could be a holdover from the pep8 era, as when I modified the relevant line in the file plugins/editor.py in master to read get_checker_executable("pycodestyle"), the option's checkbox was enabled, and pep8 checking worked fine. Conversely, as it is now, I removed pycodestyle and installed pep8 and the checkbox was enabled, but checking was not performed. Bug? Should I submit an issue?

Any update on this? I'm new to Spyder and I really like the tab indentation. I also love the real-time code analysis. It's so much easier to see tab indentation rather than trying to align spaces (even with "show blank spaces turned on!)
Please add a GUI option for this!

@grandslammer It's quite easy to do already鈥攕ee my comment above鈥攁nd its ultimately the responsibility of a third-party package (Pycodestyle), not Spyder, so as an all-volunteer community busy maintaining Spyder 3, developing a number of major new features in Spyder 4, revamping a number of plugins, and overhauling our docs, we unfortunately really don't have the bandwidth to do this at the moment.

However, since Spyder is both a Python IDE and written in Python itself, you're welcome to add it and we'd be glad to review a PR to include it in Spyder for everyone. It shouldn't be too hard at all, and we can give you some guidance on what you need to change if you're interested. Thanks!

Was this page helpful?
0 / 5 - 0 ratings