Skip to content

Commit dadade3

Browse files
committed
Switch mypy to ty
1 parent 2377617 commit dadade3

File tree

8 files changed

+2689
-84
lines changed

8 files changed

+2689
-84
lines changed

flake.lock

Lines changed: 0 additions & 26 deletions
This file was deleted.

pyproject.toml

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,43 @@
1-
[tool.poetry]
1+
[project]
22
name = "ttc"
33
version = "0.1.0"
44
description = "A Text-To-Conversation Natural Language Processing toolkit."
5-
authors = ["Ilya I. Nikitin <ilya.i.nikitin@proton.me>"]
6-
license = "GPL-3.0+"
75
readme = "README.md"
8-
repository = "https://github.com/f1uctus/ttc"
9-
10-
[tool.poetry.dependencies]
11-
# required
12-
python = ">=3.8,<3.13"
13-
click = ">=8.0,<9.0"
14-
numpy = ">=1.24.0,<2.0.0"
15-
spacy = ">=3.5.0,<4.0.0"
16-
ru_core_news_sm = { url = "https://github.com/explosion/spacy-models/releases/download/ru_core_news_sm-3.7.0/ru_core_news_sm-3.7.0.tar.gz" }
17-
18-
[tool.poetry.group.large_models_ru]
19-
optional = true
20-
21-
[tool.poetry.group.large_models_ru.dependencies]
22-
ru_core_news_md = { url = "https://github.com/explosion/spacy-models/releases/download/ru_core_news_md-3.7.0/ru_core_news_md-3.7.0.tar.gz" }
23-
ru_core_news_lg = { url = "https://github.com/explosion/spacy-models/releases/download/ru_core_news_lg-3.7.0/ru_core_news_lg-3.7.0.tar.gz" }
24-
25-
[tool.poetry.group.dev]
26-
optional = true
27-
28-
[tool.poetry.group.dev.dependencies]
29-
pytest = { version = ">=7.2.1" }
30-
jupyter = { version = ">=1.0.0" }
31-
mypy = { version = ">=1.0" }
32-
black = { version = ">=23.1" }
33-
ruff = {version = ">=0.0.275"}
34-
35-
[tool.poetry.scripts]
36-
ttc = "ttc:cli.cli"
6+
license = "GPL-3.0-or-later"
7+
authors = [
8+
{ name = "Ilya Nikitin", email = "ilya.i.nikitin@proton.me" }
9+
]
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"click>=8.0,<9.0",
13+
"numpy>=1.24.0,<2.0.0",
14+
"spacy>=3.8,<4.0",
15+
"ru_core_news_sm @ https://github.com/explosion/spacy-models/releases/download/ru_core_news_sm-3.8.0/ru_core_news_sm-3.8.0.tar.gz"
16+
]
17+
18+
[tool.uv.build-backend]
19+
module-name = "ttc"
20+
module-root = "."
3721

3822
[build-system]
39-
requires = ["poetry-core>=1.0.0"]
40-
build-backend = "poetry.core.masonry.api"
41-
42-
[tool.mypy]
43-
python_version = "3.8"
44-
implicit_reexport = true
45-
show_error_context = true
46-
show_column_numbers = true
47-
show_error_codes = true
48-
warn_return_any = true
49-
warn_unused_configs = true
50-
warn_unused_ignores = true
51-
warn_redundant_casts = true
52-
strict_optional = true
53-
54-
[[tool.mypy.overrides]]
55-
module = "tests.*"
56-
ignore_errors = true
23+
requires = ["uv_build"]
24+
build-backend = "uv_build"
25+
26+
[project.optional-dependencies]
27+
large_models_ru = [
28+
"ru_core_news_md @ https://github.com/explosion/spacy-models/releases/download/ru_core_news_md-3.8.0/ru_core_news_md-3.8.0.tar.gz",
29+
"ru_core_news_lg @ https://github.com/explosion/spacy-models/releases/download/ru_core_news_lg-3.8.0/ru_core_news_lg-3.8.0.tar.gz"
30+
]
31+
dev = [
32+
"pytest>=7.2.1",
33+
"jupyter>=1.0.0",
34+
"ty",
35+
"black>=23.1",
36+
"ruff>=0.0.275"
37+
]
38+
39+
[project.scripts]
40+
ttc = "ttc.cli:cli"
5741

5842
[tool.black]
5943
line-length = 88

ttc/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import click
66
from click import echo
7-
from colorama import init as colorama_init, Fore, Back, Style # type: ignore
7+
from colorama import init as colorama_init, Fore, Back, Style
88
from spacy.tokens import Span
99

1010
import ttc
@@ -35,6 +35,8 @@ def print_play(file: TextIO, language, with_text: bool):
3535
echo("Specified language is not supported")
3636
exit(1)
3737

38+
assert cc is not None
39+
3840
text = file.read().split("-" * 20)[0]
3941
file.close()
4042

@@ -51,7 +53,7 @@ def print_play(file: TextIO, language, with_text: bool):
5153
}
5254

5355
echo("Actors found:")
54-
echo(", ".join(c + s.text + Style.RESET_ALL for _, (s, c) in actor_colors.items()))
56+
echo(", ".join(c + s.text + str(Style.RESET_ALL) for _, (s, c) in actor_colors.items()))
5557

5658
first_col_w = max(len(str(s)) for s in play.actors)
5759
for r, s in play.lines:

ttc/iterables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import itertools
2+
from collections import OrderedDict
23
from typing import (
34
Iterable,
45
Iterator,
@@ -7,7 +8,6 @@
78
List,
89
Tuple,
910
Dict,
10-
OrderedDict,
1111
)
1212

1313
T = TypeVar("T")

ttc/language/common/span_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def trim(self: Span, should_trim: Callable[[Token], bool]) -> Span:
8181

8282
@span_extension("method")
8383
def trim_non_word(self: Span) -> Span:
84-
return trim(self, non_word) # type: ignore
84+
return trim(self, non_word)
8585

8686

8787
@span_extension("method")

ttc/language/russian/conversation_classifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import Dict
2+
from typing import Dict, Any
33

44
import spacy
55
from spacy import Language
@@ -32,7 +32,7 @@ def __init__(self):
3232

3333
russian_pipelines.register_for(self.language)
3434

35-
self.language.vocab.get_noun_chunks = noun_chunks
35+
self.language.vocab.get_noun_chunks = noun_chunks # type: ignore
3636

3737
if not Doc.has_extension("nl_indices"):
3838
Doc.set_extension("nl_indices", default=frozenset())

ttc/language/russian/pipelines/replicizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def flush_replica(*tags: Callable[[Span], Any]):
6161
if tokens:
6262
replica_span = doc[tokens[0].i : tokens[-1].i + 1]
6363
for tag in tags:
64-
replica_span._.set(tag.__name__, True)
64+
replica_span._.set(getattr(tag, "__name__", str(tag)), True)
6565
replicas.append(replica_span)
6666
tokens.clear()
6767

@@ -177,7 +177,7 @@ def flush_replica(*tags: Callable[[Span], Any]):
177177
doc[pt.i : line_end_i + 1], as_spans=True
178178
)
179179
for match in results:
180-
match: Span = match # type: ignore
180+
match: Span = match
181181
# may be an interrogative or exclamatory ending of a speech
182182
# e.g. После всего этого, — что ты еще сказал?
183183
if match[0] != pt and match[0].is_punct:

0 commit comments

Comments
 (0)