Used isort to sort imports. Also added to the git pre-commit hook.
[python_utils.git] / arper.py
index 39aecf90bd438af92d69cffae6f4a3d44ea6aa0e..ff1168ea4ef30b6f0ca16f5411e188b113548a0d 100644 (file)
--- a/arper.py
+++ b/arper.py
@@ -2,22 +2,23 @@
 
 """A caching layer around the kernel's network mapping between IPs and MACs"""
 
+
 import datetime
 import logging
 import os
-from typing import Any, Optional
 import warnings
+from typing import Any, Optional
 
 from overrides import overrides
 
 import argparse_utils
-from collect.bidict import BiDict
 import config
 import exec_utils
 import file_utils
 import persistent
-import string_utils
 import site_config
+import string_utils
+from collect.bidict import BiDict
 
 logger = logging.getLogger(__name__)
 
@@ -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)