Set strict mypy, add types for do_install
This commit is contained in:
parent
7f04bd92d1
commit
f914135142
2 changed files with 17 additions and 9 deletions
|
@ -89,8 +89,7 @@ filetype plugin indent on " required
|
|||
|
||||
" PLUGIN OPTIONS {{{
|
||||
|
||||
" uncomment to set strict mypy checking
|
||||
"let g:ale_python_mypy_options = '--strict --strict-optional'
|
||||
let g:ale_python_mypy_options = '--strict --strict-optional'
|
||||
|
||||
let g:ycm_extra_conf_globlist = ['!~/*'] " is overwritten in autogroups for c
|
||||
let g:ycm_autoclose_preview_window_after_insertion = 1
|
||||
|
|
23
install.py
23
install.py
|
@ -7,19 +7,20 @@ Shamelessly copied from https://github.com/dmerejkowsky/dotfiles.
|
|||
|
||||
import argparse
|
||||
import subprocess
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from typing import List, Optional
|
||||
from urllib.request import urlretrieve
|
||||
|
||||
import cli_ui as ui # type: ignore
|
||||
from path import Path # type: ignore
|
||||
import ruamel.yaml
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
||||
class Installer:
|
||||
"""Regroups all the installation methods listed in the yaml conf file."""
|
||||
|
||||
def __init__(self, force: bool = False, update: bool = False):
|
||||
self.conf = ruamel.yaml.safe_load(Path("configs.yml").text())
|
||||
yaml = YAML(typ='safe')
|
||||
self.conf = yaml.load(Path("configs.yml").text())
|
||||
self.base_dir = Path.getcwd()
|
||||
self.home = Path("~").expanduser()
|
||||
self.operating_system = define_os()
|
||||
|
@ -105,16 +106,22 @@ class Installer:
|
|||
if executable:
|
||||
p_dest.chmod(0o755)
|
||||
|
||||
def do_install(self, *packages, **os_specific_packages) -> None:
|
||||
def do_install(
|
||||
self, *packages: str, **os_specific_packages: List[str]
|
||||
) -> None:
|
||||
"""Install packages with OS-specific package manager.
|
||||
|
||||
Packages can either be in a tuple for non OS-specific packages, or in a
|
||||
dict for OS-specific packages.
|
||||
"""
|
||||
|
||||
if not packages: # we got the dict, make a list out of it
|
||||
if not packages:
|
||||
try:
|
||||
packages = os_specific_packages[self.operating_system] + os_specific_packages["both"]
|
||||
packages = tuple(
|
||||
os_specific_packages[self.operating_system]
|
||||
+ os_specific_packages["both"]
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
ui.fatal("Operating System not understood.")
|
||||
return
|
||||
|
@ -281,7 +288,9 @@ def define_os() -> str:
|
|||
if operating_system in ("arch", "debian"):
|
||||
return operating_system + " based"
|
||||
|
||||
return ui.fatal("I only support Arch and Debian based distros.")
|
||||
ui.fatal("I only support Arch and Debian based distros.")
|
||||
|
||||
return "Unsupported OS"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue