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
Use unicode slugify #19192
Use unicode slugify #19192
Conversation
homeassistant/util/__init__.py
Outdated
@@ -14,6 +14,8 @@ | |||
from typing import (Any, Optional, TypeVar, Callable, KeysView, Union, # noqa | |||
Iterable, List, Dict, Iterator, Coroutine, MutableSet) | |||
|
|||
from slugify import slugify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sense some naming issues ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed :D
I definitely have localized entity ids that could be improved. Kinda hard to give comments though, some before/after examples would be nice ... maybe as tests? |
@pvizeli Please test results with this method https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/core.py#L78 |
homeassistant/util/__init__.py
Outdated
|
||
return text | ||
return moz_slug.slugify( | ||
text, ok='_-', space_replacement='_', only_ascii=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think -
is a valid entity id ?
Breaking change because any entity that does not have a unique ID and has foreign characters in their name will get a new entity ID. |
Maybe we need to move to https://github.com/un33k/python-slugify because the Mozilla PyPI packages are very outdated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to merge when tests and typing fixed.
* Update __init__.py * Update setup.py * Update requirements_all.txt * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * remove `-` * fix packages * Update package_constraints.txt * Update __init__.py * Update package_constraints.txt * Update requirements_all.txt * Update setup.py * Fix tests * Fix line issue * fix all test * fix type * Fix lint
This change did break a lot of unique_ids in my setup:
It looks like a "-" character was removed in the past. Now it's mapped from "-" to "_". |
uhm, unique IDs should not get slugified. Maybe you want to add a PR that copies the old slugify function into the xiaomi_aqara component and use that to prevent a breaking change. |
I will update the xiaomi_aqara component. |
The PR will break all entity ids (without unique_id) which are containing a minus sign "-". In the past this character was removed. In future it is mapped to an underscore. |
Description:
Use mozilla slugify library with UTF-8 support:
https://github.com/mozilla/unicode-slugify
Fix: #19184
Update:
We need to move to https://github.com/un33k/python-slugify because the Mozilla PyPI packages are very outdated