Skip to content

Change indentation size for Pylint #130

Closed

Description

From Anton Danylchenko (@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

Activity

  1. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

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

  2. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Anton Danylchenko (@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?

  3. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From egabrum on June 14, 2017 0:0

    Anton Danylchenko (@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
    
  4. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Anton Danylchenko (@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: '    ']
    

    Don Jayamanne (@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=\"  \""
    ]
    
  5. 1st commented on Dec 21, 2017

    @1st

    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.

  6. MikhailArkhipov commented on Feb 1, 2018

    @MikhailArkhipov

    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.

  7. MikhailArkhipov commented on Feb 1, 2018

    @MikhailArkhipov

    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.

  8. locked as resolved and limited conversation to collaborators on Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions