-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Small fix fix when dumping config when names are only digits but stil… #13377
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
Conversation
…l ok according to the validation (used with tellstick sensor mappings)
CLA signed! :) |
CC @kellerza |
@@ -252,7 +252,7 @@ def dump_dict(layer, indent_count=3, listi=False, **kwargs): | |||
""" | |||
def sort_dict_key(val): | |||
"""Return the dict key for sorting.""" | |||
key = str.lower(val[0]) | |||
key = str.lower(val[0]) if isinstance(val[0], str) else str(val[0]) |
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.
Maybe just str(val[0]).lower()
?
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.
Yeah! That would be a nicer solution, but then it will always convert even if it is a string (witch it is in 99% of the cases). This is though just a function used with testing. So depends if nice code or speed is needed? ;)
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.
It's only for human consumption, like you say, so let go with nice code...
Thank you @hAmpzter ! 🎉 |
…l ok according to the validation (used with tellstick sensor mappings)
Description:
Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: