aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/dictify.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth/auth/dictify.py')
-rw-r--r--gn_auth/auth/dictify.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/gn_auth/auth/dictify.py b/gn_auth/auth/dictify.py
new file mode 100644
index 0000000..f9337f6
--- /dev/null
+++ b/gn_auth/auth/dictify.py
@@ -0,0 +1,12 @@
+"""Module for dictifying objects"""
+
+from typing import Any, Protocol
+
+class Dictifiable(Protocol):# pylint: disable=[too-few-public-methods]
+ """Type annotation for generic object with a `dictify` method."""
+ def dictify(self):
+ """Convert the object to a dict"""
+
+def dictify(obj: Dictifiable) -> dict[str, Any]:
+ """Turn `obj` to a dict representation."""
+ return obj.dictify()