-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Removed webcolors dependency in favor of dictionary lookup. #2215
Conversation
|
||
HASS_COLOR_MAX = 500 # mireds (inverted) | ||
HASS_COLOR_MIN = 154 | ||
|
||
|
||
def color_name_to_rgb(color_name): |
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.
- D202: No blank lines allowed after function docstring (found 1)
- D210: No whitespaces allowed surrounding docstring text
- D401: First line should be in imperative mood ('Convert', not 'Converts')
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
|
||
HASS_COLOR_MAX = 500 # mireds (inverted) | ||
HASS_COLOR_MIN = 154 | ||
|
||
|
||
def color_name_to_rgb(color_name): | ||
"""Convert color name to RGB hex value.""" | ||
colors = { |
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.
Please make this a constant in this module so that the Python interpreter will not be required to rebuild it every time this function is called.
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.
Good point. Moved to module. Thanks
'hot pink': (252, 15, 192), 'fuchsia': (255, 119, 255), | ||
'lavender': (181, 126, 220), 'indigo': (75, 0, 130), | ||
'maroon': (128, 0, 0), 'crimson': (220, 20, 60)} | ||
try: |
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.
You can do this without a try.
hex_value = colors.get(color_name.lower())
if not hex_value:
_LOGGER.....
hex_value = (255, 255, 255)
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.
Went with this suggestion to keep log message.
Looks good! 🐬 |
Description:
Removed webcolors module in favor of dictionary lookup.
Related issue (if applicable): fixes #
https://www.pivotaltracker.com/story/show/120785401
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If code communicates with devices:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass