Repository: rskmoi/namedivider-python (language: python)

Issue:
Feature/py3 12
Add support for python3.12


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml
index 883e032..9987ca0 100644
--- a/.github/workflows/python-package.yml
+++ b/.github/workflows/python-package.yml
@@ -27,7 +27,7 @@ jobs:
     strategy:
       matrix:
         os: [ubuntu-latest, windows-latest, macos-latest]
-        python-version: [ '3.8', '3.9', '3.10', '3.11']
+        python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12']
     steps:
       - uses: actions/checkout@v3
       - name: Set up Python ${{ matrix.python-version }}
@@ -40,7 +40,12 @@ jobs:
           pip install -r requirements.txt
       - name: Test with pytest
         run: |
-          pytest tests
+          coverage run -m pytest tests
         env:
           PYTHONPATH: .
           PYTHONUTF8: 1
+      - name: Show coverage
+        run: |
+          coverage report
+        env:
+          PYTHONPATH: .
diff --git a/namedivider/version.py b/namedivider/version.py
index b5fdc75..d31c31e 100644
--- a/namedivider/version.py
+++ b/namedivider/version.py
@@ -1,1 +1,1 @@
-__version__ = "0.2.2"
+__version__ = "0.2.3"
diff --git a/pyproject.toml b/pyproject.toml
index 2f484d0..79d407c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,6 +17,7 @@ classifiers = [
     "Programming Language :: Python :: 3.9",
     "Programming Language :: Python :: 3.10",
     "Programming Language :: Python :: 3.11",
+    "Programming Language :: Python :: 3.12",
 ]
 dependencies = [
     "lightgbm>=3.3",
@@ -34,6 +35,12 @@ nmdiv = "namedivider.cli:app"
 [project.urls]
 Homepage = "https://github.com/rskmoi/namedivider-python"
 
+[tool.coverage.run]
+omit = [
+    "*/dist-packages/*",
+    "*/site-packages/*",
+]
+
 [tool.hatch.version]
 path = "namedivider/version.py"
 


Test patch:
diff --git a/requirements-test.txt b/requirements-test.txt
index 3a8401d..2236946 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,7 +1,8 @@
 pytest >=7.1.3,<8.0.0
-mypy ==1.4.0
-ruff ==0.0.275
+mypy == 1.4.0
+ruff == 0.0.275
 black == 23.3.0
+coverage == 7.3.2
 
 # stubs
 types-requests
diff --git a/tests/divider/test_basic_name_divider.py b/tests/divider/test_basic_name_divider.py
index 8e1cf51..02a828c 100644
--- a/tests/divider/test_basic_name_divider.py
+++ b/tests/divider/test_basic_name_divider.py
@@ -6,34 +6,60 @@
 from namedivider.divider.config import NameDividerVersions
 
 name_test_data_v1 = [
+    # two chars
+    ("原敬", {"family": "原", "given": "敬", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # kana and kanji
+    ("中山マサ", {"family": "中山", "given": "マサ", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    ("つるの剛士", {"family": "つるの", "given": "剛士", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # three chars
     (
         "菅義偉",
         {"family": "菅", "given": "義偉", "separator": " ", "score": 0.6328842762252201, "algorithm": "kanji_feature"},
     ),
+    # four chars
     (
         "阿部晋三",
         {"family": "阿部", "given": "晋三", "separator": " ", "score": 0.5745842309372197, "algorithm": "kanji_feature"},
     ),
+    # five chars
     (
         "中曽根康弘",
         {"family": "中曽根", "given": "康弘", "separator": " ", "score": 0.3705325993396728, "algorithm": "kanji_feature"},
     ),
+    # with no kanji in kanji.txt
+    (
+        "蝶院羊",
+        {"family": "蝶", "given": "院羊", "separator": " ", "score": 0.5, "algorithm": "kanji_feature"},
+    ),
 ]
 
 
 name_test_data_v2 = [
+    # two chars
+    ("原敬", {"family": "原", "given": "敬", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # kana and kanji
+    ("中山マサ", {"family": "中山", "given": "マサ", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    ("つるの剛士", {"family": "つるの", "given": "剛士", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # three chars
     (
         "菅義偉",
         {"family": "菅", "given": "義偉", "separator": " ", "score": 0.6328842762252201, "algorithm": "kanji_feature"},
     ),
+    # four chars
     (
         "阿部晋三",
         {"family": "阿部", "given": "晋三", "separator": " ", "score": 0.5440120391041745, "algorithm": "kanji_feature"},
     ),
+    # five chars
     (
         "中曽根康弘",
         {"family": "中曽根", "given": "康弘", "separator": " ", "score": 0.3705325993396728, "algorithm": "kanji_feature"},
     ),
+    # with no kanji in kanji.txt
+    (
+        "蝶院羊",
+        {"family": "蝶", "given": "院羊", "separator": " ", "score": 0.5, "algorithm": "kanji_feature"},
+    ),
 ]
 
 
diff --git a/tests/divider/test_gbdt_name_divider.py b/tests/divider/test_gbdt_name_divider.py
index a229f16..3d45ef5 100644
--- a/tests/divider/test_gbdt_name_divider.py
+++ b/tests/divider/test_gbdt_name_divider.py
@@ -6,9 +6,19 @@
 from namedivider.divider.gbdt_name_divider import GBDTNameDivider
 
 name_test_data_v1 = [
+    # two chars
+    ("原敬", {"family": "原", "given": "敬", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # kana and kanji
+    ("中山マサ", {"family": "中山", "given": "マサ", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    ("つるの剛士", {"family": "つるの", "given": "剛士", "separator": " ", "score": 1.0, "algorithm": "rule"}),
+    # three chars
     ("菅義偉", {"family": "菅", "given": "義偉", "separator": " ", "score": 0.7300634880343344, "algorithm": "gbdt"}),
+    # four chars
     ("阿部晋三", {"family": "阿部", "given": "晋三", "separator": " ", "score": 0.5761118242092244, "algorithm": "gbdt"}),
+    # five chars
     ("中曽根康弘", {"family": "中曽根", "given": "康弘", "separator": " ", "score": 0.47535339308928076, "algorithm": "gbdt"}),
+    # with no kanji in kanji.txt
+    ("蝶院羊", {"family": "蝶院", "given": "羊", "separator": " ", "score": 0.5013754025624984, "algorithm": "gbdt"}),
 ]
 
 
diff --git a/tests/test_name_divider.py b/tests/test_name_divider.py
index 44d53ea..0773f87 100644
--- a/tests/test_name_divider.py
+++ b/tests/test_name_divider.py
@@ -18,6 +18,10 @@
         "中曽根康弘",
         {"family": "中曽根", "given": "康弘", "separator": "_", "score": 0.3705325993396728, "algorithm": "kanji_feature"},
     ),
+    (
+        "蝶院羊",
+        {"family": "蝶", "given": "院羊", "separator": "_", "score": 0.5, "algorithm": "kanji_feature"},
+    ),
     ("中山マサ", {"family": "中山", "given": "マサ", "separator": "_", "score": 1.0, "algorithm": "rule"}),
 ]