Skip to content

Test the new autopep8 extension. #19885

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

Closed
3 tasks done
karthiknadig opened this issue Sep 26, 2022 · 0 comments
Closed
3 tasks done

Test the new autopep8 extension. #19885

karthiknadig opened this issue Sep 26, 2022 · 0 comments

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Sep 26, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants