diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c6e61f234695fca0a0c33ce65fc2a46b3966e2ae..ac4119bbc62f9ec5474717097dff62a786944e7c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -5,7 +5,7 @@ repos:
     rev: v14.0.6
     hooks:
     -   id: clang-format
-        args: ['--style={BasedOnStyle: Google, SortIncludes: false}']
+        args: [--style=Google]
 -   repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.3.0
     hooks:
diff --git a/README.md b/README.md
index 16116bfa2394daae542b3ec9586e8f1d9fe28285..96eca4786bc4756cc16bd428bd775c19e65f29ad 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@ EigenPy — Efficient Python bindings between Numpy/Eigen
   <a href="https://anaconda.org/conda-forge/eigenpy"><img src="https://img.shields.io/conda/dn/conda-forge/eigenpy.svg" alt="Conda Downloads"/></a>
   <a href="https://anaconda.org/conda-forge/eigenpy"><img src="https://img.shields.io/conda/vn/conda-forge/eigenpy.svg" alt="Conda Version"/></a>
   <a href="https://badge.fury.io/py/eigenpy"><img src="https://badge.fury.io/py/eigenpy.svg" alt="PyPI version"></a>
+  <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
 </p>
 
 **EigenPy** is an open source framework which allows to bind the famous [Eigen](http://eigen.tuxfamily.org) C++ library in Python.
diff --git a/benchmarks/bench-switch.py b/benchmarks/bench-switch.py
index 289a95c691b65d190057af70ceeec97a12ac0a48..19e1ec75fe2af09590c838b2ee14ef0034e4f7b8 100644
--- a/benchmarks/bench-switch.py
+++ b/benchmarks/bench-switch.py
@@ -3,8 +3,8 @@ from __future__ import print_function
 import eigenpy
 import numpy as np
 
-import time
-import timeit
+import time  # noqa
+import timeit  # noqa
 
 from IPython import get_ipython
 
diff --git a/python/eigenpy/__init__.py b/python/eigenpy/__init__.py
index 328c005e8ed921b846f47fbe9b1ae92947244403..f68cfdb865c0587ac66b6fee950751053712fb40 100644
--- a/python/eigenpy/__init__.py
+++ b/python/eigenpy/__init__.py
@@ -2,5 +2,5 @@
 # Copyright (c) 2017-2021 CNRS INRIA
 #
 
-from .eigenpy_pywrap import *
-from .eigenpy_pywrap import __version__, __raw_version__
+from .eigenpy_pywrap import *  # noqa
+from .eigenpy_pywrap import __version__, __raw_version__  # noqa
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..ea6e1878377982b3bd3ec7f58007e40a86a23a54
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,4 @@
+[flake8]
+extend-ignore = E203
+max-line-length = 88
+exclude = cmake/.docs/cmake.py
diff --git a/unittest/eigen_ref.cpp b/unittest/eigen_ref.cpp
index 17bafe8b52edb3f5b34e0daa2ba991dd8a9cd732..78896b9a376ee15228beca98bc7e36ef776d6959 100644
--- a/unittest/eigen_ref.cpp
+++ b/unittest/eigen_ref.cpp
@@ -6,6 +6,7 @@
 #include <iostream>
 
 #include "eigenpy/eigenpy.hpp"
+// include main header first
 #include "eigenpy/eigen-from-python.hpp"
 
 using namespace Eigen;
diff --git a/unittest/python/test_LLT.py b/unittest/python/test_LLT.py
index 21cf27528c0fdd4287258a96321577b9bad93f41..63f944475e6dc7f2cd5aa55ef61332bff28f70d0 100644
--- a/unittest/python/test_LLT.py
+++ b/unittest/python/test_LLT.py
@@ -1,7 +1,6 @@
 import eigenpy
 
 import numpy as np
-import numpy.linalg as la
 
 dim = 100
 A = np.random.rand(dim, dim)
diff --git a/unittest/python/test_complex.py b/unittest/python/test_complex.py
index 0f1eba2ea8a8cec467693329611c5699be892fe7..cbe8032b078a6c1099614e8c03e06d59091c10f6 100644
--- a/unittest/python/test_complex.py
+++ b/unittest/python/test_complex.py
@@ -1,7 +1,7 @@
 from __future__ import print_function
 
 import numpy as np
-from complex import *
+from complex import switchToNumpyArray, real, imag, ascomplex
 
 switchToNumpyArray()
 
diff --git a/unittest/python/test_dimensions.py b/unittest/python/test_dimensions.py
index 83b40383e1eae5ffc58d0b44bd2fc56364c9ebb9..97312dcc93c9917c5f1fabf41dde18ea9806a346 100644
--- a/unittest/python/test_dimensions.py
+++ b/unittest/python/test_dimensions.py
@@ -1,7 +1,6 @@
 from __future__ import print_function
 
 import eigenpy
-import numpy as np
 
 quat = eigenpy.Quaternion()
 # By default, we convert as numpy.matrix
diff --git a/unittest/python/test_eigen_ref.py b/unittest/python/test_eigen_ref.py
index 0ff13547fa702625d9ab758bd6e8852a91d57928..0802643624c8bec22d5da501a0056146206fca8a 100644
--- a/unittest/python/test_eigen_ref.py
+++ b/unittest/python/test_eigen_ref.py
@@ -1,5 +1,14 @@
 import numpy as np
-from eigen_ref import *
+from eigen_ref import (
+    printMatrix,
+    asRef,
+    asConstRef,
+    fill,
+    getBlock,
+    editBlock,
+    modify_block,
+    has_ref_member,
+)
 
 
 def test(mat):
diff --git a/unittest/python/test_geometry.py b/unittest/python/test_geometry.py
index 80ebf26048f042c4dc485c2c2474f8f6468bef34..c2bd1b1addced6caa76040b320a672d30ba74dfc 100644
--- a/unittest/python/test_geometry.py
+++ b/unittest/python/test_geometry.py
@@ -1,8 +1,15 @@
 from __future__ import print_function
 
-from geometry import *
+from geometry import (
+    AngleAxis,
+    Quaternion,
+    testOutAngleAxis,
+    testInAngleAxis,
+    testOutQuaternion,
+    testInQuaternion,
+)
 import numpy as np
-from numpy import cos, sin
+from numpy import cos
 
 verbose = True
 
diff --git a/unittest/python/test_return_by_ref.py b/unittest/python/test_return_by_ref.py
index c93bebc159635ed7aa77cfd4598c8ba35e0d8709..dff108ce9793c7b127a60f067ec4ae2b187484df 100644
--- a/unittest/python/test_return_by_ref.py
+++ b/unittest/python/test_return_by_ref.py
@@ -21,7 +21,7 @@ def test_shared(mat):
     try:
         m_const_ref.fill(2)
         assert False
-    except:
+    except Exception:
         assert True
 
 
@@ -43,7 +43,7 @@ def test_not_shared(mat):
     try:
         m_const_ref.fill(2)
         assert True
-    except:
+    except Exception:
         assert False
 
 
diff --git a/unittest/python/test_self_adjoint_eigen_solver.py b/unittest/python/test_self_adjoint_eigen_solver.py
index ae98605211e379a10142db08dfd6cb2d9fd8fa1c..7e5ff1b86598640da530548c8cc053bf198abb5c 100644
--- a/unittest/python/test_self_adjoint_eigen_solver.py
+++ b/unittest/python/test_self_adjoint_eigen_solver.py
@@ -1,9 +1,8 @@
 import eigenpy
 
-eigenpy.switchToNumpyArray()
-
 import numpy as np
-import numpy.linalg as la
+
+eigenpy.switchToNumpyArray()
 
 dim = 100
 A = np.random.rand(dim, dim)
diff --git a/unittest/python/test_user_type.py b/unittest/python/test_user_type.py
index 76e5dfeaf99f798a16da098f318b19707e9e8bf1..6815673c17c4436d7b03f31a7ed611024f11340a 100644
--- a/unittest/python/test_user_type.py
+++ b/unittest/python/test_user_type.py
@@ -14,11 +14,12 @@ def test(dtype):
     assert (mat == mat_copy).all()
     assert not (mat != mat_copy).all()
 
-    #  if version.parse(np.__version__) >= version.parse("1.21.0"): # check if it fixes for new versio of NumPy
-    #    mat.fill(mat.dtype.type(20.))
-    #    mat_copy = mat.copy()
-    #    assert((mat == mat_copy).all())
-    #    assert(not (mat != mat_copy).all())
+    # if version.parse(np.__version__) >= version.parse("1.21.0"):
+    # # check if it fixes for new version of NumPy
+    # mat.fill(mat.dtype.type(20.0))
+    # mat_copy = mat.copy()
+    # assert (mat == mat_copy).all()
+    # assert not (mat != mat_copy).all()
 
     mat_op = mat + mat
     mat_op = mat.copy(order="F") + mat.copy(order="C")
@@ -28,7 +29,7 @@ def test(dtype):
     mat_op = mat.dot(mat.T)
     mat_op = mat / mat
 
-    mat_op = -mat
+    mat_op = -mat  # noqa
 
     assert (mat >= mat).all()
     assert (mat <= mat).all()
@@ -47,7 +48,7 @@ def test_cast(from_dtype, to_dtype):
     np.can_cast(from_dtype, to_dtype)
 
     from_mat = np.zeros((rows, cols), dtype=from_dtype)
-    to_mat = from_mat.astype(dtype=to_dtype)
+    to_mat = from_mat.astype(dtype=to_dtype)  # noqa
 
 
 test(user_type.CustomDouble)