Repository: janehmueller/python-json-config

Issue:
Serialization methods (JSON)
It would be great if a parsed configuration could also be transformed back into a dictionary or json string format. For example like: `config.dump()` or `config.to_json()`

Discussion:

Patch:
diff --git a/python_json_config/__init__.py b/python_json_config/__init__.py
index 567dcba..4023d6d 100644
--- a/python_json_config/__init__.py
+++ b/python_json_config/__init__.py
@@ -2,6 +2,6 @@ from .config_node import Config
 from .config_builder import ConfigBuilder
 
 __all__ = [
-    'Config',
-    'ConfigBuilder'
+    "Config",
+    "ConfigBuilder"
 ]
diff --git a/python_json_config/__version__.py b/python_json_config/__version__.py
index bc50bee..c72e379 100644
--- a/python_json_config/__version__.py
+++ b/python_json_config/__version__.py
@@ -1,1 +1,1 @@
-__version__ = '1.1.4'
+__version__ = "1.1.4"
diff --git a/python_json_config/config_builder.py b/python_json_config/config_builder.py
index 52c2c76..1168a9c 100644
--- a/python_json_config/config_builder.py
+++ b/python_json_config/config_builder.py
@@ -42,7 +42,7 @@ class ConfigBuilder(object):
             if value is None:
                 continue
             assert isinstance(value, field_type), f'Config field "{field_name}" with value "{value}" is not of ' \
-                f'type {field_type}'
+                f"type {field_type}"
 
     def validate_field_value(self, field_name: str, validation_function):
         """
diff --git a/python_json_config/config_node.py b/python_json_config/config_node.py
index f84e291..2243ca2 100644
--- a/python_json_config/config_node.py
+++ b/python_json_config/config_node.py
@@ -1,3 +1,4 @@
+import json
 import os
 import warnings
 from typing import List, Union, Tuple
@@ -168,7 +169,10 @@ class ConfigNode(object):
             else:
                 yield self.__path_for_key(key), value
 
-    def to_dict(self):
+    """
+    Serialization functions
+    """
+    def to_dict(self) -> dict:
         config_dict = {}
         for key, value in self.__node_dict.items():
             if isinstance(value, ConfigNode):
@@ -177,6 +181,9 @@ class ConfigNode(object):
                 config_dict[key] = value
         return config_dict
 
+    def to_json(self) -> str:
+        return json.dumps(self.to_dict())
+
     """
     Built-in python functions
     """
@@ -213,8 +220,8 @@ class ConfigNode(object):
             return False
 
     def __str__(self):
-        return f'ConfigNode(path={self.__path}, values={self.__node_dict}, strict_access={self.strict_access}, ' \
-               f'required_fields={self.required_fields}, optional_fields={self.optional_fields})'
+        return f"ConfigNode(path={self.__path}, values={self.__node_dict}, strict_access={self.strict_access}, " \
+               f"required_fields={self.required_fields}, optional_fields={self.optional_fields})"
 
     __repr__ = __str__
 
@@ -238,7 +245,7 @@ class ConfigNode(object):
         return ".".join(self.__path)
 
     def __path_for_key(self, key: str):
-        print_path = self.__path_str + '.' * bool(self.__path)
+        print_path = self.__path_str + "." * bool(self.__path)
         return print_path + key
 
     def __parse_field_settings(self, field_names: List[Union[str, List[str]]]) -> Tuple[List[str], List[List[str]]]:
diff --git a/python_json_config/transformers/__init__.py b/python_json_config/transformers/__init__.py
index bb32639..f0eefef 100644
--- a/python_json_config/transformers/__init__.py
+++ b/python_json_config/transformers/__init__.py
@@ -1,5 +1,5 @@
 from .generic_transformers import to_timedelta
 
 __all__ = [
-    'to_timedelta'
+    "to_timedelta"
 ]
diff --git a/python_json_config/transformers/generic_transformers.py b/python_json_config/transformers/generic_transformers.py
index 5fd0f46..f64150b 100644
--- a/python_json_config/transformers/generic_transformers.py
+++ b/python_json_config/transformers/generic_transformers.py
@@ -15,7 +15,7 @@ def to_timedelta(value: str):
     :param value: The timedelta as string.
     :return: A timedelta value representing the timespan that is specified.
     """
-    split_values = value.split(':')
+    split_values = value.split(":")
 
     try:
         int_values = [int(element) for element in split_values]
diff --git a/python_json_config/utils.py b/python_json_config/utils.py
index c95566e..555be79 100644
--- a/python_json_config/utils.py
+++ b/python_json_config/utils.py
@@ -3,5 +3,5 @@ from typing import Union, List
 
 def normalize_path(path: Union[str, List[str]]) -> List[str]:
     if isinstance(path, str):
-        path = path.split('.')
+        path = path.split(".")
     return path
diff --git a/python_json_config/validators/__init__.py b/python_json_config/validators/__init__.py
index 07a7938..f640aaa 100644
--- a/python_json_config/validators/__init__.py
+++ b/python_json_config/validators/__init__.py
@@ -2,8 +2,8 @@ from .network_validators import is_ipv4_address, is_unreserved_port
 from .generic_validators import is_timedelta, is_valid_choice
 
 __all__ = [
-    'is_timedelta',
-    'is_valid_choice',
-    'is_ipv4_address',
-    'is_unreserved_port'
+    "is_timedelta",
+    "is_valid_choice",
+    "is_ipv4_address",
+    "is_unreserved_port"
 ]
diff --git a/python_json_config/validators/generic_validators.py b/python_json_config/validators/generic_validators.py
index 5ad1ece..7abeb56 100644
--- a/python_json_config/validators/generic_validators.py
+++ b/python_json_config/validators/generic_validators.py
@@ -14,7 +14,7 @@ def is_timedelta(value: str) -> Union[bool, Tuple[bool, str]]:
     :param value: The timedelta as string.
     :return: True if the value is a valid timedelta specification otherwise False.
     """
-    split_values = value.split(':')
+    split_values = value.split(":")
     if len(split_values) > 5:
         return False, "Timedelta contains more than 5 elements."
 


Test patch:
diff --git a/tests/config_builder_test.py b/tests/config_builder_test.py
index f651baf..935ab7a 100644
--- a/tests/config_builder_test.py
+++ b/tests/config_builder_test.py
@@ -9,78 +9,78 @@ from python_json_config import ConfigBuilder
 
 @pytest.fixture
 def path() -> str:
-    return 'tests/resources/test_config.json'
+    return "tests/resources/test_config.json"
 
 
 @pytest.fixture
 def schema_path() -> str:
-    return 'tests/resources/test_config.schema.json'
+    return "tests/resources/test_config.schema.json"
 
 
 def test_parse(path):
     config = ConfigBuilder()\
-        .validate_field_type('server.port', int)\
-        .validate_field_value('server.debug_mode', lambda x: not x)\
-        .transform_field_value('server.port', lambda x: str(x))\
+        .validate_field_type("server.port", int)\
+        .validate_field_value("server.debug_mode", lambda x: not x)\
+        .transform_field_value("server.port", lambda x: str(x))\
         .parse_config(path)
     assert config is not None
     assert not config.server.debug_mode
-    assert config.server.port == '5000'
+    assert config.server.port == "5000"
 
 
 def test_type_validation_builder():
     builder = ConfigBuilder()
-    builder.validate_field_type('key1', int)
-    builder.validate_field_type('key1.key2', list)
+    builder.validate_field_type("key1", int)
+    builder.validate_field_type("key1.key2", list)
     type_validation_dict = builder._ConfigBuilder__validation_types
-    assert type_validation_dict['key1'] == int
-    assert type_validation_dict['key1.key2'] == list
+    assert type_validation_dict["key1"] == int
+    assert type_validation_dict["key1.key2"] == list
 
 
 def test_value_validation_builder():
     builder = ConfigBuilder()
-    builder.validate_field_value('key1', lambda x: x < 4)
-    builder.validate_field_value('key1.key2', lambda x: len(x) == 3)
+    builder.validate_field_value("key1", lambda x: x < 4)
+    builder.validate_field_value("key1.key2", lambda x: len(x) == 3)
     value_validation_dict = builder._ConfigBuilder__validation_functions
-    assert value_validation_dict['key1'][0](1)
-    assert not value_validation_dict['key1'][0](4)
-    assert value_validation_dict['key1.key2'][0]([1, 2, 3])
-    assert not value_validation_dict['key1.key2'][0](['a', 'b'])
+    assert value_validation_dict["key1"][0](1)
+    assert not value_validation_dict["key1"][0](4)
+    assert value_validation_dict["key1.key2"][0]([1, 2, 3])
+    assert not value_validation_dict["key1.key2"][0](["a", "b"])
 
 
 def test_value_transformation_builder():
     builder = ConfigBuilder()
-    builder.transform_field_value('key1', lambda x: x * 4)
-    builder.transform_field_value('key1.key2', lambda x: [x[len(x) - 1 - i] for i in range(len(x))])
+    builder.transform_field_value("key1", lambda x: x * 4)
+    builder.transform_field_value("key1.key2", lambda x: [x[len(x) - 1 - i] for i in range(len(x))])
     value_transformation_dict = builder._ConfigBuilder__transformation_functions
-    assert value_transformation_dict['key1'](1) == 4
-    assert value_transformation_dict['key1'](4) == 16
-    assert value_transformation_dict['key1.key2']([1 == 2, 3]), [3, 2, 1]
-    assert value_transformation_dict['key1.key2'](['a' == 'b', False]), [False, 'b', 'a']
+    assert value_transformation_dict["key1"](1) == 4
+    assert value_transformation_dict["key1"](4) == 16
+    assert value_transformation_dict["key1.key2"]([1 == 2, 3]), [3, 2, 1]
+    assert value_transformation_dict["key1.key2"](["a" == "b", False]), [False, "b", "a"]
 
 
 def test_type_validation(path):
     builder = ConfigBuilder()
-    builder.validate_field_type('server.debug_mode', bool)
-    builder.validate_field_type('server.port', int)
+    builder.validate_field_type("server.debug_mode", bool)
+    builder.validate_field_type("server.port", int)
     builder.parse_config(path)
-    builder.validate_field_type('server.host', int)
+    builder.validate_field_type("server.host", int)
     with pytest.raises(AssertionError):
         builder.parse_config(path)
 
 
 def test_value_validation(path):
     builder = ConfigBuilder()
-    builder.validate_field_value('server.debug_mode', lambda x: not x)
-    builder.validate_field_value('server.port', [lambda x: x < 10000, lambda x: x > 1023])
+    builder.validate_field_value("server.debug_mode", lambda x: not x)
+    builder.validate_field_value("server.port", [lambda x: x < 10000, lambda x: x > 1023])
     builder.parse_config(path)
 
-    builder.validate_field_value('server.port', lambda x: x > 6000)
+    builder.validate_field_value("server.port", lambda x: x > 6000)
     with pytest.raises(AssertionError):
         builder.parse_config(path)
 
     builder = ConfigBuilder()
-    builder = builder.validate_field_value('cache.ttl', lambda x: x > 200)
+    builder = builder.validate_field_value("cache.ttl", lambda x: x > 200)
     with pytest.raises(AssertionError):
         builder.parse_config(path)
 
@@ -91,8 +91,8 @@ def test_value_transformation(path):
     assert not config.server.debug_mode
     assert config.server.port == 5000
 
-    builder.transform_field_value('server.debug_mode', lambda x: not x)
-    builder.transform_field_value('server.port', lambda x: x + 4)
+    builder.transform_field_value("server.debug_mode", lambda x: not x)
+    builder.transform_field_value("server.port", lambda x: x + 4)
     config = builder.parse_config(path)
     assert config.server.debug_mode
     assert config.server.port == 5004
@@ -100,8 +100,8 @@ def test_value_transformation(path):
 
 def test_value_validation_error_messages(path):
     builder = ConfigBuilder()
-    custom_message = 'test error'
-    builder.validate_field_value('server.debug_mode', lambda x: (x, custom_message))
+    custom_message = "test error"
+    builder.validate_field_value("server.debug_mode", lambda x: (x, custom_message))
     expected_message = f'Error validating field "server.debug_mode" with value "False": {custom_message}'
     with pytest.raises(AssertionError, match=expected_message):
         builder.parse_config(path)
@@ -125,8 +125,8 @@ def test_json_schema_validation(path, schema_path):
 def test_optional_access(path):
     builder = ConfigBuilder()
     builder.set_field_access_optional()
-    builder.add_required_field('server.nokey')
-    builder.add_required_fields(['cache.name', 'test'])
+    builder.add_required_field("server.nokey")
+    builder.add_required_fields(["cache.name", "test"])
     config = builder.parse_config(path)
 
     assert config.nokey is None
@@ -143,8 +143,8 @@ def test_optional_access(path):
 def test_required_access(path):
     builder = ConfigBuilder()
     builder.set_field_access_required()
-    builder.add_optional_field('server.nokey')
-    builder.add_optional_fields(['cache.name', 'test'])
+    builder.add_optional_field("server.nokey")
+    builder.add_optional_fields(["cache.name", "test"])
     config = builder.parse_config(path)
 
     assert config.test is None
@@ -161,9 +161,9 @@ def test_required_access(path):
 def test_optional_validation(path):
     builder = ConfigBuilder()
     builder.set_field_access_optional()
-    builder.validate_field_type('cache.name', str)
-    builder.validate_field_value('cache.host', 'localhost')
-    builder.transform_field_value('cache.host', lambda name: f"https://{name}")
+    builder.validate_field_type("cache.name", str)
+    builder.validate_field_value("cache.host", "localhost")
+    builder.transform_field_value("cache.host", lambda name: f"https://{name}")
     builder.parse_config(path)
 
 
diff --git a/tests/config_node/conftest.py b/tests/config_node/conftest.py
index 32136b4..dbaf80f 100644
--- a/tests/config_node/conftest.py
+++ b/tests/config_node/conftest.py
@@ -1,14 +1,14 @@
 import pytest
 
 
-@pytest.fixture(scope='session')
+@pytest.fixture(scope="session")
 def config_dict() -> dict:
     return {
-        'key1': 1,
-        'key2': {
-            'key3': 3,
-            'key4': {'key5': 5},
-            'key6': 6
+        "key1": 1,
+        "key2": {
+            "key3": 3,
+            "key4": {"key5": 5},
+            "key6": 6
         },
-        'key7': 7
+        "key7": 7
     }
diff --git a/tests/config_node/test_crud.py b/tests/config_node/test_crud.py
index b2cbb71..57d313f 100644
--- a/tests/config_node/test_crud.py
+++ b/tests/config_node/test_crud.py
@@ -8,17 +8,17 @@ from python_json_config.config_node import ConfigNode
 def test_creation(config_dict):
     node = ConfigNode(config_dict)
     assert node.key1 == 1
-    assert node.__dict__['_ConfigNode__path'] == []
+    assert node.__dict__["_ConfigNode__path"] == []
     assert isinstance(node.key2, ConfigNode)
 
     nested_node = node.key2
     assert nested_node.key3 == 3
-    assert nested_node.__dict__['_ConfigNode__path'] == ['key2']
+    assert nested_node.__dict__["_ConfigNode__path"] == ["key2"]
     assert isinstance(nested_node.key4, ConfigNode)
 
     nested_node = nested_node.key4
     assert nested_node.key5 == 5
-    assert nested_node.__dict__['_ConfigNode__path'] == ['key2', 'key4']
+    assert nested_node.__dict__["_ConfigNode__path"] == ["key2", "key4"]
 
 
 def test_get(config_dict):
@@ -27,40 +27,40 @@ def test_get(config_dict):
     with pytest.raises(AttributeError):
         node.nokey
 
-    assert node.get('key1') == 1
+    assert node.get("key1") == 1
     with pytest.raises(AttributeError):
-        node.get('nokey')
+        node.get("nokey")
 
-    assert node.get('key2.key3') == 3
+    assert node.get("key2.key3") == 3
 
 
 def test_add():
-    node = ConfigNode({'key1': 1})
+    node = ConfigNode({"key1": 1})
     assert node.key1 == 1
 
     with pytest.raises(AttributeError):
         node.key2
-    node.add('key2', 2)
+    node.add("key2", 2)
     assert node.key2 == 2
 
     with pytest.raises(AttributeError):
         node.key3.key4
-    node.add('key3.key4', "test")
+    node.add("key3.key4", "test")
     assert node.key3.key4 == "test"
 
 
 def test_add_overwrite():
-    node = ConfigNode({'key1': 1})
+    node = ConfigNode({"key1": 1})
     assert node.key1 == 1
 
     with warnings.catch_warnings(record=True) as warning_log:
         assert len(warning_log) == 0
 
-        node.add('key1', 2, overwrite=False)
+        node.add("key1", 2, overwrite=False)
         assert len(warning_log) == 1
         assert node.key1 == 2
 
-        node.add('key1', 3)
+        node.add("key1", 3)
         assert len(warning_log) == 1
         assert node.key1 == 3
 
@@ -69,35 +69,35 @@ def test_update(config_dict):
     node = ConfigNode(config_dict)
 
     assert node.key1 == 1
-    node.update('key1', 2)
+    node.update("key1", 2)
     assert node.key1 == 2
 
-    node.update('key1', {'newkey': 1})
+    node.update("key1", {"newkey": 1})
     assert isinstance(node.key1, ConfigNode)
     assert node.key1.newkey == 1
 
     assert isinstance(node.key2.key4, ConfigNode)
-    node.update('key2.key4', 1337)
+    node.update("key2.key4", 1337)
     assert node.key2.key4 == 1337
 
 
 def test_update_upsert():
-    node = ConfigNode({'key1': 1})
+    node = ConfigNode({"key1": 1})
 
     with pytest.raises(AttributeError):
         node.key2
 
     with pytest.raises(RuntimeError):
-        node.update('key2', 'asd', upsert=False)
+        node.update("key2", "asd", upsert=False)
 
-    node.update('key2', 'asd', upsert=True)
-    assert node.key2 == 'asd'
+    node.update("key2", "asd", upsert=True)
+    assert node.key2 == "asd"
 
 
 def test_strict_access(config_dict):
     config = ConfigNode(config_dict,
                         strict_access=True,
-                        optional_fields=['nokey', ['key2', 'nokey'], 'key2.nokey2'])
+                        optional_fields=["nokey", ["key2", "nokey"], "key2.nokey2"])
     assert config.nokey is None
     assert config.key2.nokey is None
     assert config.key2.nokey2 is None
@@ -106,7 +106,7 @@ def test_strict_access(config_dict):
 
     config = ConfigNode(config_dict,
                         strict_access=False,
-                        required_fields=['nokey', ['key2', 'nokey'], 'key2.nokey2'])
+                        required_fields=["nokey", ["key2", "nokey"], "key2.nokey2"])
     assert config.key2.nokey3 is None
     with pytest.raises(AttributeError):
         assert config.nokey is None
diff --git a/tests/config_node/test_iterators.py b/tests/config_node/test_iterators.py
index 60b8c49..695302d 100644
--- a/tests/config_node/test_iterators.py
+++ b/tests/config_node/test_iterators.py
@@ -3,17 +3,17 @@ from python_json_config.config_node import ConfigNode
 
 def test_contains(config_dict):
     config = ConfigNode(config_dict)
-    assert 'key1' in config
-    assert 'key1.key2' not in config
-    assert 'key2.key3' in config
-    assert 'key2.key4.key5' in config
-    assert 'key2.key4.key6' not in config
+    assert "key1" in config
+    assert "key1.key2" not in config
+    assert "key2.key3" in config
+    assert "key2.key4.key5" in config
+    assert "key2.key4.key6" not in config
 
 
 def test_keys(config_dict):
     config = ConfigNode(config_dict)
     keys = list(config.keys())
-    expected_keys = ['key1', 'key2.key3', 'key2.key4.key5', 'key2.key6', 'key7']
+    expected_keys = ["key1", "key2.key3", "key2.key4.key5", "key2.key6", "key7"]
     assert keys == expected_keys
 
 
@@ -26,13 +26,13 @@ def test_values(config_dict):
 def test_items(config_dict):
     config = ConfigNode(config_dict)
     items = list(config.items())
-    expected_items = [('key1', 1), ('key2.key3', 3), ('key2.key4.key5', 5), ('key2.key6', 6), ('key7', 7)]
+    expected_items = [("key1", 1), ("key2.key3", 3), ("key2.key4.key5", 5), ("key2.key6", 6), ("key7", 7)]
     assert items == expected_items
 
 
 def test_iter(config_dict):
     config = ConfigNode(config_dict)
-    expected_keys = ['key1', 'key2.key3', 'key2.key4.key5', 'key2.key6', 'key7']
+    expected_keys = ["key1", "key2.key3", "key2.key4.key5", "key2.key6", "key7"]
     assert list(config) == expected_keys
 
 
@@ -44,10 +44,3 @@ def test_iteration(config_dict):
         assert item_key == key
         assert item_value == value
         assert config.get(key) == value
-
-
-def test_to_dict(config_dict):
-    config = ConfigNode(config_dict)
-    assert config.to_dict() == config_dict
-    assert config.key2.to_dict() == config_dict["key2"]
-    assert config.key2.key4.to_dict() == config_dict["key2"]["key4"]
diff --git a/tests/config_node/test_serialization.py b/tests/config_node/test_serialization.py
index 8ed34c9..82d5f24 100644
--- a/tests/config_node/test_serialization.py
+++ b/tests/config_node/test_serialization.py
@@ -9,3 +9,16 @@ def test_pickle(config_dict):
     assert pickle_conf.key1 == 1
     assert pickle_conf.key2.key3 == 3
     assert pickle_conf.key2.key4.key5 == 5
+
+
+def test_to_dict(config_dict):
+    config = ConfigNode(config_dict)
+    assert config.to_dict() == config_dict
+    assert config.key2.to_dict() == config_dict["key2"]
+    assert config.key2.key4.to_dict() == config_dict["key2"]["key4"]
+
+
+def test_to_json(config_dict):
+    config = ConfigNode(config_dict)
+    json = config.to_json()
+    assert json == """{"key1": 1, "key2": {"key3": 3, "key4": {"key5": 5}, "key6": 6}, "key7": 7}"""
diff --git a/tests/config_node/test_utils.py b/tests/config_node/test_utils.py
index 5537fee..2756c80 100644
--- a/tests/config_node/test_utils.py
+++ b/tests/config_node/test_utils.py
@@ -3,6 +3,6 @@ from python_json_config.config_node import ConfigNode
 
 def test_string():
     node = ConfigNode({1: 2, 3: 4})
-    node_str = 'ConfigNode(path=[], values={1: 2, 3: 4}, strict_access=True, required_fields=[], optional_fields' \
-               '=[])'
+    node_str = "ConfigNode(path=[], values={1: 2, 3: 4}, strict_access=True, required_fields=[], optional_fields" \
+               "=[])"
     assert str(node) == node_str
diff --git a/tests/validators/generic_validators_test.py b/tests/validators/generic_validators_test.py
index eb1200b..3374b07 100644
--- a/tests/validators/generic_validators_test.py
+++ b/tests/validators/generic_validators_test.py
@@ -2,27 +2,27 @@ from python_json_config.validators import is_timedelta, is_valid_choice
 
 
 def test_is_timedelta():
-    valid_timedeltas = ['1:3:24:30:23', '0:0:1', '0:0:0:0:1', '01:02:02:03:04']
-    invalid_timedeltas = ['1:3:24:30:23:45', '01:a:02:03:04']
+    valid_timedeltas = ["1:3:24:30:23", "0:0:1", "0:0:0:0:1", "01:02:02:03:04"]
+    invalid_timedeltas = ["1:3:24:30:23:45", "01:a:02:03:04"]
 
     for timedelta in valid_timedeltas:
         assert is_timedelta(timedelta)
 
-    assert is_timedelta(invalid_timedeltas[0]) == (False, 'Timedelta contains more than 5 elements.')
-    assert is_timedelta(invalid_timedeltas[1]) == (False, 'Timedelta contains non-integer elements.')
+    assert is_timedelta(invalid_timedeltas[0]) == (False, "Timedelta contains more than 5 elements.")
+    assert is_timedelta(invalid_timedeltas[1]) == (False, "Timedelta contains non-integer elements.")
 
 
 def test_is_valid_choice():
-    list_options = [1, 2, '3']
+    list_options = [1, 2, "3"]
     list_validator = is_valid_choice(list_options)
     assert list_validator(1)
-    assert list_validator(3) == (False, f'Value is not contained in the options {list_options}')
-    assert list_validator('3')
-    assert list_validator(4) == (False, f'Value is not contained in the options {list_options}')
+    assert list_validator(3) == (False, f"Value is not contained in the options {list_options}")
+    assert list_validator("3")
+    assert list_validator(4) == (False, f"Value is not contained in the options {list_options}")
 
-    dict_options = {1: '2', '3': 4}
+    dict_options = {1: "2", "3": 4}
     dict_validator = is_valid_choice(dict_options)
     assert dict_validator(1)
-    assert dict_validator('2') == (False, f'Value is not contained in the options {dict_options}')
-    assert dict_validator('3')
-    assert dict_validator(4) == (False, f'Value is not contained in the options {dict_options}')
+    assert dict_validator("2") == (False, f"Value is not contained in the options {dict_options}")
+    assert dict_validator("3")
+    assert dict_validator(4) == (False, f"Value is not contained in the options {dict_options}")
diff --git a/tests/validators/network_validators_test.py b/tests/validators/network_validators_test.py
index e13ab1b..7190b8d 100644
--- a/tests/validators/network_validators_test.py
+++ b/tests/validators/network_validators_test.py
@@ -2,20 +2,20 @@ from python_json_config.validators import is_ipv4_address, is_unreserved_port
 
 
 def test_is_ipv4_address():
-    valid_ips = ['127.0.0.1', '8.8.8.8', '127.1', '8.526344']
-    invalid_ips = ['327.0.0.1', '8.8.8.8.8', '127.-1', '256.526344']
+    valid_ips = ["127.0.0.1", "8.8.8.8", "127.1", "8.526344"]
+    invalid_ips = ["327.0.0.1", "8.8.8.8.8", "127.-1", "256.526344"]
 
     for address in valid_ips:
         assert is_ipv4_address(address)
 
     for address in invalid_ips:
-        assert is_ipv4_address(address) == (False, 'IP address is not a valid IPv4 address.')
+        assert is_ipv4_address(address) == (False, "IP address is not a valid IPv4 address.")
 
 
 def test_is_unreserved_port():
-    assert is_unreserved_port(1) == (False, 'Port is reserved.')
-    assert is_unreserved_port(-1) == (False, 'Port is reserved.')
-    assert is_unreserved_port(22) == (False, 'Port is reserved.')
-    assert is_unreserved_port(1023) == (False, 'Port is reserved.')
+    assert is_unreserved_port(1) == (False, "Port is reserved.")
+    assert is_unreserved_port(-1) == (False, "Port is reserved.")
+    assert is_unreserved_port(22) == (False, "Port is reserved.")
+    assert is_unreserved_port(1023) == (False, "Port is reserved.")
     assert is_unreserved_port(1024)
     assert is_unreserved_port(14302)