Reformat the source code using black

Change-Id: I54e7f6b9a60e4caa42158bf6259c671bc800e4a8
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..aa4949a
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,2 @@
+[tool.black]
+line-length = 100
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..3f13854
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[flake8]
+max_line_length = 100
diff --git a/src/charm.py b/src/charm.py
index 50707a5..d40d3b3 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -22,8 +22,8 @@
 
 class CinderCharmBase(CinderStoragePluginCharm):
 
-    PACKAGES = ['cinder-common']
-    MANDATORY_CONFIG = ['protocol']
+    PACKAGES = ["cinder-common"]
+    MANDATORY_CONFIG = ["protocol"]
     # Overriden from the parent. May be set depending on the charm's properties
     stateless = True
     active_active = True
@@ -33,29 +33,30 @@
 
     def cinder_configuration(self, config):
         # Return the configuration to be set by the principal.
-        backend_name = config.get('volume-backend-name',
-                                  self.framework.model.app.name)
-        volume_driver = 'cinder.volume.drivers.storpool.StorPoolDriver'
+        backend_name = config.get("volume-backend-name", self.framework.model.app.name)
+        volume_driver = "cinder.volume.drivers.storpool.StorPoolDriver"
         options = [
-            ('volume_driver', volume_driver),
-            ('volume_backend_name', backend_name),
+            ("volume_driver", volume_driver),
+            ("volume_backend_name", backend_name),
         ]
 
-        if config.get('use-multipath'):
-            options.extend([
-                ('use_multipath_for_image_xfer', True),
-                ('enforce_multipath_for_image_xfer', True)
-            ])
+        if config.get("use-multipath"):
+            options.extend(
+                [
+                    ("use_multipath_for_image_xfer", True),
+                    ("enforce_multipath_for_image_xfer", True),
+                ]
+            )
 
         return options
 
 
 @charm_class
 class CinderStorPoolCharm(CinderCharmBase):
-    release = 'yoga'
+    release = "yoga"
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     # main(get_charm_class_for_release())
     # main(CinderStorPoolCharm)
     main(get_charm_class(release="yoga"))
diff --git a/tests/tests.py b/tests/tests.py
index 69507e1..a0458e7 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -22,9 +22,10 @@
 class CinderStorPoolTest(CinderBackendTest):
     """Encapsulate StorPool tests."""
 
-    backend_name = 'StorPool'
+    backend_name = "StorPool"
 
     expected_config_content = {
-        'StorPool': {
-            'volume-backend-name': ['StorPool'],
-        }}
+        "StorPool": {
+            "volume-backend-name": ["StorPool"],
+        }
+    }
diff --git a/tox.ini b/tox.ini
index 2cb7d3b..0ee1b02 100644
--- a/tox.ini
+++ b/tox.ini
@@ -25,6 +25,12 @@
 # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
 minversion = 3.2.0
 
+[defs]
+pyfiles =
+  src
+  tests
+  unit_tests
+
 [testenv]
 setenv = VIRTUAL_ENV={envdir}
          PYTHONHASHSEED=0
@@ -146,7 +152,14 @@
 commands =
     functest-run-suite --keep-model --bundle {posargs}
 
-[flake8]
-# Ignore E902 because the unit_tests directory is missing in the built charm.
-ignore = E402,E226,W503,W504,E902
-max-line-length = 100
+[testenv:black-reformat]
+deps =
+  black >= 22, < 23
+commands =
+  black {[defs]pyfiles}
+
+[testenv:black]
+deps =
+  black >= 22, < 23
+commands =
+  black --check {[defs]pyfiles}
diff --git a/unit_tests/test_cinder_storpool_charm.py b/unit_tests/test_cinder_storpool_charm.py
index 44b44cd..2399857 100644
--- a/unit_tests/test_cinder_storpool_charm.py
+++ b/unit_tests/test_cinder_storpool_charm.py
@@ -19,32 +19,27 @@
 
 
 class TestCinderStorPoolCharm(unittest.TestCase):
-
     def setUp(self):
         self.harness = Harness(CinderCharmBase)
         self.addCleanup(self.harness.cleanup)
         self.harness.begin()
         self.harness.set_leader(True)
-        backend = self.harness.add_relation('storage-backend', 'cinder')
-        self.harness.update_config({'volume-backend-name': 'test'})
-        self.harness.add_relation_unit(backend, 'cinder/0')
+        backend = self.harness.add_relation("storage-backend", "cinder")
+        self.harness.update_config({"volume-backend-name": "test"})
+        self.harness.add_relation_unit(backend, "cinder/0")
 
     def test_cinder_base(self):
-        self.assertEqual(
-            self.harness.framework.model.app.name,
-            'cinder-storpool')
+        self.assertEqual(self.harness.framework.model.app.name, "cinder-storpool")
         # Test that charm is active upon installation.
         self.harness.update_config({})
-        self.assertTrue(isinstance(
-            self.harness.model.unit.status, ActiveStatus))
+        self.assertTrue(isinstance(self.harness.model.unit.status, ActiveStatus))
 
     def test_multipath_config(self):
-        self.harness.update_config({'use-multipath': True})
-        conf = dict(self.harness.charm.cinder_configuration(
-            dict(self.harness.model.config)))
-        self.assertEqual(conf['volume_backend_name'], 'test')
-        self.assertTrue(conf.get('use_multipath_for_image_xfer'))
-        self.assertTrue(conf.get('enforce_multipath_for_image_xfer'))
+        self.harness.update_config({"use-multipath": True})
+        conf = dict(self.harness.charm.cinder_configuration(dict(self.harness.model.config)))
+        self.assertEqual(conf["volume_backend_name"], "test")
+        self.assertTrue(conf.get("use_multipath_for_image_xfer"))
+        self.assertTrue(conf.get("enforce_multipath_for_image_xfer"))
 
     def test_cinder_configuration(self):
         # Add check here that configuration is as expected.