Skip to content

Test the new autopep8 extension. #19885

@karthiknadig

Description

@karthiknadig

Refs: #19654

Complexity: 1

Create Issue


Requirements

Install the following extension: https://github.com/microsoft/vscode-autopep8/suites/8479132203/artifacts/376874338
NOTE: Currently only pre-release version in available.

Verification

You should not have to install black in your environment. Try this for example:

Create a python file with following content:

import unittest
import re
class TestSum(unittest.TestCase):
    def test_sum(self):
        self.assertEqual(sum([1, 2, 3]), 6, "Should be 6")
    def test_sum_tuple(self):
        self.assertEqual(sum((1, 2, 3)), 6, "Should be 6")
if __name__ == "__main__":
    unittest.main()
    print(x)

Right click in the document and select "Format Document With ...":
image

You should see two formatters, Select "autopep8":

That is it! If you want this to happen automatically, set Black as the default formatter, and enable format on save. Then on save the content will be formatted.

If you run into any problems, you should be able to see logs under Output > autopep8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions