From the course: Create an Open-Source Project in Python

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Formatting your code with Black

Formatting your code with Black - Python Tutorial

From the course: Create an Open-Source Project in Python

Formatting your code with Black

- [Instructor] Now that we have learned what Black is, let's put it into practice. First of all, we want to make sure we have Black installed by using this command. Now, let's use Black to format test of py. Let us remind ourselves what is the file by opening it in Vim. Okay, to format test of py, we only need a single Black command. Let's first use a special command to check if tests the py fulfills the Black code style. As you can see, we get a prompt saying that tests the py will be reformatted. So, let's check what exit code we have. The check command exists with code one, which means that it does not fulfill the Black code style. So, let's do it now. Now, we get the all done prompt. Test the py has been reformatted. Let's check the reformatted file using Vim. Can you spot the difference? It will be more obvious if you use git, as I am here. All you need to do is to use the git diff command. As you can see, a…

Contents