1
0
Fork 0

Add more type hints.

This commit is contained in:
Casper V. Kristensen 2019-03-08 02:07:22 +01:00
parent c493442314
commit 635720f618
Signed by: caspervk
GPG key ID: 289CA03790535054
2 changed files with 5 additions and 5 deletions

View file

@ -45,8 +45,7 @@ def initialize_logging(config: configparser.ConfigParser):
logger.info("Logging level is %s", log_level) logger.info("Logging level is %s", log_level)
logger.info("Logging to %s - backup count is %s", log_file, log_backup_count) logger.info("Logging to %s - backup count is %s", log_file, log_backup_count)
def logging_config(file, level, backup_count) -> dict:
def logging_config(file, level, backup_count):
return { return {
"version": 1, "version": 1,
"disable_existing_loggers": False, "disable_existing_loggers": False,

View file

@ -1,7 +1,8 @@
import difflib import difflib
from typing import Sequence, List
def humanize(n, precision=2, prefix="bin", suffix="B") -> str: def humanize(n: int, precision=2, prefix="bin", suffix="B") -> str:
""" """
Return a humanized string representation of a number (of bytes). Return a humanized string representation of a number (of bytes).
Adapted from Doug Latornell - http://code.activestate.com/recipes/577081/ Adapted from Doug Latornell - http://code.activestate.com/recipes/577081/
@ -26,7 +27,7 @@ def humanize(n, precision=2, prefix="bin", suffix="B") -> str:
return "{1:.{0}f}".format(precision, n / factor).rstrip("0").rstrip(".") + suffix return "{1:.{0}f}".format(precision, n / factor).rstrip("0").rstrip(".") + suffix
def case_insensitive_close_matches(word, possibilities, n=3, cutoff=0.6): def case_insensitive_close_matches(word: str, possibilities: Sequence[str], n=3, cutoff=0.6) -> List[str]:
""" """
Python's difflib.get_close_matches does case sensitive sequence matching, this function decorates the library Python's difflib.get_close_matches does case sensitive sequence matching, this function decorates the library
function to make it case insensitive. function to make it case insensitive.
@ -36,7 +37,7 @@ def case_insensitive_close_matches(word, possibilities, n=3, cutoff=0.6):
return [possibilities[m] for m in close_matches] return [possibilities[m] for m in close_matches]
def markdown_escape(text: str): def markdown_escape(text: str) -> str:
""" """
Escape markdown. Escape markdown.
""" """