diff options
author | mathieui <mathieui@mathieui.net> | 2018-08-17 02:16:03 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2018-08-17 02:16:03 +0200 |
commit | b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4 (patch) | |
tree | f8c489bbf65a9a4a24d268281d3da798bbfe3ba2 /poezio/windows/funcs.py | |
parent | 6ccf7ea71d5e5194dd036a90e36c0db6a0ec757a (diff) | |
download | poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.gz poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.bz2 poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.xz poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.zip |
Add typing information and reformat stuff
Diffstat (limited to 'poezio/windows/funcs.py')
-rw-r--r-- | poezio/windows/funcs.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/poezio/windows/funcs.py b/poezio/windows/funcs.py index 3648bac3..d118f353 100644 --- a/poezio/windows/funcs.py +++ b/poezio/windows/funcs.py @@ -3,16 +3,17 @@ Standalone functions used by the modules """ import string -DIGITS = string.digits + '-' - +from typing import Optional, List from poezio.windows.base_wins import FORMAT_CHAR, format_chars +DIGITS = string.digits + '-' + -def find_first_format_char(text, chars=None): - if chars is None: - chars = format_chars +def find_first_format_char(text: str, + chars: Optional[List[str]] = None) -> int: + to_find = chars or format_chars pos = -1 - for char in chars: + for char in to_find: p = text.find(char) if p == -1: continue @@ -21,7 +22,7 @@ def find_first_format_char(text, chars=None): return pos -def truncate_nick(nick, size=10): +def truncate_nick(nick: str, size=10) -> str: if size < 1: size = 1 if nick and len(nick) > size: @@ -29,7 +30,7 @@ def truncate_nick(nick, size=10): return nick -def parse_attrs(text, previous=None): +def parse_attrs(text: str, previous: Optional[List[str]] = None) -> List[str]: next_attr_char = text.find(FORMAT_CHAR) if previous: attrs = previous |