Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change indentation size for Pylint #130

Closed
DonJayamanne opened this issue Nov 13, 2017 · 7 comments
Closed

Change indentation size for Pylint #130

DonJayamanne opened this issue Nov 13, 2017 · 7 comments
Assignees
Labels
area-linting feature-request Request for new features or functionality

Comments

@DonJayamanne
Copy link

From @1st on June 12, 2017 14:0

Hello.

I set a setting "editor.tabSize": 2, but pythonVSCode doesn't recognize this settings. I see the error message from the pylint about wrong indentation, something like this:

[pylint] W0311:Bad indentation. Found 6 spaces, expected 12

Tried to find the proper option to pass to the "python.linting.pylintArgs": [] but found nothing. Can you please let me know how to push pylint to check syntax based on the two-space indentation instead of four? Also it will be good to use theeditor.tabSize setting in the pythonVSCode to pass through to the pylint.

Thanks.

Copied from original issue: DonJayamanne/pythonVSCode#1015

@DonJayamanne
Copy link
Author

Pylint is a separate python package. You will need to configure pylint using the relevant configuration files.

@DonJayamanne
Copy link
Author

From @1st on June 13, 2017 7:41

But it adds complexity. In each my project I need to add a file with config fot pylint and other libs? It's unreal if I have 10 projects.

In Sublime I change indentation size and it automatically pass this parameter to the pylint. I need nothing to configure. I know that it's extra work that you need to do to initialize the pylint with the correct parameters- but I think that it worth it.

PS. I don't know which parameter I need to pass to pylint as a custom argument to change the indentation size. Can you help with it?

@DonJayamanne
Copy link
Author

From @egabrum on June 14, 2017 0:0

@1st I include a pylintrc file in the root of my workspace with these lines:

# String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1
# tab).
indent-string='   '

# Number of spaces of indent required inside a hanging  or continued line.
indent-after-paren=3

@DonJayamanne
Copy link
Author

From @1st on July 4, 2017 15:34

I finally decided to execute command pylint --long-help to configure this option myself.

It's what I found there:

    --indent-string=<string>
                        String used as indentation unit. This is usually "
                        " (4 spaces) or "\t" (1 tab). [current: '    ']

@DonJayamanne can you please adopt this option to the current size of indentation that set by the configuration option editor.tabSize? It will be fine to pass this automatically to the pylint linter as a mandatory option.

Currently I solved my problem with 2 spaces in my project with this configuration option:

"python.linting.pylintArgs": [
    "--indent-string=\"  \""
]

@1st
Copy link

1st commented Dec 21, 2017

Dear developers. As you can see - I've proposed a solution for the problem. But it's manual solution.

I wish to see it automatically made by vscode: every time when you run the pylint please add next argument to it: --indent-string=\" \". It will be the number of spaces that user set in the "editor.tabSize" setting. If it's set to 2 - then two space will be passed. If it's set to 4 - then four spaces will be passed to the pylint tool.

As for me it looks very easy to implement. The problem that I didn't make any change in vscode before and can't propose a patch for it. If you will need my help - just let me know and we can do it together, or I can explain how to solve this issue. But I don't have extended knowledge of the project to make changes in code myself.

@MikhailArkhipov MikhailArkhipov self-assigned this Jan 5, 2018
@MikhailArkhipov
Copy link

Propagating individual settings as arguments has side effects. For example, team may have standard set to 4 and yet we will not flag incorrect formatting since we'll be passing 2 instead and git commit hooks will then reject the code.

TS Lint does not follow editor settings. It follows its tsfmt.json configuration file so formatting would be consisted with the team settings checked in into the source control. Similarly, in big Visual Studio linting rules are typically separate from the editor settings.

@MikhailArkhipov
Copy link

In the upcoming release default (simplified) pylint rules exclude formatting and styling so it won't be complaining about tab sizes, see #554. However, we do not want to tie linter rules to edit settings since it would be inconsistent with behavior of other languages and editors.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants