Skip to content

Commit

Permalink
build: enforce pydocstyle only in the actual module
Browse files Browse the repository at this point in the history
  • Loading branch information
WieeRd committed Feb 12, 2024
1 parent f93caf2 commit 8677538
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
14 changes: 5 additions & 9 deletions mklookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


def jamo_to_compat_jamo(jamo: str, /) -> str | None:
"""Maps a Jamo character to a Compatibility Jamo character."""
name = ud.name(jamo).split(" ")[-1] # HANGUL CHOSEONG "KIYEOK"
try:
return ud.lookup(f"HANGUL LETTER {name}")
Expand All @@ -15,7 +14,6 @@ def jamo_to_compat_jamo(jamo: str, /) -> str | None:


def compat_jaum_to_choseong(compat_jaum: str, /) -> str | None:
"""Maps a Compatibility Jaum character to a Jamo Choseong character."""
name = ud.name(compat_jaum).split(" ")[-1] # HANGUL LETTER "KIYEOK"
try:
return ud.lookup(f"HANGUL CHOSEONG {name}")
Expand All @@ -24,13 +22,11 @@ def compat_jaum_to_choseong(compat_jaum: str, /) -> str | None:


def compat_jaum_to_jongseong(compat_jaum: str, /) -> str:
"""Maps a Compatibility Jaum character to a Jamo Jongseong character."""
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:
"""Decomposes a composite Jongseong into tuple of 2 Jongseongs."""
name = ud.name(jongseong).split(" ")[-1] # HANGUL JONGSEONG "KIYEOK"

# SSANG{jaum} e.g. SSANGKIYEOK
Expand Down Expand Up @@ -59,26 +55,26 @@ def decompose_jongseong(jongseong: str, /) -> tuple[str, str] | None:

T = TypeVar("T")

def _mklookup(convert: Callable[[str], T], base: int, end: int) -> list[T]:
def mklookup(convert: Callable[[str], T], base: int, end: int) -> list[T]:
return [convert(chr(code)) for code in range(base, end + 1)]

CHOSEONG_TO_COMPAT_JAUM = _mklookup(
CHOSEONG_TO_COMPAT_JAUM = mklookup(
jamo_to_compat_jamo,
hg.MODERN_CHOSEONG_BASE,
hg.MODERN_CHOSEONG_END,
)
JONGSEONG_TO_COMPAT_JAUM = _mklookup(
JONGSEONG_TO_COMPAT_JAUM = mklookup(
jamo_to_compat_jamo,
hg.MODERN_JONGSEONG_BASE,
hg.MODERN_JONGSEONG_END,
)

COMPAT_JAUM_TO_CHOSEONG = _mklookup(
COMPAT_JAUM_TO_CHOSEONG = mklookup(
compat_jaum_to_choseong,
hg.MODERN_COMPAT_JAUM_BASE,
hg.MODERN_COMPAT_JAUM_END,
)
COMPAT_JAUM_TO_JONGSEONG = _mklookup(
COMPAT_JAUM_TO_JONGSEONG = mklookup(
compat_jaum_to_jongseong,
hg.MODERN_COMPAT_JAUM_BASE,
hg.MODERN_COMPAT_JAUM_END,
Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ output-format = "grouped"
extend-select = [
"C90", # mccabe
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"ANN001", "ANN2", # annotations
"ASYNC", # async
Expand All @@ -46,13 +45,9 @@ extend-select = [
"RUF", # ruff
]

# F403: checks for wildcard imports (`from module import *`)
# excuse: import * will always be used modules containing `__all__`
# allow wildcard imports in `__init__.py`
per-file-ignores = { "__init__.py" = ["F403"] }

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.format]
preview = true

Expand Down
7 changes: 7 additions & 0 deletions ricecake/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extend = "../pyproject.toml"

[lint]
extend-select = ["D"] # pydocstyle

[lint.pydocstyle]
convention = "google"

0 comments on commit 8677538

Please sign in to comment.