From bffc5d85f20cc26a444a19a4488ffa85acab4fbc Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 23 May 2023 18:52:52 +0200 Subject: [PATCH] Don't explicitly derive from `object` in Python (#1552) That's an artifact from Python 2, Python 3 does that automatically. --- uniffi_bindgen/src/bindings/python/templates/EnumTemplate.py | 2 +- .../src/bindings/python/templates/ObjectTemplate.py | 2 +- .../src/bindings/python/templates/RustBufferTemplate.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uniffi_bindgen/src/bindings/python/templates/EnumTemplate.py b/uniffi_bindgen/src/bindings/python/templates/EnumTemplate.py index 5c366d8855..b24448be46 100644 --- a/uniffi_bindgen/src/bindings/python/templates/EnumTemplate.py +++ b/uniffi_bindgen/src/bindings/python/templates/EnumTemplate.py @@ -19,7 +19,7 @@ def __init__(self): # Each enum variant is a nested class of the enum itself. {% for variant in e.variants() -%} - class {{ variant.name()|enum_variant_py }}(object): + class {{ variant.name()|enum_variant_py }}: def __init__(self,{% for field in variant.fields() %}{{ field.name()|var_name }}{% if loop.last %}{% else %}, {% endif %}{% endfor %}): {% if variant.has_fields() %} {%- for field in variant.fields() %} diff --git a/uniffi_bindgen/src/bindings/python/templates/ObjectTemplate.py b/uniffi_bindgen/src/bindings/python/templates/ObjectTemplate.py index d8c4ea7aa2..ebf0284525 100644 --- a/uniffi_bindgen/src/bindings/python/templates/ObjectTemplate.py +++ b/uniffi_bindgen/src/bindings/python/templates/ObjectTemplate.py @@ -1,6 +1,6 @@ {%- let obj = ci.get_object_definition(name).unwrap() %} -class {{ type_name }}(object): +class {{ type_name }}: {%- match obj.primary_constructor() %} {%- when Some with (cons) %} def __init__(self, {% call py::arg_list_decl(cons) -%}): diff --git a/uniffi_bindgen/src/bindings/python/templates/RustBufferTemplate.py b/uniffi_bindgen/src/bindings/python/templates/RustBufferTemplate.py index ad4a65bc8c..a97e702747 100644 --- a/uniffi_bindgen/src/bindings/python/templates/RustBufferTemplate.py +++ b/uniffi_bindgen/src/bindings/python/templates/RustBufferTemplate.py @@ -75,7 +75,7 @@ def __str__(self): return "ForeignBytes(len={}, data={})".format(self.len, self.data[0:self.len]) -class RustBufferStream(object): +class RustBufferStream: """ Helper for structured reading of bytes from a RustBuffer """ @@ -140,7 +140,7 @@ def readDouble(self): def readCSizeT(self): return self._unpack_from(ctypes.sizeof(ctypes.c_size_t) , "@N") -class RustBufferBuilder(object): +class RustBufferBuilder: """ Helper for structured writing of bytes into a RustBuffer. """