Skip to content
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

Fix enum lookup #125220

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions homeassistant/components/google_cloud/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,10 @@
_LOGGER.error("Error: %s when validating options: %s", err, options)
return None, None

encoding: texttospeech.AudioEncoding = texttospeech.AudioEncoding[
options[CONF_ENCODING]
] # type: ignore[misc]
gender: texttospeech.SsmlVoiceGender | None = texttospeech.SsmlVoiceGender[
encoding = texttospeech.AudioEncoding(options[CONF_ENCODING])
gender: texttospeech.SsmlVoiceGender | None = texttospeech.SsmlVoiceGender(

Check warning on line 176 in homeassistant/components/google_cloud/tts.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/google_cloud/tts.py#L175-L176

Added lines #L175 - L176 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

could it still be None then?

Copy link
Member Author

@cdce8p cdce8p Sep 4, 2024

Choose a reason for hiding this comment

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

if voice is given, it's set to None. So the explicit annotation is necessary here.
encoding will never be set to None though.

voice = options[CONF_VOICE]
if voice:
gender = None

options[CONF_GENDER]
] # type: ignore[misc]
)
voice = options[CONF_VOICE]
if voice:
gender = None
Expand Down