-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
Ensure service calls are typed [k-n] #62917
Conversation
@@ -67,12 +70,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: | |||
_LOGGER.error("Error occurred during Mazda login request: %s", ex) | |||
raise ConfigEntryNotReady from ex | |||
|
|||
async def async_handle_service_call(service_call=None): | |||
async def async_handle_service_call(service_call: ServiceCall) -> None: |
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.
The previous type hint was wrong.
if TYPE_CHECKING: | ||
assert device_entry |
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 has already been checked in the schema validation (validate_mazda_device_id
)
core/homeassistant/components/mazda/__init__.py
Lines 115 to 116 in 41c497e
if (device_entry := dev_reg.async_get(device_id)) is None: | |
raise vol.Invalid("Invalid device ID") |
if TYPE_CHECKING: | ||
# For mypy: it has already been checked in validate_mazda_device_id | ||
assert device_entry |
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 like these kinds of concepts.
The fact is, async_get
may return None; which should just be handled; not silenced.
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 like it either, and I originally planned to raise a ValueError
.
But then I noticed it was already handled inside the schema validation process.
Proposed change
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: