Skip to content

Commit 1110c48

Browse files
authored
Merge pull request #1364 from bact/rm-mypy-overrides
mypy strict = true
2 parents 82d4302 + 7f7d706 commit 1110c48

5 files changed

Lines changed: 17 additions & 24 deletions

File tree

pyproject.toml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,40 +414,33 @@ basepython = "pypy3.11"
414414

415415
[tool.tox.env.ruff]
416416
basepython = "python"
417-
deps = "ruff"
418417
commands = [["ruff", "check", "pythainlp"], ["ruff", "format", "--check", "pythainlp"]]
418+
deps = "ruff"
419419
skip_install = true
420420

421421
# Mypy configuration
422422
[tool.mypy]
423423
check_untyped_defs = true
424-
disallow_untyped_defs = false
425-
disallow_incomplete_defs = false
426-
disallow_untyped_decorators = false
424+
disallow_incomplete_defs = true
425+
disallow_subclassing_any = true
426+
disallow_untyped_decorators = true
427+
disallow_untyped_defs = true
427428
pretty = true
428429
python_version = "3.9"
429430
show_column_numbers = true
430431
show_error_code_links = true
431432
show_error_context = true
433+
strict = true
432434
strict_bytes = true
433435
strict_equality = true
434436
strict_equality_for_none = true
435437
strict_optional = true
436438
warn_no_return = true
437439
warn_redundant_casts = true
438440
warn_return_any = true
441+
warn_unreachable = true
439442
warn_unused_configs = true
440443
warn_unused_ignores = true
441-
warn_unreachable = true
442-
443-
# Per-module options for stricter checking on foundation modules
444-
[[tool.mypy.overrides]]
445-
module = [
446-
"pythainlp.tools.*",
447-
"pythainlp.cli.*",
448-
]
449-
disallow_untyped_defs = true
450-
disallow_incomplete_defs = true
451444

452445
# Ignore missing imports for optional dependencies
453446
[[tool.mypy.overrides]]

pythainlp/spell/wanchanberta_thai_grammarly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232

3333

34-
class BertModel(torch.nn.Module):
34+
class BertModel(torch.nn.Module): # type: ignore[misc]
3535
def __init__(self) -> None:
3636
super().__init__()
3737
self.bert: BertForTokenClassification = (

pythainlp/translate/tokenization_small100.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# fmt: on
6666

6767

68-
class SMALL100Tokenizer(PreTrainedTokenizer):
68+
class SMALL100Tokenizer(PreTrainedTokenizer): # type: ignore[misc]
6969
"""Construct an SMALL100 tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
7070
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
7171
this superclass for more information regarding those methods.

pythainlp/transliterate/thai2rom.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def romanize(self, text: str) -> str:
119119
return "".join(target)
120120

121121

122-
class Encoder(nn.Module):
122+
class Encoder(nn.Module): # type: ignore[misc]
123123
hidden_size: int
124124
character_embedding: nn.Embedding
125125
rnn: nn.LSTM
@@ -196,7 +196,7 @@ def init_hidden(
196196
return (h_0, c_0)
197197

198198

199-
class Attn(nn.Module):
199+
class Attn(nn.Module): # type: ignore[misc]
200200
method: str
201201
hidden_size: int
202202
attn: nn.Linear
@@ -256,7 +256,7 @@ def forward(
256256
return F.softmax(attn_energies, 1)
257257

258258

259-
class AttentionDecoder(nn.Module):
259+
class AttentionDecoder(nn.Module): # type: ignore[misc]
260260
vocabulary_size: int
261261
hidden_size: int
262262
character_embedding: nn.Embedding
@@ -324,7 +324,7 @@ def forward(
324324
return x, hidden[0], attn_weights
325325

326326

327-
class Seq2Seq(nn.Module):
327+
class Seq2Seq(nn.Module): # type: ignore[misc]
328328
encoder: Encoder
329329
decoder: AttentionDecoder
330330
pad_idx: int

pythainlp/transliterate/thaig2p.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def g2p(self, text: str) -> str:
131131
return "".join(target)
132132

133133

134-
class Encoder(nn.Module):
134+
class Encoder(nn.Module): # type: ignore[misc]
135135
hidden_size: int
136136
character_embedding: nn.Embedding
137137
rnn: nn.LSTM
@@ -216,7 +216,7 @@ def init_hidden(
216216
return (h_0, c_0)
217217

218218

219-
class Attn(nn.Module):
219+
class Attn(nn.Module): # type: ignore[misc]
220220
method: str
221221
hidden_size: int
222222
attn: nn.Linear
@@ -278,7 +278,7 @@ def forward(
278278
return F.softmax(attn_energies, 1)
279279

280280

281-
class AttentionDecoder(nn.Module):
281+
class AttentionDecoder(nn.Module): # type: ignore[misc]
282282
vocabulary_size: int
283283
hidden_size: int
284284
character_embedding: nn.Embedding
@@ -346,7 +346,7 @@ def forward(
346346
return x, hidden[0], attn_weights
347347

348348

349-
class Seq2Seq(nn.Module):
349+
class Seq2Seq(nn.Module): # type: ignore[misc]
350350
encoder: Encoder
351351
decoder: AttentionDecoder
352352
pad_idx: int

0 commit comments

Comments
 (0)