Fokko commented on code in PR #4767:
URL: https://github.com/apache/iceberg/pull/4767#discussion_r873965560


##########
python/src/iceberg/types.py:
##########
@@ -148,56 +159,28 @@ def __new__(
         cls._instances[key] = cls._instances.get(key) or object.__new__(cls)
         return cls._instances[key]
 
-    def __init__(
-        self,
-        field_id: int,
-        name: str,
-        field_type: IcebergType,
-        is_optional: bool = True,
-        doc: Optional[str] = None,
-    ):
-        if not self._initialized:
-            docString = "" if doc is None else f", doc={repr(doc)}"
-            super().__init__(
-                (
-                    f"{field_id}: {name}: {'optional' if is_optional else 
'required'} {field_type}" ""
-                    if doc is None
-                    else f" ({doc})"
-                ),
-                f"NestedField(field_id={field_id}, name={repr(name)}, 
field_type={repr(field_type)}, is_optional={is_optional}"
-                f"{docString})",
-            )
-            self._is_optional = is_optional
-            self._id = field_id
-            self._name = name
-            self._type = field_type
-            self._doc = doc
-
-    @property
-    def is_optional(self) -> bool:
-        return self._is_optional
-
     @property
     def is_required(self) -> bool:
-        return not self._is_optional
-
-    @property
-    def field_id(self) -> int:
-        return self._id
-
-    @property
-    def name(self) -> str:
-        return self._name
-
-    @property
-    def doc(self) -> Optional[str]:
-        return self._doc
-
+        return not self.is_optional
+
+    def __post_init__(self):
+        object.__setattr__(
+            self,
+            "type_string",
+            (
+                f"{self.field_id}: {self.name}: {'optional' if 
self.is_optional else 'required'} {self.type}"
+                if self.doc is None
+                else f" ({self.doc})"
+            ),
+        )
+
+    # Alias for field_type
     @property
     def type(self) -> IcebergType:
-        return self._type
+        return self.field_type

Review Comment:
   Relative small change: 
https://github.com/apache/iceberg/pull/4767/commits/f4661656ad303239467888dc9913d5d4bd83014e
 :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to