Skip to content

Test the new black formatter extension #18996

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 Apr 25, 2022 · 2 comments
Closed
3 tasks done

Test the new black formatter extension #18996

karthiknadig opened this issue Apr 25, 2022 · 2 comments

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Apr 25, 2022

Refs: #18890

Complexity: 1

Create Issue


Requirements

Install the following extension: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
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 "Black Formatter":

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 > Black Formatter.

@karthiknadig karthiknadig added this to the April 2022 milestone Apr 25, 2022
@karrtikr karrtikr removed their assignment Apr 26, 2022
@lszomoru
Copy link
Member

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

This should read, "You should install black in your environment.", correct?

@lszomoru lszomoru removed their assignment Apr 26, 2022
@karthiknadig
Copy link
Member Author

black python library is bundled with the Black Formatter extension. So, you don't have to install black using pip or conda in your environment. You can always install it in your environment, but it is not needed.

@roblourens roblourens removed their assignment Apr 26, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
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