Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(pre-commit.ci): pre-commit autoupdate #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "CHANGELOG.md|.copier-answers.yml"
default_stages: [commit]
default_stages: [pre-commit]

ci:
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"

repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.1
rev: v4.0.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: debug-statements
- id: check-builtin-literals
Expand All @@ -28,11 +28,11 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-poetry/poetry
rev: 1.8.4
rev: 1.8.0
hooks:
- id: poetry-check
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: ["--tab-width", "2"]
Expand All @@ -50,15 +50,15 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.10.0
hooks:
- id: black
# - repo: https://github.com/codespell-project/codespell
# rev: v2.2.5
# hooks:
# - id: codespell
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
Expand All @@ -67,11 +67,11 @@ repos:
- id: mypy
additional_dependencies: []
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
rev: 1.8.0
hooks:
- id: bandit
args: [-x, tests]
- repo: https://github.com/srstevenson/nb-clean
rev: "3.3.0"
rev: "4.0.1"
hooks:
- id: nb-clean
9 changes: 6 additions & 3 deletions src/mecab_text_cleaner/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ def to_reading(
reading_type: Literal["orth", "pron", "kana"] = "pron",
add_atype: bool = True,
add_blank_between_words: bool = True,
when_unknown: Literal["passthrough", "*", "unidecode"]
| Callable[[str], str] = "passthrough",
when_unknown: (
Literal["passthrough", "*", "unidecode"] | Callable[[str], str]
) = "passthrough",
tagger: fugashi.Tagger = _get_tagger(),
) -> str:
"""Convert text to reading.
Expand Down Expand Up @@ -212,7 +213,9 @@ def to_reading(

if reading in ("", "*", None):
# unknown reading
if not (word.feature.pos1 == "補助記号" and word.feature.pos2 == "一般"):
if not (
word.feature.pos1 == "補助記号" and word.feature.pos2 == "一般"
):
# known symbol
if add_blank_between_words:
res = res[:-1]
Expand Down
15 changes: 12 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ def test_simple():


def test_complex():
assert to_reading(" 1한. 人、武蔵 小杉に向かう。") == "1 한. ヒト=、 ム]サシ コスギ= ニ ムカウ=。"
assert (
to_reading(" 1한. 人、武蔵 小杉に向かう。")
== "1 한. ヒト=、 ム]サシ コスギ= ニ ムカウ=。"
)


def test_multiline():
assert to_reading(" 한空、雲。\n雨!(") == "한 ソ]ラ、 ク]モ。\nア]メ!("


def test_multiline_noatype():
assert to_reading(" 한空、雲。\n雨!(", add_atype=False) == "한 ソラ、 クモ。\nアメ!("
assert (
to_reading(" 한空、雲。\n雨!(", add_atype=False)
== "한 ソラ、 クモ。\nアメ!("
)


def test_multiline_noblank():
Expand All @@ -34,7 +40,10 @@ def test_multiline_unidecode():


def test_multiline_star():
assert to_reading(" 한空、雲。\n雨!(", when_unknown="*") == "* ソ]ラ、 ク]モ。\nア]メ!("
assert (
to_reading(" 한空、雲。\n雨!(", when_unknown="*")
== "* ソ]ラ、 ク]モ。\nア]メ!("
)


def test_multiline_custom():
Expand Down
Loading