Add pre-commit support for sanity checks

Use pre-commit framework [1] to run black and flake8 before the commit.
black and flake8 are managed by the pre-commit framework and they can be
run manually by the user using `pre-commit run` command.

Fix the code base with the help of black and flake8.
Fix import statements according to PEP8 guidelines [1]
Both tools have the following settings (specified in the pre-commit
configuration file):
* line length: 120 characters
* directory to exclude: ethosu/vela/tflite/ and ethosu/vela/ethos_u55_regs

Updated README.md on how to install pre-commit and how to run sanity checks.
Pipenv files have been updated including new dependencies for pre-commit.

[1]: https://www.python.org/dev/peps/pep-0008/#imports
[2]: https://github.com/pre-commit/pre-commit

Change-Id: I304d9fffdf019d390ffa396a529c8a7c2437f63d
Signed-off-by: Diego Russo <diego.russo@arm.com>
diff --git a/ethosu/vela/live_range.py b/ethosu/vela/live_range.py
index 24f1f64..54c15ba 100644
--- a/ethosu/vela/live_range.py
+++ b/ethosu/vela/live_range.py
@@ -20,7 +20,7 @@
 # Can work with either a pass packed subgraph or a scheduled subgraph.
 
 from .tensor import Tensor, MemArea
-from .nn_graph import TensorPurpose, PassPlacement
+from .nn_graph import PassPlacement
 from .high_level_command_stream_generator import calc_allowed_ofm_ifm_overlap_for_cascaded_pass
 
 
@@ -90,9 +90,9 @@
             if tens.address == 0:
                 tens.address = address
                 # Also need to set the address to the tensor's cpu/npu clones
-                if tens.cpu_tensor != None:
+                if tens.cpu_tensor is not None:
                     tens.cpu_tensor.address = address
-                if tens.npu_tensor != None:
+                if tens.npu_tensor is not None:
                     tens.npu_tensor.address = address
 
     def get_alignment(self):
@@ -115,8 +115,8 @@
             output_tensor = ps.outputs[0]
             # If the input or output tensor is tied to a Cpu tensor, i.e. a subgraph input
             # or output, fuse the live-range with the Cpu tensors' live-range instead.
-            input_tensor = input_tensor.cpu_tensor if input_tensor.cpu_tensor != None else input_tensor
-            output_tensor = output_tensor.cpu_tensor if output_tensor.cpu_tensor != None else output_tensor
+            input_tensor = input_tensor.cpu_tensor if input_tensor.cpu_tensor is not None else input_tensor
+            output_tensor = output_tensor.cpu_tensor if output_tensor.cpu_tensor is not None else output_tensor
             if not tensor_should_be_ignored(input_tensor, target_mem_area) and not tensor_should_be_ignored(
                 output_tensor, target_mem_area
             ):
@@ -221,7 +221,7 @@
     ignore_subgraph_input_output_tensors=False,
     lr_graph=None,
 ):
-    if lr_graph == None:
+    if lr_graph is None:
         lr_graph = LiveRangeGraph()
 
     if sg in lr_graph.processed_subgraphs: