Skip to content

Commit ccb7a77

Browse files
committed
dead code cleanup
1 parent d079bc2 commit ccb7a77

File tree

16 files changed

+36
-75
lines changed

16 files changed

+36
-75
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ coverage:
2828
pytest --cov=pyconlang
2929

3030

31+
.PHONY: dead-code
32+
dead-code:
33+
vulture pyconlang
34+
35+
3136
.PHONY: env
3237
env:
3338
! [ -d .venv ] && python3 -m venv .venv || true

pyconlang/book/conlang/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def __init__(self, translator: Translator) -> None:
4040
super().__init__()
4141

4242
self.translator = translator
43-
self.valid_cache = False
4443

4544
def extendMarkdown(self, md: Markdown) -> None:
4645
md.registerExtension(self)

pyconlang/book/conlang/advanced_macros.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
from .conlang_macro import ConlangMacro
66

77

8-
class ShortcutRomanizedMacro(ConlangMacro):
9-
@classmethod
10-
def expression(cls) -> str:
11-
return rf"\[\[(?P<text>.+?)\]\]"
12-
13-
def map_match(self, match: re.Match[str]) -> str:
14-
text = match.group("text")
15-
return f"r[{text}]"
16-
17-
188
class AdvancedMacro(ConlangMacro, metaclass=ABCMeta):
199
@classmethod
2010
def expression(cls) -> str:

pyconlang/book/conlang/dictionary.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from ... import CHANGES_GLOB, CHANGES_PATH, LEXICON_GLOB, LEXICON_PATH
77
from ...cache import path_cached_property
8-
from ...domain import DefaultFusion, Morpheme, Word
98
from ...lexicon.domain import Entry
109
from ...translate import Translator
1110

@@ -98,6 +97,3 @@ def show_entry(self, entry: Entry) -> str:
9897
", ".join(forms)
9998
+ f" [ph({entry.form})] pr[{entry.form}] {entry.description()}"
10099
)
101-
102-
def form_to_morphemes(self, form: Word[DefaultFusion]) -> list[Morpheme]:
103-
return self.translator.lexicon.resolve(form).leaves()

pyconlang/book/multi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, pattern: str) -> None:
1818
# have contradictory type annotations,
1919
# so we have to ignore type.
2020
def handleMatch( # type: ignore
21-
self, m: re.Match[str], data: Any
21+
self, m: re.Match[str], _data: Any
2222
) -> tuple[ElementTree.Element, int, int]:
2323
el = ElementTree.Element("span")
2424
el.text = m.group(2)

pyconlang/cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(self, paths: list[AnyPath], func: Callable[[_C], _T]) -> None:
136136
self.attrname = None
137137
self.__doc__ = func.__doc__
138138

139-
def __set_name__(self, owner: _C, name: str) -> None:
139+
def __set_name__(self, _owner: _C, name: str) -> None:
140140
if self.attrname is None:
141141
self.attrname = name
142142
elif name != self.attrname:
@@ -149,7 +149,7 @@ def __set_name__(self, owner: _C, name: str) -> None:
149149
def hidden_name(self) -> str:
150150
return f"__path_cached_func_{self.attrname}"
151151

152-
def __get__(self, instance: _C | None, owner: type[_C] | None = None) -> _T:
152+
def __get__(self, instance: _C | None, _owner: type[_C] | None = None) -> _T:
153153
assert instance is not None
154154

155155
if self.attrname is None:
@@ -244,9 +244,9 @@ def __enter__(self) -> Self:
244244

245245
def __exit__(
246246
self,
247-
exc_type: Optional[Type[BaseException]],
248-
exc_val: Optional[BaseException],
249-
exc_tb: Optional[TracebackType],
247+
_exc_type: Optional[Type[BaseException]],
248+
_exc_val: Optional[BaseException],
249+
_exc_tb: Optional[TracebackType],
250250
) -> bool:
251251
self.cache_path.parent.mkdir(parents=True, exist_ok=True)
252252
self.cache_path.write_bytes(

pyconlang/domain.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,6 @@ def leaves(self) -> list[Compoundable]:
203203
return self.head.leaves() + self.tail.leaves()
204204

205205

206-
def default_compound(
207-
head: "Word[DefaultFusion]", joiner: Joiner, tail: "Word[DefaultFusion]"
208-
) -> "Compound[DefaultFusion]":
209-
return Compound(head, joiner, tail)
210-
211-
212206
Word = Component[Compoundable] | Compound[Compoundable]
213207

214208
DefaultWord = Word[DefaultFusion]
@@ -283,7 +277,3 @@ def scope(self) -> Scope:
283277

284278

285279
DefaultSentence = Sentence[DefaultWord]
286-
287-
288-
def default_sentence(tags: Tags, words: list[DefaultWord]) -> DefaultSentence:
289-
return Sentence(tags, words)

pyconlang/evolve/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class Evolver:
6161
query_cache: PersistentDict[tuple[Path, Query], Evolved]
6262
trace_cache: PersistentDict[tuple[Path, Query], list[TraceLine]]
6363
batcher: Batcher = field(default_factory=Batcher)
64-
clients: dict[Path, LexurgyClient] = field(default_factory=dict)
6564

6665
@classmethod
6766
@contextmanager

pyconlang/lexicon/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def extend_with_affix(
266266
self.resolve(definition.get_form(), scope),
267267
)
268268

269-
def substitute(
269+
def substitute( # todo: remove?
270270
self, var: Var, form: DefaultWord, scope: Scope = Scope()
271271
) -> ResolvedForm:
272272
return self.extend_with_affixes(
@@ -283,12 +283,6 @@ def get_vars(self, name: TemplateName | None) -> tuple[Var, ...]:
283283

284284
raise MissingTemplate(name.name)
285285

286-
def resolve_entry(self, entry: Entry) -> list[ResolvedForm]:
287-
return [
288-
self.substitute(var, entry.form, entry.tags.scope)
289-
for var in self.get_vars(entry.template)
290-
]
291-
292286
def form(self, record: Definable, scope: Scope = Scope()) -> DefaultWord:
293287
match record:
294288
case Prefix() | Suffix():
@@ -297,11 +291,6 @@ def form(self, record: Definable, scope: Scope = Scope()) -> DefaultWord:
297291
case Lexeme():
298292
return self.get_entry(record, scope).form
299293

300-
def resolve_definable(
301-
self, record: Definable, scope: Scope = Scope()
302-
) -> ResolvedForm:
303-
return self.resolve(self.form(record, scope), scope)
304-
305294
def define(self, record: Definable, scope: Scope = Scope()) -> str:
306295
match record:
307296
case Prefix() | Suffix():

pyconlang/lexicon/domain.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class Template:
5858
tags: Tags
5959
vars: tuple[Var, ...]
6060

61-
@classmethod
62-
def from_args(cls, name: TemplateName, tags: Tags, *var_args: Var) -> "Template":
63-
return cls(name, tags, var_args)
64-
6561

6662
@dataclass(eq=True, frozen=True)
6763
class Entry:

0 commit comments

Comments
 (0)