Keep Your Code Clean using Black & Pylint & Git Hooks & Pre-commit

Keep Your Code Clean using Black & Pylint & Git Hooks & Pre-commit

This is why it is important to have a similar code formatter and code linter in order to make your git commits cleaner. Keep your code clean using Black & Pylint & Git Hooks & Pre-commit. Automate python code formatting tasks with the pre-commit framework, with black, flake8 & isort in the pipeline, and focus more on code logic.

Indispensable tools for collaborative development

Coding can be a very hard task especially when working on a project with different developers. Each member of the team has his/her own way of coding leading to very heterogeneous scripts.

This is why it is important to have a similar *code formatter *and *code linter *in order to make your git commits cleaner. This can be carried out either between the staging and committing phase or during the CI/CD chain.

In this article, we will see how to do so as a pre-commit step using git hooks.

Table of content

The summary is as follows:

  1. Black
  2. Pylint
  3. Pre-commits as Git Hooks

Black

Black is a python code formatter which style configurations are deliberately limited. It makes your code cleaner so you can focus more on the content. The code review is also more efficient since the diffs are as minor as possible.

It can be installed using the following command line:

pip install black

You can run black on any python file by typing:

Black pathtofile.py

Image by the author

coding git python linter

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

top 30 Python Tips and Tricks for Beginners

In this post, we'll learn top 30 Python Tips and Tricks for Beginners

Lambda, Map, Filter functions in python

You can learn how to use Lambda,Map,Filter function in python with Advance code examples. Please read this article

50+ Basic Python Code Examples

In this tutorial, we'll learn 50+ Basic Python Code Examples.List, strings, score calculation and more..

Live Coding of Python in the Eclipse IDE

In this tutorial, we'll learn Live Coding of Python in the Eclipse IDE. This live coding extension makes coders/programmers life easier...

Running your python code in unity

Running your python code in unity. Python offers the least code among others and is in fact 1/5 the number compared to other OOP languages. No wonder it is one of the most…