mirror of
https://github.com/aclist/dztui.git
synced 2026-11-11 20:40:38 +01:00
feat: immutable decorator
This commit is contained in:
1 parent
ba92d15085
commit
7a6f4a2bb9
1 file changed
+9
@@ -0,0 +1,9 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
def immutable_dataclass(cls: type | None = None, **kwargs: bool) -> type | Callable[[type], type]:
|
||||||
|
kwargs["slots"] = True
|
||||||
|
kwargs["frozen"] = True
|
||||||
|
if cls is None:
|
||||||
|
return lambda c: dataclass(c, **kwargs)
|
||||||
|
return dataclass(cls, **kwargs)
|
||||||
Reference in new issue
Block a user