From 3a8bed9bdac7bb507b9b95f7beb0f85e4f048ced Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Mon, 15 Feb 2021 20:55:16 +0100
Subject: [PATCH] Leave out optional attributes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Docs say there are defaults, but there aren't…
---
 dj_iconify/types.py | 53 +++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/dj_iconify/types.py b/dj_iconify/types.py
index e659167..0793421 100644
--- a/dj_iconify/types.py
+++ b/dj_iconify/types.py
@@ -8,34 +8,41 @@ import json
 
 
 class IconifyOptional:
-    left: int = 0
-    top: int = 0
-    width: int = 16
-    height: int = 16
+    left: Optional[int] = None
+    top: Optional[int] = None
+    width: Optional[int] = None
+    height: Optional[int] = None
 
-    rotate: int = 0
-    h_flip: bool = False
-    v_flip: bool = False
+    rotate: Optional[int] = None
+    h_flip: Optional[bool] = None
+    v_flip: Optional[bool] = None
 
     def _as_dict_optional(self) -> dict:
-        return {
-            "left": self.left,
-            "top": self.top,
-            "width": self.width,
-            "height": self.height,
-            "rotate": self.rotate,
-            "hFlip": self.h_flip,
-            "vFlip": self.v_flip,
-        }
+        res = {}
+        if self.left is not None:
+            res["left"] = self.left
+        if self.top is not None:
+            res["top"] = self.top
+        if self.width is not None:
+            res["width"] = self.width
+        if self.height is not None:
+            res["height"] = self.height
+        if self.rotate is not None:
+            res["rotate"] = self.rotate
+        if self.h_flip is not None:
+            res["hFlip"] = self.h_flip
+        if self.v_flip is not None:
+            res["vFlip"] = self.v_flip
+        return res
 
     def _from_dict_optional(self, src: dict) -> None:
-        self.left = src.get("left", None) or self.left
-        self.top = src.get("top", None) or self.top
-        self.width = src.get("width", None) or self.width
-        self.height = src.get("height", None) or self.height
-        self.rotate = src.get("rotate", None) or self.rotate
-        self.h_flip = src.get("hFlip", None) or self.h_flip
-        self.v_flip = src.get("vFlip", None) or self.v_flip
+        self.left = src.get("left", None)
+        self.top = src.get("top", None)
+        self.width = src.get("width", None)
+        self.height = src.get("height", None)
+        self.rotate = src.get("rotate", None)
+        self.h_flip = src.get("hFlip", None)
+        self.v_flip = src.get("vFlip", None)
 
 
 class IconifyIcon(IconifyOptional):
-- 
GitLab