Mark ReadOnlyDict with @final (#142059)

This commit is contained in:
Erik Montnemery 2025-04-02 14:06:01 +02:00 committed by GitHub
parent 8200c234dd
commit 6fbee5c2e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
"""Read only dictionary."""
from copy import deepcopy
from typing import Any
from typing import Any, final
def _readonly(*args: Any, **kwargs: Any) -> Any:
@ -9,6 +9,7 @@ def _readonly(*args: Any, **kwargs: Any) -> Any:
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."""