Add more type hints.
This commit is contained in:
parent
c493442314
commit
635720f618
|
@ -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,
|
||||||
|
|
|
@ -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.
|
||||||
"""
|
"""
|
||||||
|
|
Reference in a new issue