Skip to content

Commit 82d7605

Browse files
Type annotations; Pylance complaints fixed
1 parent d020b1d commit 82d7605

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

src/tokenizer/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
TOK, Tok, tokenize, tokenize_without_annotation, split_into_sentences,
3737
parse_tokens, correct_spaces, detokenize, mark_paragraphs, paragraphs,
3838
normalized_text, normalized_text_from_tokens, text_from_tokens,
39-
calculate_indexes, generate_rough_tokens
39+
calculate_indexes, generate_rough_tokens, TokenStream
4040
)
4141
from .abbrev import Abbreviations, ConfigError
4242
from .version import __version__
4343

44+
__author__ = "Miðeind ehf"
45+
__copyright__ = "(C) 2021 Miðeind ehf."
46+
4447
__all__ = (
4548
"TP_LEFT","TP_CENTER", "TP_RIGHT", "TP_NONE", "TP_WORD",
4649
"EN_DASH", "EM_DASH",
@@ -49,9 +52,7 @@
4952
"TOK", "Tok", "tokenize", "tokenize_without_annotation", "split_into_sentences",
5053
"parse_tokens", "correct_spaces", "detokenize", "mark_paragraphs", "paragraphs",
5154
"normalized_text", "normalized_text_from_tokens", "text_from_tokens",
52-
"calculate_indexes", "generate_rough_tokens",
53-
"Abbreviations", "ConfigError"
55+
"calculate_indexes", "generate_rough_tokens", "TokenStream",
56+
"Abbreviations", "ConfigError", "__version__", "__author__", "__copyright__"
5457
)
5558

56-
__author__ = "Miðeind ehf"
57-
__copyright__ = "(C) 2021 Miðeind ehf."

src/tokenizer/definitions.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,21 @@
5454
TelnoTuple = Tuple[str, str]
5555
CurrencyTuple = Tuple[str, Optional[List[str]], Optional[List[str]]]
5656

57-
BIN_Tuple = NamedTuple(
58-
"BIN_Tuple",
59-
[
60-
("stofn", str),
61-
("utg", int),
62-
("ordfl", str),
63-
("fl", str),
64-
("ordmynd", str),
65-
("beyging", str),
66-
],
67-
)
57+
class BIN_Tuple(NamedTuple):
58+
stofn: str
59+
utg: int
60+
ordfl: str
61+
fl: str
62+
ordmynd: str
63+
beyging: str
64+
6865
BIN_TupleList = Sequence[BIN_Tuple]
6966

70-
PersonNameTuple = NamedTuple(
71-
"PersonNameTuple",
72-
[
73-
("name", str),
74-
("gender", Optional[str]),
75-
("case", Optional[str]),
76-
]
77-
)
67+
class PersonNameTuple(NamedTuple):
68+
name: str
69+
gender: Optional[str]
70+
case: Optional[str]
71+
7872
PersonNameList = Sequence[PersonNameTuple]
7973

8074
# All possible contents of the Tok.val attribute

0 commit comments

Comments
 (0)