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/tflite_writer.py b/ethosu/vela/tflite_writer.py
index f55d1ce..1f07242 100644
--- a/ethosu/vela/tflite_writer.py
+++ b/ethosu/vela/tflite_writer.py
@@ -18,7 +18,13 @@
 # Description:
 # Functions used to write to a TensorFlow Lite format file. Supports adding in file identifiers.
 
+import numpy as np
 import flatbuffers
+from flatbuffers.builder import UOffsetTFlags
+
+# ugh, the python flatbuffer interface is missing a method to add in file identifier. patching it in here:
+import flatbuffers.number_types as N
+from flatbuffers import encode
 
 from .tflite import Tensor
 from .tflite import QuantizationParameters
@@ -28,22 +34,14 @@
 from .tflite import Operator
 from .tflite import Buffer
 from .tflite import Metadata
-
-import numpy as np
-
 from .tflite_mapping import datatype_inv_map, builtin_operator_inv_map, custom_prefix, BuiltinOperator
 from .nn_graph import PassPlacement
 from .tensor import TensorPurpose, MemArea
-from flatbuffers.builder import UOffsetTFlags
 
 tflite_version = 3
 tflite_file_identifier = "TFL" + str(tflite_version)
 
 
-import flatbuffers.number_types as N
-from flatbuffers import encode
-
-
 def FinishWithFileIdentifier(self, rootTable, fid):
     if fid is None or len(fid) != 4:
         raise Exception("fid must be 4 chars")
@@ -163,8 +161,8 @@
                 tf_code, opt_serializer = builtin_operator_inv_map[code]
             except KeyError:
                 print(
-                    "Warning: Writing operation %s, which does not have a direct TensorFlow Lite mapping, as a custom operation"
-                    % (code,)
+                    "Warning: Writing operation %s, which does not have a direct TensorFlow Lite mapping,"
+                    "as a custom operation" % (code,)
                 )
                 tf_code, opt_serializer = builtin_operator_inv_map[custom_prefix]