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

Mark ReadOnlyDict with @final #142059

Merged
merged 1 commit into from
Apr 2, 2025
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
3 changes: 2 additions & 1 deletion homeassistant/util/read_only_dict.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Read only dictionary."""

from copy import deepcopy
from typing import Any
from typing import Any, final


def _readonly(*args: Any, **kwargs: Any) -> Any:
"""Raise an exception when a read only dict is modified."""
raise RuntimeError("Cannot modify ReadOnlyDict")


@final # Final to allow direct checking of the type instead of using isinstance
class ReadOnlyDict[_KT, _VT](dict[_KT, _VT]):
"""Read only version of dict that is compatible with dict types."""

Expand Down