Steps to setup sourcery in PyCharm:
1. First click here to sign up for the sourcery account.
2. Click on “Add to PyCharm”
3. Click on “Sign Up with Google”, use any account to sign up.
4. Now click on Continue. (Note:- Sourcery provide access to Pro Features for 30 days)
5. Now on the next page you can tell about yourself to sourcery if you want or you can skip this step.
6. Now you will reach the dashboard, from here you can copy your token (check-in below image) that we will use further to set up sourcery in PyCharm.
7. Now open PyCharm then click on a file then settings and finally click on plugins to open the Marketplace tab inside plugins, check the below image for reference.
8. Now search sourcery here and install sourcery plugin.
9. After installation is complete click on “Restart IDE”.
10. After Restart PyCharm, again open settings and now you will see an option sourcery, click on that and paste the token (that we get in step 6) inside Sourcery Token option.
11. Finally click on the “OK” button, now you are ready to use sourcery in your PyCharm.
Let’s start writing the code and check how sourcery works, to improve python code quality.
So write the below code first in your PyCharm.
my_list =  for i in range(5): my_list.append(i) print(my_list)
Now after writing this code, you can see on the top, my_list is highlighting, just hover over on my_list and see sourcery is giving us the suggestion “Convert for loop into list comprehension” just click on it.
Code Output after use Sourcery:
my_list = [i for i in range(5)] pritn(my_list)
Now you can see our previous code is converted into new code here, and you can see it is now cleaner and of good quality as compare to before.
So in this way you can use sourcery to improve your python code quality and make it cleaner using sourcery smart refractors and suggestions.
You can also watch our this video, In this video, I explained everything about sourcery and how to use it in our IDE.
Check out top 5 IDE for Python Developers in 2021