skip to Main Content

.vscode/settings.json

{
    "python.linting.pylintEnabled": false,
    "python.linting.enabled": true,
    "python.linting.pylintArgs": [
        "-d",
        "C0301"
    ],
    "python.testing.unittestArgs": [
        "-v",
        "-s",
        ".",
        "-p",
        "test_*.py"
    ],
    "python.testing.pytestEnabled": false,
    "python.testing.unittestEnabled": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.autopep8"
    },
    // "python.formatting.provider": "none",
    "python.formatting.provider": "autopep8",
    "python.formatting.autopep8Args": [
        "--max-line-length",
        "79",
        "--experimental"
    ]
}

code:

if (1 == 10192310928301928301928301928301923 and rx_resp == 'aosidjaoisdjaoisdjaoisjdaoisjdaoisjdaoisjd' and 44 == 11111):
            print('aoisjdoaijsdoiajsdoaisjdoaijsdoaisjdoaisjdaoisjdiasjdoajaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

No error shown on these long lines. When I click on format I should see some error saying line too long or linter should automatically break lines into shorter format.

2

Answers


  1. Chosen as BEST ANSWER

    settings.json

    {
        "python.linting.pylintEnabled": true,
        "python.linting.enabled": true,
        "python.testing.unittestArgs": [
            "-v",
            "-s",
            ".",
            "-p",
            "test_*.py"
        ],
        "python.testing.pytestEnabled": false,
        "python.testing.unittestEnabled": true,
        "[python]": {
            "editor.defaultFormatter": "ms-python.autopep8"
        },
        "python.formatting.provider": "none"
    }
    

    I uninstalled pylint extension.

    Now some basic formatting works. eg: status =status.HTTP_200_OK after formatting will become status=status.HTTP_200_OK


  2. Install Black Formatter extension.

    set .vscode/settings.json file as follows:

    {
        "python.linting.pylintEnabled": true,
        "python.linting.enabled": true,
        "python.testing.unittestArgs": [
            "-v",
            "-s",
            ".",
            "-p",
            "test_*.py"
        ],
        "python.testing.pytestEnabled": false,
        "python.testing.unittestEnabled": true,
        "[python]": {
            "editor.defaultFormatter": "ms-python.black-formatter",
            "editor.formatOnSave": true
        },
        "black-formatter.args": [
            "--line-length",
            "79"
        ]
    }
    

    Now long lines in python will get reformatted on save.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search