forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Milestone
Description
Refs: #19654
Complexity: 1
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 ...":

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.
alexdima