Skip to content

Make util.color._match_max_scale public#59207

Merged
balloob merged 2 commits intohome-assistant:devfrom
farmio:match_max_scale
Nov 11, 2021
Merged

Make util.color._match_max_scale public#59207
balloob merged 2 commits intohome-assistant:devfrom
farmio:match_max_scale

Conversation

@farmio
Copy link
Copy Markdown
Member

@farmio farmio commented Nov 5, 2021

Proposed change

Make util.color._match_max_scale public.
I'd like to use it in an integration for converting RGB values with normalized brightness to the HA used model of independent brightness and RGB levels.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@farmio farmio requested a review from a team as a code owner November 5, 2021 22:40
@probot-home-assistant probot-home-assistant bot added core small-pr PRs with less than 30 lines. labels Nov 5, 2021
Copy link
Copy Markdown
Contributor

@marvin-w marvin-w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let's see what the others say.

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Nov 6, 2021

I think its fine to make it public, but we should also test it directly in that case in tests/util/test_color.py

# Match the output maximum value to the input. This ensures the full
# channel range is used.
return _match_max_scale((r, g, b), rgbw) # type: ignore
return match_max_scale((r, g, b), rgbw) # type: ignore[return-value]
Copy link
Copy Markdown
Member Author

@farmio farmio Nov 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add @overloads for the used tuple length variations (3, 4 and 5 x int)? or better keep the ignores?
This would add ~20 lines to the code just for type variations 😬

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore is fine.

@balloob balloob merged commit f8f060b into home-assistant:dev Nov 11, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2021
@farmio farmio deleted the match_max_scale branch November 13, 2021 22:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed core small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants