Skip to content

Commit

Permalink
fix: remove meaningless positional only arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
WieeRd committed Feb 27, 2024
1 parent df50a01 commit 38a2d3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions mklookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
from typing import TypeVar


def jamo_to_compat_jamo(jamo: str, /) -> str | None:
def jamo_to_compat_jamo(jamo: str) -> str | None:
name = ud.name(jamo).split(" ")[-1] # HANGUL CHOSEONG "KIYEOK"
try:
return ud.lookup(f"HANGUL LETTER {name}")
except KeyError:
return None


def compat_jaum_to_choseong(compat_jaum: str, /) -> str | None:
def compat_jaum_to_choseong(compat_jaum: str) -> str | None:
name = ud.name(compat_jaum).split(" ")[-1] # HANGUL LETTER "KIYEOK"
try:
return ud.lookup(f"HANGUL CHOSEONG {name}")
except KeyError:
return None


def compat_jaum_to_jongseong(compat_jaum: str, /) -> str:
def compat_jaum_to_jongseong(compat_jaum: str) -> str:
name = ud.name(compat_jaum).split(" ")[-1] # HANGUL LETTER "KIYEOK"
return ud.lookup(f"HANGUL JONGSEONG {name}")


def decompose_jongseong(jongseong: str, /) -> tuple[str, str] | None:
def decompose_jongseong(jongseong: str) -> tuple[str, str] | None:
name = ud.name(jongseong).split(" ")[-1] # HANGUL JONGSEONG "KIYEOK"

# SSANG{jaum} e.g. SSANGKIYEOK
Expand Down
4 changes: 2 additions & 2 deletions ricecake/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def compose(cho: str, jung: str, jong: str | None) -> str:
)


def decompose(c: str, /) -> tuple[str, str, str | None]:
def decompose(syllable: str) -> tuple[str, str, str | None]:
"""Decomposes a Syllable into Choseong, Jungseong, and an optional Jongseong.
Raises:
ValueError: If the character is not a Hangul Syllable.
"""
syl = o.syllable_offset(c)
syl = o.syllable_offset(syllable)

cho = syl // o.CHOSEONG_COEF
jung = syl % (o.CHOSEONG_COEF) // o.JUNGSEONG_COEF
Expand Down
20 changes: 10 additions & 10 deletions ricecake/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,54 @@
# | - [ ] add `classify_jamo() -> tuple[JamoKind, int]`
# | - [ ] `jamo_to_compat_jamo() -> str | None`
# | - [x] RIIR & PyO3
def jamo_to_compat_jamo(c: str, /) -> str:
def jamo_to_compat_jamo(jamo: str) -> str:
"""Converts a Hangul Jamo character to a Compatibility Jamo character.
Raises:
ValueError: If the character is not a Hangul Jamo.
"""
with suppress(ValueError):
i = o.choseong_offset(c)
i = o.choseong_offset(jamo)
return CHOSEONG_TO_COMPAT_JAUM[i]

with suppress(ValueError):
i = o.jungseong_offset(c)
i = o.jungseong_offset(jamo)
return chr(i + o.MODERN_COMPAT_MOUM_BASE)

with suppress(ValueError):
i = o.jongseong_offset(c)
i = o.jongseong_offset(jamo)
return JONGSEONG_TO_COMPAT_JAUM[i - 1]

raise ValueError("expected a modern Hangul Jamo character")


def compat_jaum_to_choseong(c: str, /) -> str | None:
def compat_jaum_to_choseong(compat_jaum: str) -> str | None:
"""Converts a Hangul Compatibility Jaum character to a Jamo Choseong character.
Returns `None` if there is no corresponding Jamo Choseong character.
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Jaum.
"""
i = o.compat_jaum_offset(c)
i = o.compat_jaum_offset(compat_jaum)
return COMPAT_JAUM_TO_CHOSEONG[i]


def compat_moum_to_jungseong(c: str, /) -> str:
def compat_moum_to_jungseong(compat_moum: str) -> str:
"""Converts a Hangul Compatibility Moum character to a Jamo Jungseong character.
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Moum.
"""
i = o.compat_moum_offset(c)
i = o.compat_moum_offset(compat_moum)
return chr(i + o.MODERN_JUNGSEONG_BASE)


def compat_jaum_to_jongseong(c: str, /) -> str:
def compat_jaum_to_jongseong(compat_jaum: str) -> str:
"""Converts a Hangul Compatibility Jaum character to a Jamo Jongseong character.
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Jaum.
"""
i = o.compat_jaum_offset(c)
i = o.compat_jaum_offset(compat_jaum)
return COMPAT_JAUM_TO_JONGSEONG[i]

0 comments on commit 38a2d3b

Please sign in to comment.