mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-24 04:51:27 +00:00
feat: add type hints
This commit is contained in:
parent
e6ddd1feed
commit
7d0cc5e630
|
@ -1,10 +1,11 @@
|
|||
import re
|
||||
from typing import Dict, Tuple, Optional
|
||||
|
||||
FLAKE_CONFIG_PATH = "/etc/nixos/sp-modules/flake.nix"
|
||||
|
||||
|
||||
class FlakeServiceManager:
|
||||
def __enter__(self):
|
||||
def __enter__(self) -> "FlakeServiceManager":
|
||||
self.services = {}
|
||||
|
||||
with open(FLAKE_CONFIG_PATH, "r") as file:
|
||||
|
@ -15,7 +16,9 @@ class FlakeServiceManager:
|
|||
|
||||
return self
|
||||
|
||||
def _extract_services(self, input_string: str):
|
||||
def _extract_services(
|
||||
self, input_string: str
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
pattern = r"inputs\.(\w+)\.url\s*=\s*(\S+);"
|
||||
match = re.search(pattern, input_string)
|
||||
|
||||
|
@ -26,7 +29,7 @@ class FlakeServiceManager:
|
|||
else:
|
||||
return None, None
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
def __exit__(self, exc_type, exc_value, traceback) -> None:
|
||||
with open(FLAKE_CONFIG_PATH, "w") as file:
|
||||
file.write(
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue