Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,40 +414,33 @@ basepython = "pypy3.11"

[tool.tox.env.ruff]
basepython = "python"
deps = "ruff"
commands = [["ruff", "check", "pythainlp"], ["ruff", "format", "--check", "pythainlp"]]
deps = "ruff"
skip_install = true

# Mypy configuration
[tool.mypy]
check_untyped_defs = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
disallow_untyped_decorators = false
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
pretty = true
python_version = "3.9"
show_column_numbers = true
show_error_code_links = true
show_error_context = true
strict = true
strict_bytes = true
strict_equality = true
strict_equality_for_none = true
strict_optional = true
warn_no_return = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true
warn_unreachable = true

# Per-module options for stricter checking on foundation modules
[[tool.mypy.overrides]]
module = [
"pythainlp.tools.*",
"pythainlp.cli.*",
]
disallow_untyped_defs = true
disallow_incomplete_defs = true

# Ignore missing imports for optional dependencies
[[tool.mypy.overrides]]
Expand Down
2 changes: 1 addition & 1 deletion pythainlp/spell/wanchanberta_thai_grammarly.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)


class BertModel(torch.nn.Module):
class BertModel(torch.nn.Module): # type: ignore[misc]
def __init__(self) -> None:
super().__init__()
self.bert: BertForTokenClassification = (
Expand Down
2 changes: 1 addition & 1 deletion pythainlp/translate/tokenization_small100.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# fmt: on


class SMALL100Tokenizer(PreTrainedTokenizer):
class SMALL100Tokenizer(PreTrainedTokenizer): # type: ignore[misc]
"""Construct an SMALL100 tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Expand Down
8 changes: 4 additions & 4 deletions pythainlp/transliterate/thai2rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def romanize(self, text: str) -> str:
return "".join(target)


class Encoder(nn.Module):
class Encoder(nn.Module): # type: ignore[misc]
hidden_size: int
character_embedding: nn.Embedding
rnn: nn.LSTM
Expand Down Expand Up @@ -196,7 +196,7 @@ def init_hidden(
return (h_0, c_0)


class Attn(nn.Module):
class Attn(nn.Module): # type: ignore[misc]
method: str
hidden_size: int
attn: nn.Linear
Expand Down Expand Up @@ -256,7 +256,7 @@ def forward(
return F.softmax(attn_energies, 1)


class AttentionDecoder(nn.Module):
class AttentionDecoder(nn.Module): # type: ignore[misc]
vocabulary_size: int
hidden_size: int
character_embedding: nn.Embedding
Expand Down Expand Up @@ -324,7 +324,7 @@ def forward(
return x, hidden[0], attn_weights


class Seq2Seq(nn.Module):
class Seq2Seq(nn.Module): # type: ignore[misc]
encoder: Encoder
decoder: AttentionDecoder
pad_idx: int
Expand Down
8 changes: 4 additions & 4 deletions pythainlp/transliterate/thaig2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def g2p(self, text: str) -> str:
return "".join(target)


class Encoder(nn.Module):
class Encoder(nn.Module): # type: ignore[misc]
hidden_size: int
character_embedding: nn.Embedding
rnn: nn.LSTM
Expand Down Expand Up @@ -216,7 +216,7 @@ def init_hidden(
return (h_0, c_0)


class Attn(nn.Module):
class Attn(nn.Module): # type: ignore[misc]
method: str
hidden_size: int
attn: nn.Linear
Expand Down Expand Up @@ -278,7 +278,7 @@ def forward(
return F.softmax(attn_energies, 1)


class AttentionDecoder(nn.Module):
class AttentionDecoder(nn.Module): # type: ignore[misc]
vocabulary_size: int
hidden_size: int
character_embedding: nn.Embedding
Expand Down Expand Up @@ -346,7 +346,7 @@ def forward(
return x, hidden[0], attn_weights


class Seq2Seq(nn.Module):
class Seq2Seq(nn.Module): # type: ignore[misc]
encoder: Encoder
decoder: AttentionDecoder
pad_idx: int
Expand Down
Loading