More type annotations.
[python_utils.git] / arper.py
index 39aecf90bd438af92d69cffae6f4a3d44ea6aa0e..ca5d1d5fa59c6ad75bb811f0664c90e798a4745d 100644 (file)
--- a/arper.py
+++ b/arper.py
@@ -2,6 +2,7 @@
 
 """A caching layer around the kernel's network mapping between IPs and MACs"""
 
+
 import datetime
 import logging
 import os
@@ -46,7 +47,7 @@ cfg.add_argument(
 )
 
 
[email protected]_autoloaded_singleton()
[email protected]_autoloaded_singleton()  # type: ignore
 class Arper(persistent.Persistent):
     def __init__(self, cached_state: Optional[BiDict] = None) -> None:
         self.state = BiDict()
@@ -131,10 +132,7 @@ class Arper(persistent.Persistent):
                     mac = mac.lower()
                     ip = ip.strip()
                     cached_state[mac] = ip
-            if (
-                len(cached_state)
-                > config.config['arper_min_entries_to_be_valid']
-            ):
+            if len(cached_state) > config.config['arper_min_entries_to_be_valid']:
                 return cls(cached_state)
             else:
                 msg = f'{cache_file} is invalid: only {len(cached_state)} entries.  Deleting it.'
@@ -147,12 +145,8 @@ class Arper(persistent.Persistent):
     @overrides
     def save(self) -> bool:
         if len(self.state) > config.config['arper_min_entries_to_be_valid']:
-            logger.debug(
-                f'Persisting state to {config.config["arper_cache_location"]}'
-            )
-            with file_utils.FileWriter(
-                config.config['arper_cache_location']
-            ) as wf:
+            logger.debug(f'Persisting state to {config.config["arper_cache_location"]}')
+            with file_utils.FileWriter(config.config['arper_cache_location']) as wf:
                 for (mac, ip) in self.state.items():
                     mac = mac.lower()
                     print(f'{mac}, {ip}', file=wf)