Skip to content

Commit 8756bb9

Browse files
committed
normalize special characters
1 parent e338f7b commit 8756bb9

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

openapi_python_client/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from keyword import iskeyword
77
from typing import Any
88

9+
from unidecode import unidecode
10+
911
from .config import Config
1012

1113
DELIMITERS = r"\. _-"
@@ -44,8 +46,8 @@ def __deepcopy__(self, _: Any) -> ClassName:
4446

4547

4648
def sanitize(value: str) -> str:
47-
"""Removes every character that isn't 0-9, A-Z, a-z, or a known delimiter"""
48-
return re.sub(rf"[^\w{DELIMITERS}]+", "", value)
49+
"""Removes every character that isn't 0-9, A-Z, a-z, or a known delimiter and normalizes it to convert special characters"""
50+
return unidecode(re.sub(rf"[^\w{DELIMITERS}]+", "", value))
4951

5052

5153
def split_words(value: str) -> list[str]:

pdm.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"ruamel.yaml>=0.18.6,<0.19.0",
1717
"ruff>=0.2,<0.13",
1818
"typing-extensions>=4.8.0,<5.0.0",
19+
"unidecode>=1.4.0",
1920
]
2021
name = "openapi-python-client"
2122
version = "0.25.2"

0 commit comments

Comments
 (0)