From 8b7c598407a5fea9a3d78473e72df87606998cd4 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 4 Aug 2023 10:10:28 +0300 Subject: Copy over files from GN3 repository. --- gn_auth/auth/dictify.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 gn_auth/auth/dictify.py (limited to 'gn_auth/auth/dictify.py') 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() -- cgit v1.2.3