Fixed typechecking with mypy

This commit is contained in:
Stijn Van Campenhout
2019-09-20 15:28:26 +02:00
parent a748bf9dd5
commit 5d27b5b3c4
6 changed files with 106 additions and 129 deletions

View File

@@ -1,21 +1,23 @@
from pathlib import Path
from yaml import BaseLoader
from yaml import load as yml_load
from yaml import dump as yml_dump
from typing import Dict
def load() -> dict:
"""Load the .rmapi config file"""
config_file_path = Path.joinpath(Path.home(), ".rmapi")
config = {}
config: Dict[str, str] = {}
if Path.exists(config_file_path):
with open(config_file_path, 'r') as config_file:
config = dict(yml_load(config_file.read()))
config = dict(yml_load(config_file.read(), Loader=BaseLoader))
return config
def dump(config: dict) -> True:
def dump(config: dict) -> None:
"""Dump config to the .rmapi config file
Args:
@@ -28,6 +30,4 @@ def dump(config: dict) -> True:
with open(config_file_path, 'w') as config_file:
config_file.write(yml_dump(config))
return True