[Python] Enhance object API __init__ with typed keyword arguments (#8615)

This commit significantly improves the developer experience for the Python Object-Based API by overhauling the generated `__init__` method for `T`-suffixed classes.

Previously, `T` objects had to be instantiated with an empty constructor, and their fields had to be populated manually one by one. This was verbose and not idiomatic Python.

This change modifies the Python code generator (`GenInitialize`) to produce `__init__` methods that are:

1.  **Keyword-Argument-Friendly**: The constructor now accepts all table/struct fields as keyword arguments, allowing for concise, single-line object creation.

2.  **Fully Typed**: The signature of the `__init__` method is now annotated with Python type hints. This provides immediate benefits for static analysis tools (like Mypy) and IDEs, enabling better autocompletion and type checking.

3.  **Correctly Optional**: The generator now correctly wraps types in `Optional[...]` if their default value is `None`. This applies to strings, vectors, and other nullable fields, ensuring strict type safety.

The new approach remains **fully backward-compatible**, as all arguments have default values. Existing code that uses the empty constructor will continue to work without modification.

#### Example of a Generated `__init__`

**Before:**

```python
class KeyValueT(object):
    def __init__(self):
        self.key = None  # type: str
        self.value = None  # type: str
```

**After:**

```python
class KeyValueT(object):
    def __init__(self, key: Optional[str] = None, value: Optional[str] = None):
        self.key = key
        self.value = value
```

#### Example of User Code

**Before:**

```python
# Old, verbose way
kv = KeyValueT()
kv.key = "instrument"
kv.value = "EUR/USD"
```

**After:**

```python
# New, Pythonic way
kv = KeyValueT(key="instrument", value="EUR/USD")
```
This commit is contained in:
Łukasz Kurowski
2025-07-23 08:57:39 +02:00
committed by GitHub
parent ca73ff34b7
commit c526cb640b
31 changed files with 745 additions and 293 deletions

View File

@@ -287,6 +287,63 @@ class PythonStubGenerator {
}
}
void GenerateObjectInitializerStub(std::stringstream &stub,
const StructDef *struct_def,
Imports *imports) const {
stub << " def __init__(\n";
stub << " self,\n";
for (const FieldDef *field : struct_def->fields.vec) {
if (field->deprecated) continue;
std::string field_name = namer_.Field(*field);
std::string field_type;
const Type &type = field->value.type;
if (IsScalar(type.base_type)) {
field_type = TypeOf(type, imports);
if (field->IsOptional()) { field_type += " | None"; }
} else {
switch (type.base_type) {
case BASE_TYPE_STRUCT: {
Import import_ =
imports->Import(ModuleFor(type.struct_def),
namer_.ObjectType(*type.struct_def));
field_type = "'" + import_.name + "' | None";
break;
}
case BASE_TYPE_STRING:
field_type = "str | None";
break;
case BASE_TYPE_ARRAY:
case BASE_TYPE_VECTOR: {
imports->Import("typing");
if (type.element == BASE_TYPE_STRUCT) {
Import import_ =
imports->Import(ModuleFor(type.struct_def),
namer_.ObjectType(*type.struct_def));
field_type = "typing.List['" + import_.name + "'] | None";
} else if (type.element == BASE_TYPE_STRING) {
field_type = "typing.List[str] | None";
} else {
field_type = "typing.List[" + TypeOf(type.VectorType(), imports) +
"] | None";
}
break;
}
case BASE_TYPE_UNION:
field_type = UnionObjectType(*type.enum_def, imports);
break;
default:
field_type = "typing.Any";
break;
}
}
stub << " " << field_name << ": " << field_type << " = ...,\n";
}
stub << " ) -> None: ...\n";
}
void GenerateObjectStub(std::stringstream &stub, const StructDef *struct_def,
Imports *imports) const {
std::string name = namer_.ObjectType(*struct_def);
@@ -300,6 +357,8 @@ class PythonStubGenerator {
stub << " " << GenerateObjectFieldStub(field, imports) << "\n";
}
GenerateObjectInitializerStub(stub, struct_def, imports);
stub << " @classmethod\n";
stub << " def InitFromBuf(cls, buf: bytes, pos: int) -> " << name
<< ": ...\n";
@@ -1694,6 +1753,7 @@ class PythonGenerator : public BaseGenerator {
field_type = package_reference + "." + field_type;
import_list->insert("import " + package_reference);
}
field_type = "'" + field_type + "'";
break;
case BASE_TYPE_STRING: field_type += "str"; break;
case BASE_TYPE_NONE: field_type += "None"; break;
@@ -1755,8 +1815,12 @@ class PythonGenerator : public BaseGenerator {
void GenInitialize(const StructDef &struct_def, std::string *code_ptr,
std::set<std::string> *import_list) const {
std::string code;
std::string signature_params;
std::string init_body;
std::set<std::string> import_typing_list;
signature_params += GenIndents(2) + "self,";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
@@ -1783,6 +1847,7 @@ class PythonGenerator : public BaseGenerator {
// Scalar or sting fields.
field_type = GetBasePythonTypeForScalarAndString(base_type);
if (field.IsScalarOptional()) {
import_typing_list.insert("Optional");
field_type = "Optional[" + field_type + "]";
}
break;
@@ -1791,18 +1856,23 @@ class PythonGenerator : public BaseGenerator {
const auto default_value = GetDefaultValue(field);
// Writes the init statement.
const auto field_field = namer_.Field(field);
code += GenIndents(2) + "self." + field_field + " = " + default_value +
" # type: " + field_type;
// Build signature with keyword arguments, type hints, and default values.
signature_params += GenIndents(2) + field_field + " = " + default_value + ",";
// Build the body of the __init__ method.
init_body += GenIndents(2) + "self." + field_field + " = " + field_field +
" # type: " + field_type;
}
// Writes __init__ method.
auto &code_base = *code_ptr;
GenReceiverForObjectAPI(struct_def, code_ptr);
code_base += "__init__(self):";
if (code.empty()) {
code_base += "__init__(" + signature_params + GenIndents(1) + "):";
if (init_body.empty()) {
code_base += GenIndents(2) + "pass";
} else {
code_base += code;
code_base += init_body;
}
code_base += "\n";

View File

@@ -32,9 +32,13 @@ def CreateAbility(builder, id, distance):
class AbilityT(object):
# AbilityT
def __init__(self):
self.id = 0 # type: int
self.distance = 0 # type: int
def __init__(
self,
id = 0,
distance = 0,
):
self.id = id # type: int
self.distance = distance # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -114,13 +114,21 @@ except:
class ArrayStructT(object):
# ArrayStructT
def __init__(self):
self.a = 0.0 # type: float
self.b = None # type: Optional[List[int]]
self.c = 0 # type: int
self.d = None # type: Optional[List[MyGame.Example.NestedStruct.NestedStructT]]
self.e = 0 # type: int
self.f = None # type: Optional[List[int]]
def __init__(
self,
a = 0.0,
b = None,
c = 0,
d = None,
e = 0,
f = None,
):
self.a = a # type: float
self.b = b # type: Optional[List[int]]
self.c = c # type: int
self.d = d # type: Optional[List[MyGame.Example.NestedStruct.NestedStructT]]
self.e = e # type: int
self.f = f # type: Optional[List[int]]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -35,6 +35,15 @@ class ArrayStructT(object):
d: typing.List[NestedStructT]
e: int
f: typing.List[int]
def __init__(
self,
a: float = ...,
b: typing.List[int] | None = ...,
c: int = ...,
d: typing.List['NestedStructT'] | None = ...,
e: int = ...,
f: typing.List[int] | None = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> ArrayStructT: ...
@classmethod

View File

@@ -68,8 +68,11 @@ except:
class ArrayTableT(object):
# ArrayTableT
def __init__(self):
self.a = None # type: Optional[MyGame.Example.ArrayStruct.ArrayStructT]
def __init__(
self,
a = None,
):
self.a = a # type: Optional[MyGame.Example.ArrayStruct.ArrayStructT]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -19,6 +19,10 @@ class ArrayTable(object):
def A(self) -> ArrayStruct | None: ...
class ArrayTableT(object):
a: ArrayStructT | None
def __init__(
self,
a: 'ArrayStructT' | None = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> ArrayTableT: ...
@classmethod

View File

@@ -1403,68 +1403,131 @@ except:
class MonsterT(object):
# MonsterT
def __init__(self):
self.pos = None # type: Optional[MyGame.Example.Vec3.Vec3T]
self.mana = 150 # type: int
self.hp = 100 # type: int
self.name = None # type: Optional[str]
self.inventory = None # type: Optional[List[int]]
self.color = 8 # type: int
self.testType = 0 # type: int
self.test = None # type: Union[None, MyGame.Example.Monster.MonsterT, MyGame.Example.TestSimpleTableWithEnum.TestSimpleTableWithEnumT, MyGame.Example2.Monster.MonsterT]
self.test4 = None # type: Optional[List[MyGame.Example.Test.TestT]]
self.testarrayofstring = None # type: Optional[List[Optional[str]]]
self.testarrayoftables = None # type: Optional[List[MyGame.Example.Monster.MonsterT]]
self.enemy = None # type: Optional[MyGame.Example.Monster.MonsterT]
self.testnestedflatbuffer = None # type: Optional[List[int]]
self.testempty = None # type: Optional[MyGame.Example.Stat.StatT]
self.testbool = False # type: bool
self.testhashs32Fnv1 = 0 # type: int
self.testhashu32Fnv1 = 0 # type: int
self.testhashs64Fnv1 = 0 # type: int
self.testhashu64Fnv1 = 0 # type: int
self.testhashs32Fnv1a = 0 # type: int
self.testhashu32Fnv1a = 0 # type: int
self.testhashs64Fnv1a = 0 # type: int
self.testhashu64Fnv1a = 0 # type: int
self.testarrayofbools = None # type: Optional[List[bool]]
self.testf = 3.14159 # type: float
self.testf2 = 3.0 # type: float
self.testf3 = 0.0 # type: float
self.testarrayofstring2 = None # type: Optional[List[Optional[str]]]
self.testarrayofsortedstruct = None # type: Optional[List[MyGame.Example.Ability.AbilityT]]
self.flex = None # type: Optional[List[int]]
self.test5 = None # type: Optional[List[MyGame.Example.Test.TestT]]
self.vectorOfLongs = None # type: Optional[List[int]]
self.vectorOfDoubles = None # type: Optional[List[float]]
self.parentNamespaceTest = None # type: Optional[MyGame.InParentNamespace.InParentNamespaceT]
self.vectorOfReferrables = None # type: Optional[List[MyGame.Example.Referrable.ReferrableT]]
self.singleWeakReference = 0 # type: int
self.vectorOfWeakReferences = None # type: Optional[List[int]]
self.vectorOfStrongReferrables = None # type: Optional[List[MyGame.Example.Referrable.ReferrableT]]
self.coOwningReference = 0 # type: int
self.vectorOfCoOwningReferences = None # type: Optional[List[int]]
self.nonOwningReference = 0 # type: int
self.vectorOfNonOwningReferences = None # type: Optional[List[int]]
self.anyUniqueType = 0 # type: int
self.anyUnique = None # type: Union[None, MyGame.Example.Monster.MonsterT, MyGame.Example.TestSimpleTableWithEnum.TestSimpleTableWithEnumT, MyGame.Example2.Monster.MonsterT]
self.anyAmbiguousType = 0 # type: int
self.anyAmbiguous = None # type: Union[None, MyGame.Example.Monster.MonsterT, MyGame.Example.Monster.MonsterT, MyGame.Example.Monster.MonsterT]
self.vectorOfEnums = None # type: Optional[List[int]]
self.signedEnum = -1 # type: int
self.testrequirednestedflatbuffer = None # type: Optional[List[int]]
self.scalarKeySortedTables = None # type: Optional[List[MyGame.Example.Stat.StatT]]
self.nativeInline = None # type: Optional[MyGame.Example.Test.TestT]
self.longEnumNonEnumDefault = 0 # type: int
self.longEnumNormalDefault = 2 # type: int
self.nanDefault = float('nan') # type: float
self.infDefault = float('inf') # type: float
self.positiveInfDefault = float('inf') # type: float
self.infinityDefault = float('inf') # type: float
self.positiveInfinityDefault = float('inf') # type: float
self.negativeInfDefault = float('-inf') # type: float
self.negativeInfinityDefault = float('-inf') # type: float
self.doubleInfDefault = float('inf') # type: float
def __init__(
self,
pos = None,
mana = 150,
hp = 100,
name = None,
inventory = None,
color = 8,
testType = 0,
test = None,
test4 = None,
testarrayofstring = None,
testarrayoftables = None,
enemy = None,
testnestedflatbuffer = None,
testempty = None,
testbool = False,
testhashs32Fnv1 = 0,
testhashu32Fnv1 = 0,
testhashs64Fnv1 = 0,
testhashu64Fnv1 = 0,
testhashs32Fnv1a = 0,
testhashu32Fnv1a = 0,
testhashs64Fnv1a = 0,
testhashu64Fnv1a = 0,
testarrayofbools = None,
testf = 3.14159,
testf2 = 3.0,
testf3 = 0.0,
testarrayofstring2 = None,
testarrayofsortedstruct = None,
flex = None,
test5 = None,
vectorOfLongs = None,
vectorOfDoubles = None,
parentNamespaceTest = None,
vectorOfReferrables = None,
singleWeakReference = 0,
vectorOfWeakReferences = None,
vectorOfStrongReferrables = None,
coOwningReference = 0,
vectorOfCoOwningReferences = None,
nonOwningReference = 0,
vectorOfNonOwningReferences = None,
anyUniqueType = 0,
anyUnique = None,
anyAmbiguousType = 0,
anyAmbiguous = None,
vectorOfEnums = None,
signedEnum = -1,
testrequirednestedflatbuffer = None,
scalarKeySortedTables = None,
nativeInline = None,
longEnumNonEnumDefault = 0,
longEnumNormalDefault = 2,
nanDefault = float('nan'),
infDefault = float('inf'),
positiveInfDefault = float('inf'),
infinityDefault = float('inf'),
positiveInfinityDefault = float('inf'),
negativeInfDefault = float('-inf'),
negativeInfinityDefault = float('-inf'),
doubleInfDefault = float('inf'),
):
self.pos = pos # type: Optional[MyGame.Example.Vec3.Vec3T]
self.mana = mana # type: int
self.hp = hp # type: int
self.name = name # type: Optional[str]
self.inventory = inventory # type: Optional[List[int]]
self.color = color # type: int
self.testType = testType # type: int
self.test = test # type: Union[None, 'MyGame.Example.Monster.MonsterT', 'MyGame.Example.TestSimpleTableWithEnum.TestSimpleTableWithEnumT', 'MyGame.Example2.Monster.MonsterT']
self.test4 = test4 # type: Optional[List[MyGame.Example.Test.TestT]]
self.testarrayofstring = testarrayofstring # type: Optional[List[Optional[str]]]
self.testarrayoftables = testarrayoftables # type: Optional[List[MyGame.Example.Monster.MonsterT]]
self.enemy = enemy # type: Optional[MyGame.Example.Monster.MonsterT]
self.testnestedflatbuffer = testnestedflatbuffer # type: Optional[List[int]]
self.testempty = testempty # type: Optional[MyGame.Example.Stat.StatT]
self.testbool = testbool # type: bool
self.testhashs32Fnv1 = testhashs32Fnv1 # type: int
self.testhashu32Fnv1 = testhashu32Fnv1 # type: int
self.testhashs64Fnv1 = testhashs64Fnv1 # type: int
self.testhashu64Fnv1 = testhashu64Fnv1 # type: int
self.testhashs32Fnv1a = testhashs32Fnv1a # type: int
self.testhashu32Fnv1a = testhashu32Fnv1a # type: int
self.testhashs64Fnv1a = testhashs64Fnv1a # type: int
self.testhashu64Fnv1a = testhashu64Fnv1a # type: int
self.testarrayofbools = testarrayofbools # type: Optional[List[bool]]
self.testf = testf # type: float
self.testf2 = testf2 # type: float
self.testf3 = testf3 # type: float
self.testarrayofstring2 = testarrayofstring2 # type: Optional[List[Optional[str]]]
self.testarrayofsortedstruct = testarrayofsortedstruct # type: Optional[List[MyGame.Example.Ability.AbilityT]]
self.flex = flex # type: Optional[List[int]]
self.test5 = test5 # type: Optional[List[MyGame.Example.Test.TestT]]
self.vectorOfLongs = vectorOfLongs # type: Optional[List[int]]
self.vectorOfDoubles = vectorOfDoubles # type: Optional[List[float]]
self.parentNamespaceTest = parentNamespaceTest # type: Optional[MyGame.InParentNamespace.InParentNamespaceT]
self.vectorOfReferrables = vectorOfReferrables # type: Optional[List[MyGame.Example.Referrable.ReferrableT]]
self.singleWeakReference = singleWeakReference # type: int
self.vectorOfWeakReferences = vectorOfWeakReferences # type: Optional[List[int]]
self.vectorOfStrongReferrables = vectorOfStrongReferrables # type: Optional[List[MyGame.Example.Referrable.ReferrableT]]
self.coOwningReference = coOwningReference # type: int
self.vectorOfCoOwningReferences = vectorOfCoOwningReferences # type: Optional[List[int]]
self.nonOwningReference = nonOwningReference # type: int
self.vectorOfNonOwningReferences = vectorOfNonOwningReferences # type: Optional[List[int]]
self.anyUniqueType = anyUniqueType # type: int
self.anyUnique = anyUnique # type: Union[None, 'MyGame.Example.Monster.MonsterT', 'MyGame.Example.TestSimpleTableWithEnum.TestSimpleTableWithEnumT', 'MyGame.Example2.Monster.MonsterT']
self.anyAmbiguousType = anyAmbiguousType # type: int
self.anyAmbiguous = anyAmbiguous # type: Union[None, 'MyGame.Example.Monster.MonsterT', 'MyGame.Example.Monster.MonsterT', 'MyGame.Example.Monster.MonsterT']
self.vectorOfEnums = vectorOfEnums # type: Optional[List[int]]
self.signedEnum = signedEnum # type: int
self.testrequirednestedflatbuffer = testrequirednestedflatbuffer # type: Optional[List[int]]
self.scalarKeySortedTables = scalarKeySortedTables # type: Optional[List[MyGame.Example.Stat.StatT]]
self.nativeInline = nativeInline # type: Optional[MyGame.Example.Test.TestT]
self.longEnumNonEnumDefault = longEnumNonEnumDefault # type: int
self.longEnumNormalDefault = longEnumNormalDefault # type: int
self.nanDefault = nanDefault # type: float
self.infDefault = infDefault # type: float
self.positiveInfDefault = positiveInfDefault # type: float
self.infinityDefault = infinityDefault # type: float
self.positiveInfinityDefault = positiveInfinityDefault # type: float
self.negativeInfDefault = negativeInfDefault # type: float
self.negativeInfinityDefault = negativeInfinityDefault # type: float
self.doubleInfDefault = doubleInfDefault # type: float
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -104,11 +104,17 @@ except:
class NestedStructT(object):
# NestedStructT
def __init__(self):
self.a = None # type: Optional[List[int]]
self.b = 0 # type: int
self.c = None # type: Optional[List[int]]
self.d = None # type: Optional[List[int]]
def __init__(
self,
a = None,
b = 0,
c = None,
d = None,
):
self.a = a # type: Optional[List[int]]
self.b = b # type: int
self.c = c # type: Optional[List[int]]
self.d = d # type: Optional[List[int]]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -31,6 +31,13 @@ class NestedStructT(object):
b: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]
c: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]]
d: typing.List[int]
def __init__(
self,
a: typing.List[int] | None = ...,
b: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C] = ...,
c: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]] | None = ...,
d: typing.List[int] | None = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> NestedStructT: ...
@classmethod

View File

@@ -104,11 +104,17 @@ except:
class NestedUnionTestT(object):
# NestedUnionTestT
def __init__(self):
self.name = None # type: Optional[str]
self.dataType = 0 # type: int
self.data = None # type: Union[None, MyGame.Example.NestedUnion.Vec3.Vec3T, MyGame.Example.NestedUnion.TestSimpleTableWithEnum.TestSimpleTableWithEnumT]
self.id = 0 # type: int
def __init__(
self,
name = None,
dataType = 0,
data = None,
id = 0,
):
self.name = name # type: Optional[str]
self.dataType = dataType # type: int
self.data = data # type: Union[None, 'MyGame.Example.NestedUnion.Vec3.Vec3T', 'MyGame.Example.NestedUnion.TestSimpleTableWithEnum.TestSimpleTableWithEnumT']
self.id = id # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -26,6 +26,13 @@ class NestedUnionTestT(object):
dataType: typing.Literal[Any.NONE, Any.Vec3, Any.TestSimpleTableWithEnum]
data: typing.Union[None, Vec3T, TestSimpleTableWithEnumT]
id: int
def __init__(
self,
name: str | None = ...,
dataType: typing.Literal[Any.NONE, Any.Vec3, Any.TestSimpleTableWithEnum] = ...,
data: typing.Union[None, Vec3T, TestSimpleTableWithEnumT] = ...,
id: int = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> NestedUnionTestT: ...
@classmethod

View File

@@ -34,9 +34,13 @@ def CreateTest(builder, a, b):
class TestT(object):
# TestT
def __init__(self):
self.a = 0 # type: int
self.b = 0 # type: int
def __init__(
self,
a = 0,
b = 0,
):
self.a = a # type: int
self.b = b # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -17,6 +17,11 @@ class Test(object):
class TestT(object):
a: int
b: int
def __init__(
self,
a: int = ...,
b: int = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> TestT: ...
@classmethod

View File

@@ -54,8 +54,11 @@ def End(builder: flatbuffers.Builder) -> int:
class TestSimpleTableWithEnumT(object):
# TestSimpleTableWithEnumT
def __init__(self):
self.color = 2 # type: int
def __init__(
self,
color = 2,
):
self.color = color # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -17,6 +17,10 @@ class TestSimpleTableWithEnum(object):
def Color(self) -> typing.Literal[Color.Red, Color.Green, Color.Blue]: ...
class TestSimpleTableWithEnumT(object):
color: typing.Literal[Color.Red, Color.Green, Color.Blue]
def __init__(
self,
color: typing.Literal[Color.Red, Color.Green, Color.Blue] = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> TestSimpleTableWithEnumT: ...
@classmethod

View File

@@ -129,13 +129,21 @@ except:
class Vec3T(object):
# Vec3T
def __init__(self):
self.x = 0.0 # type: float
self.y = 0.0 # type: float
self.z = 0.0 # type: float
self.test1 = 0.0 # type: float
self.test2 = 0 # type: int
self.test3 = None # type: Optional[MyGame.Example.NestedUnion.Test.TestT]
def __init__(
self,
x = 0.0,
y = 0.0,
z = 0.0,
test1 = 0.0,
test2 = 0,
test3 = None,
):
self.x = x # type: float
self.y = y # type: float
self.z = z # type: float
self.test1 = test1 # type: float
self.test2 = test2 # type: int
self.test3 = test3 # type: Optional[MyGame.Example.NestedUnion.Test.TestT]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -28,6 +28,15 @@ class Vec3T(object):
test1: float
test2: typing.Literal[Color.Red, Color.Green, Color.Blue]
test3: TestT | None
def __init__(
self,
x: float = ...,
y: float = ...,
z: float = ...,
test1: float = ...,
test2: typing.Literal[Color.Red, Color.Green, Color.Blue] = ...,
test3: 'TestT' | None = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> Vec3T: ...
@classmethod

View File

@@ -57,8 +57,11 @@ def End(builder):
class ReferrableT(object):
# ReferrableT
def __init__(self):
self.id = 0 # type: int
def __init__(
self,
id = 0,
):
self.id = id # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -83,10 +83,15 @@ def End(builder):
class StatT(object):
# StatT
def __init__(self):
self.id = None # type: Optional[str]
self.val = 0 # type: int
self.count = 0 # type: int
def __init__(
self,
id = None,
val = 0,
count = 0,
):
self.id = id # type: Optional[str]
self.val = val # type: int
self.count = count # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -57,10 +57,15 @@ except:
class StructOfStructsT(object):
# StructOfStructsT
def __init__(self):
self.a = None # type: Optional[MyGame.Example.Ability.AbilityT]
self.b = None # type: Optional[MyGame.Example.Test.TestT]
self.c = None # type: Optional[MyGame.Example.Ability.AbilityT]
def __init__(
self,
a = None,
b = None,
c = None,
):
self.a = a # type: Optional[MyGame.Example.Ability.AbilityT]
self.b = b # type: Optional[MyGame.Example.Test.TestT]
self.c = c # type: Optional[MyGame.Example.Ability.AbilityT]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -47,8 +47,11 @@ except:
class StructOfStructsOfStructsT(object):
# StructOfStructsOfStructsT
def __init__(self):
self.a = None # type: Optional[MyGame.Example.StructOfStructs.StructOfStructsT]
def __init__(
self,
a = None,
):
self.a = a # type: Optional[MyGame.Example.StructOfStructs.StructOfStructsT]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -33,9 +33,13 @@ def CreateTest(builder, a, b):
class TestT(object):
# TestT
def __init__(self):
self.a = 0 # type: int
self.b = 0 # type: int
def __init__(
self,
a = 0,
b = 0,
):
self.a = a # type: int
self.b = b # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -57,8 +57,11 @@ def End(builder):
class TestSimpleTableWithEnumT(object):
# TestSimpleTableWithEnumT
def __init__(self):
self.color = 2 # type: int
def __init__(
self,
color = 2,
):
self.color = color # type: int
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -256,19 +256,33 @@ except:
class TypeAliasesT(object):
# TypeAliasesT
def __init__(self):
self.i8 = 0 # type: int
self.u8 = 0 # type: int
self.i16 = 0 # type: int
self.u16 = 0 # type: int
self.i32 = 0 # type: int
self.u32 = 0 # type: int
self.i64 = 0 # type: int
self.u64 = 0 # type: int
self.f32 = 0.0 # type: float
self.f64 = 0.0 # type: float
self.v8 = None # type: Optional[List[int]]
self.vf64 = None # type: Optional[List[float]]
def __init__(
self,
i8 = 0,
u8 = 0,
i16 = 0,
u16 = 0,
i32 = 0,
u32 = 0,
i64 = 0,
u64 = 0,
f32 = 0.0,
f64 = 0.0,
v8 = None,
vf64 = None,
):
self.i8 = i8 # type: int
self.u8 = u8 # type: int
self.i16 = i16 # type: int
self.u16 = u16 # type: int
self.i32 = i32 # type: int
self.u32 = u32 # type: int
self.i64 = i64 # type: int
self.u64 = u64 # type: int
self.f32 = f32 # type: float
self.f64 = f64 # type: float
self.v8 = v8 # type: Optional[List[int]]
self.vf64 = vf64 # type: Optional[List[float]]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -58,13 +58,21 @@ except:
class Vec3T(object):
# Vec3T
def __init__(self):
self.x = 0.0 # type: float
self.y = 0.0 # type: float
self.z = 0.0 # type: float
self.test1 = 0.0 # type: float
self.test2 = 0 # type: int
self.test3 = None # type: Optional[MyGame.Example.Test.TestT]
def __init__(
self,
x = 0.0,
y = 0.0,
z = 0.0,
test1 = 0.0,
test2 = 0,
test3 = None,
):
self.x = x # type: float
self.y = y # type: float
self.z = z # type: float
self.test1 = test1 # type: float
self.test2 = test2 # type: int
self.test3 = test3 # type: Optional[MyGame.Example.Test.TestT]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -44,7 +44,9 @@ def End(builder):
class MonsterT(object):
# MonsterT
def __init__(self):
def __init__(
self,
):
pass
@classmethod

View File

@@ -44,7 +44,9 @@ def End(builder):
class InParentNamespaceT(object):
# InParentNamespaceT
def __init__(self):
def __init__(
self,
):
pass
@classmethod

View File

@@ -231,17 +231,29 @@ except:
class MonsterExtraT(object):
# MonsterExtraT
def __init__(self):
self.d0 = float('nan') # type: float
self.d1 = float('nan') # type: float
self.d2 = float('inf') # type: float
self.d3 = float('-inf') # type: float
self.f0 = float('nan') # type: float
self.f1 = float('nan') # type: float
self.f2 = float('inf') # type: float
self.f3 = float('-inf') # type: float
self.dvec = None # type: Optional[List[float]]
self.fvec = None # type: Optional[List[float]]
def __init__(
self,
d0 = float('nan'),
d1 = float('nan'),
d2 = float('inf'),
d3 = float('-inf'),
f0 = float('nan'),
f1 = float('nan'),
f2 = float('inf'),
f3 = float('-inf'),
dvec = None,
fvec = None,
):
self.d0 = d0 # type: float
self.d1 = d1 # type: float
self.d2 = d2 # type: float
self.d3 = d3 # type: float
self.f0 = f0 # type: float
self.f1 = f1 # type: float
self.f2 = f2 # type: float
self.f3 = f3 # type: float
self.dvec = dvec # type: Optional[List[float]]
self.fvec = fvec # type: Optional[List[float]]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -42,6 +42,19 @@ class MonsterExtraT(object):
f3: float
dvec: typing.List[float]
fvec: typing.List[float]
def __init__(
self,
d0: float = ...,
d1: float = ...,
d2: float = ...,
d3: float = ...,
f0: float = ...,
f1: float = ...,
f2: float = ...,
f3: float = ...,
dvec: typing.List[float] | None = ...,
fvec: typing.List[float] | None = ...,
) -> None: ...
@classmethod
def InitFromBuf(cls, buf: bytes, pos: int) -> MonsterExtraT: ...
@classmethod

View File

@@ -119,7 +119,9 @@ def InParentNamespaceEnd(builder):
class InParentNamespaceT(object):
# InParentNamespaceT
def __init__(self):
def __init__(
self,
):
pass
@classmethod
@@ -184,7 +186,9 @@ def MonsterEnd(builder):
class MonsterT(object):
# MonsterT
def __init__(self):
def __init__(
self,
):
pass
@classmethod
@@ -243,9 +247,13 @@ def CreateTest(builder, a, b):
class TestT(object):
# TestT
def __init__(self):
self.a = 0 # type: int
self.b = 0 # type: int
def __init__(
self,
a = 0,
b = 0,
):
self.a = a # type: int
self.b = b # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -319,8 +327,11 @@ def TestSimpleTableWithEnumEnd(builder):
class TestSimpleTableWithEnumT(object):
# TestSimpleTableWithEnumT
def __init__(self):
self.color = 2 # type: int
def __init__(
self,
color = 2,
):
self.color = color # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -404,13 +415,21 @@ except:
class Vec3T(object):
# Vec3T
def __init__(self):
self.x = 0.0 # type: float
self.y = 0.0 # type: float
self.z = 0.0 # type: float
self.test1 = 0.0 # type: float
self.test2 = 0 # type: int
self.test3 = None # type: Optional[TestT]
def __init__(
self,
x = 0.0,
y = 0.0,
z = 0.0,
test1 = 0.0,
test2 = 0,
test3 = None,
):
self.x = x # type: float
self.y = y # type: float
self.z = z # type: float
self.test1 = test1 # type: float
self.test2 = test2 # type: int
self.test3 = test3 # type: Optional[TestT]
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -472,9 +491,13 @@ def CreateAbility(builder, id, distance):
class AbilityT(object):
# AbilityT
def __init__(self):
self.id = 0 # type: int
self.distance = 0 # type: int
def __init__(
self,
id = 0,
distance = 0,
):
self.id = id # type: int
self.distance = distance # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -554,10 +577,15 @@ except:
class StructOfStructsT(object):
# StructOfStructsT
def __init__(self):
self.a = None # type: Optional[AbilityT]
self.b = None # type: Optional[TestT]
self.c = None # type: Optional[AbilityT]
def __init__(
self,
a = None,
b = None,
c = None,
):
self.a = a # type: Optional[AbilityT]
self.b = b # type: Optional[TestT]
self.c = c # type: Optional[AbilityT]
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -632,8 +660,11 @@ except:
class StructOfStructsOfStructsT(object):
# StructOfStructsOfStructsT
def __init__(self):
self.a = None # type: Optional[StructOfStructsT]
def __init__(
self,
a = None,
):
self.a = a # type: Optional[StructOfStructsT]
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -727,10 +758,15 @@ def StatEnd(builder):
class StatT(object):
# StatT
def __init__(self):
self.id = None # type: Optional[str]
self.val = 0 # type: int
self.count = 0 # type: int
def __init__(
self,
id = None,
val = 0,
count = 0,
):
self.id = id # type: Optional[str]
self.val = val # type: int
self.count = count # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -813,8 +849,11 @@ def ReferrableEnd(builder):
class ReferrableT(object):
# ReferrableT
def __init__(self):
self.id = 0 # type: int
def __init__(
self,
id = 0,
):
self.id = id # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -1969,68 +2008,131 @@ except:
class MonsterT(object):
# MonsterT
def __init__(self):
self.pos = None # type: Optional[Vec3T]
self.mana = 150 # type: int
self.hp = 100 # type: int
self.name = None # type: Optional[str]
self.inventory = None # type: Optional[List[int]]
self.color = 8 # type: int
self.testType = 0 # type: int
self.test = None # type: Union[None, MonsterT, TestSimpleTableWithEnumT, MonsterT]
self.test4 = None # type: Optional[List[TestT]]
self.testarrayofstring = None # type: Optional[List[Optional[str]]]
self.testarrayoftables = None # type: Optional[List[MonsterT]]
self.enemy = None # type: Optional[MonsterT]
self.testnestedflatbuffer = None # type: Optional[List[int]]
self.testempty = None # type: Optional[StatT]
self.testbool = False # type: bool
self.testhashs32Fnv1 = 0 # type: int
self.testhashu32Fnv1 = 0 # type: int
self.testhashs64Fnv1 = 0 # type: int
self.testhashu64Fnv1 = 0 # type: int
self.testhashs32Fnv1a = 0 # type: int
self.testhashu32Fnv1a = 0 # type: int
self.testhashs64Fnv1a = 0 # type: int
self.testhashu64Fnv1a = 0 # type: int
self.testarrayofbools = None # type: Optional[List[bool]]
self.testf = 3.14159 # type: float
self.testf2 = 3.0 # type: float
self.testf3 = 0.0 # type: float
self.testarrayofstring2 = None # type: Optional[List[Optional[str]]]
self.testarrayofsortedstruct = None # type: Optional[List[AbilityT]]
self.flex = None # type: Optional[List[int]]
self.test5 = None # type: Optional[List[TestT]]
self.vectorOfLongs = None # type: Optional[List[int]]
self.vectorOfDoubles = None # type: Optional[List[float]]
self.parentNamespaceTest = None # type: Optional[InParentNamespaceT]
self.vectorOfReferrables = None # type: Optional[List[ReferrableT]]
self.singleWeakReference = 0 # type: int
self.vectorOfWeakReferences = None # type: Optional[List[int]]
self.vectorOfStrongReferrables = None # type: Optional[List[ReferrableT]]
self.coOwningReference = 0 # type: int
self.vectorOfCoOwningReferences = None # type: Optional[List[int]]
self.nonOwningReference = 0 # type: int
self.vectorOfNonOwningReferences = None # type: Optional[List[int]]
self.anyUniqueType = 0 # type: int
self.anyUnique = None # type: Union[None, MonsterT, TestSimpleTableWithEnumT, MonsterT]
self.anyAmbiguousType = 0 # type: int
self.anyAmbiguous = None # type: Union[None, MonsterT, MonsterT, MonsterT]
self.vectorOfEnums = None # type: Optional[List[int]]
self.signedEnum = -1 # type: int
self.testrequirednestedflatbuffer = None # type: Optional[List[int]]
self.scalarKeySortedTables = None # type: Optional[List[StatT]]
self.nativeInline = None # type: Optional[TestT]
self.longEnumNonEnumDefault = 0 # type: int
self.longEnumNormalDefault = 2 # type: int
self.nanDefault = float('nan') # type: float
self.infDefault = float('inf') # type: float
self.positiveInfDefault = float('inf') # type: float
self.infinityDefault = float('inf') # type: float
self.positiveInfinityDefault = float('inf') # type: float
self.negativeInfDefault = float('-inf') # type: float
self.negativeInfinityDefault = float('-inf') # type: float
self.doubleInfDefault = float('inf') # type: float
def __init__(
self,
pos = None,
mana = 150,
hp = 100,
name = None,
inventory = None,
color = 8,
testType = 0,
test = None,
test4 = None,
testarrayofstring = None,
testarrayoftables = None,
enemy = None,
testnestedflatbuffer = None,
testempty = None,
testbool = False,
testhashs32Fnv1 = 0,
testhashu32Fnv1 = 0,
testhashs64Fnv1 = 0,
testhashu64Fnv1 = 0,
testhashs32Fnv1a = 0,
testhashu32Fnv1a = 0,
testhashs64Fnv1a = 0,
testhashu64Fnv1a = 0,
testarrayofbools = None,
testf = 3.14159,
testf2 = 3.0,
testf3 = 0.0,
testarrayofstring2 = None,
testarrayofsortedstruct = None,
flex = None,
test5 = None,
vectorOfLongs = None,
vectorOfDoubles = None,
parentNamespaceTest = None,
vectorOfReferrables = None,
singleWeakReference = 0,
vectorOfWeakReferences = None,
vectorOfStrongReferrables = None,
coOwningReference = 0,
vectorOfCoOwningReferences = None,
nonOwningReference = 0,
vectorOfNonOwningReferences = None,
anyUniqueType = 0,
anyUnique = None,
anyAmbiguousType = 0,
anyAmbiguous = None,
vectorOfEnums = None,
signedEnum = -1,
testrequirednestedflatbuffer = None,
scalarKeySortedTables = None,
nativeInline = None,
longEnumNonEnumDefault = 0,
longEnumNormalDefault = 2,
nanDefault = float('nan'),
infDefault = float('inf'),
positiveInfDefault = float('inf'),
infinityDefault = float('inf'),
positiveInfinityDefault = float('inf'),
negativeInfDefault = float('-inf'),
negativeInfinityDefault = float('-inf'),
doubleInfDefault = float('inf'),
):
self.pos = pos # type: Optional[Vec3T]
self.mana = mana # type: int
self.hp = hp # type: int
self.name = name # type: Optional[str]
self.inventory = inventory # type: Optional[List[int]]
self.color = color # type: int
self.testType = testType # type: int
self.test = test # type: Union[None, 'MonsterT', 'TestSimpleTableWithEnumT', 'MonsterT']
self.test4 = test4 # type: Optional[List[TestT]]
self.testarrayofstring = testarrayofstring # type: Optional[List[Optional[str]]]
self.testarrayoftables = testarrayoftables # type: Optional[List[MonsterT]]
self.enemy = enemy # type: Optional[MonsterT]
self.testnestedflatbuffer = testnestedflatbuffer # type: Optional[List[int]]
self.testempty = testempty # type: Optional[StatT]
self.testbool = testbool # type: bool
self.testhashs32Fnv1 = testhashs32Fnv1 # type: int
self.testhashu32Fnv1 = testhashu32Fnv1 # type: int
self.testhashs64Fnv1 = testhashs64Fnv1 # type: int
self.testhashu64Fnv1 = testhashu64Fnv1 # type: int
self.testhashs32Fnv1a = testhashs32Fnv1a # type: int
self.testhashu32Fnv1a = testhashu32Fnv1a # type: int
self.testhashs64Fnv1a = testhashs64Fnv1a # type: int
self.testhashu64Fnv1a = testhashu64Fnv1a # type: int
self.testarrayofbools = testarrayofbools # type: Optional[List[bool]]
self.testf = testf # type: float
self.testf2 = testf2 # type: float
self.testf3 = testf3 # type: float
self.testarrayofstring2 = testarrayofstring2 # type: Optional[List[Optional[str]]]
self.testarrayofsortedstruct = testarrayofsortedstruct # type: Optional[List[AbilityT]]
self.flex = flex # type: Optional[List[int]]
self.test5 = test5 # type: Optional[List[TestT]]
self.vectorOfLongs = vectorOfLongs # type: Optional[List[int]]
self.vectorOfDoubles = vectorOfDoubles # type: Optional[List[float]]
self.parentNamespaceTest = parentNamespaceTest # type: Optional[InParentNamespaceT]
self.vectorOfReferrables = vectorOfReferrables # type: Optional[List[ReferrableT]]
self.singleWeakReference = singleWeakReference # type: int
self.vectorOfWeakReferences = vectorOfWeakReferences # type: Optional[List[int]]
self.vectorOfStrongReferrables = vectorOfStrongReferrables # type: Optional[List[ReferrableT]]
self.coOwningReference = coOwningReference # type: int
self.vectorOfCoOwningReferences = vectorOfCoOwningReferences # type: Optional[List[int]]
self.nonOwningReference = nonOwningReference # type: int
self.vectorOfNonOwningReferences = vectorOfNonOwningReferences # type: Optional[List[int]]
self.anyUniqueType = anyUniqueType # type: int
self.anyUnique = anyUnique # type: Union[None, 'MonsterT', 'TestSimpleTableWithEnumT', 'MonsterT']
self.anyAmbiguousType = anyAmbiguousType # type: int
self.anyAmbiguous = anyAmbiguous # type: Union[None, 'MonsterT', 'MonsterT', 'MonsterT']
self.vectorOfEnums = vectorOfEnums # type: Optional[List[int]]
self.signedEnum = signedEnum # type: int
self.testrequirednestedflatbuffer = testrequirednestedflatbuffer # type: Optional[List[int]]
self.scalarKeySortedTables = scalarKeySortedTables # type: Optional[List[StatT]]
self.nativeInline = nativeInline # type: Optional[TestT]
self.longEnumNonEnumDefault = longEnumNonEnumDefault # type: int
self.longEnumNormalDefault = longEnumNormalDefault # type: int
self.nanDefault = nanDefault # type: float
self.infDefault = infDefault # type: float
self.positiveInfDefault = positiveInfDefault # type: float
self.infinityDefault = infinityDefault # type: float
self.positiveInfinityDefault = positiveInfinityDefault # type: float
self.negativeInfDefault = negativeInfDefault # type: float
self.negativeInfinityDefault = negativeInfinityDefault # type: float
self.doubleInfDefault = doubleInfDefault # type: float
@classmethod
def InitFromBuf(cls, buf, pos):
@@ -2708,19 +2810,33 @@ except:
class TypeAliasesT(object):
# TypeAliasesT
def __init__(self):
self.i8 = 0 # type: int
self.u8 = 0 # type: int
self.i16 = 0 # type: int
self.u16 = 0 # type: int
self.i32 = 0 # type: int
self.u32 = 0 # type: int
self.i64 = 0 # type: int
self.u64 = 0 # type: int
self.f32 = 0.0 # type: float
self.f64 = 0.0 # type: float
self.v8 = None # type: Optional[List[int]]
self.vf64 = None # type: Optional[List[float]]
def __init__(
self,
i8 = 0,
u8 = 0,
i16 = 0,
u16 = 0,
i32 = 0,
u32 = 0,
i64 = 0,
u64 = 0,
f32 = 0.0,
f64 = 0.0,
v8 = None,
vf64 = None,
):
self.i8 = i8 # type: int
self.u8 = u8 # type: int
self.i16 = i16 # type: int
self.u16 = u16 # type: int
self.i32 = i32 # type: int
self.u32 = u32 # type: int
self.i64 = i64 # type: int
self.u64 = u64 # type: int
self.f32 = f32 # type: float
self.f64 = f64 # type: float
self.v8 = v8 # type: Optional[List[int]]
self.vf64 = vf64 # type: Optional[List[float]]
@classmethod
def InitFromBuf(cls, buf, pos):

View File

@@ -508,47 +508,89 @@ def ScalarStuffEnd(builder):
def End(builder):
return ScalarStuffEnd(builder)
try:
from typing import Optional
except:
pass
class ScalarStuffT(object):
# ScalarStuffT
def __init__(self):
self.justI8 = 0 # type: int
self.maybeI8 = None # type: Optional[int]
self.defaultI8 = 42 # type: int
self.justU8 = 0 # type: int
self.maybeU8 = None # type: Optional[int]
self.defaultU8 = 42 # type: int
self.justI16 = 0 # type: int
self.maybeI16 = None # type: Optional[int]
self.defaultI16 = 42 # type: int
self.justU16 = 0 # type: int
self.maybeU16 = None # type: Optional[int]
self.defaultU16 = 42 # type: int
self.justI32 = 0 # type: int
self.maybeI32 = None # type: Optional[int]
self.defaultI32 = 42 # type: int
self.justU32 = 0 # type: int
self.maybeU32 = None # type: Optional[int]
self.defaultU32 = 42 # type: int
self.justI64 = 0 # type: int
self.maybeI64 = None # type: Optional[int]
self.defaultI64 = 42 # type: int
self.justU64 = 0 # type: int
self.maybeU64 = None # type: Optional[int]
self.defaultU64 = 42 # type: int
self.justF32 = 0.0 # type: float
self.maybeF32 = None # type: Optional[float]
self.defaultF32 = 42.0 # type: float
self.justF64 = 0.0 # type: float
self.maybeF64 = None # type: Optional[float]
self.defaultF64 = 42.0 # type: float
self.justBool = False # type: bool
self.maybeBool = None # type: Optional[bool]
self.defaultBool = True # type: bool
self.justEnum = 0 # type: int
self.maybeEnum = None # type: Optional[int]
self.defaultEnum = 1 # type: int
def __init__(
self,
justI8 = 0,
maybeI8 = None,
defaultI8 = 42,
justU8 = 0,
maybeU8 = None,
defaultU8 = 42,
justI16 = 0,
maybeI16 = None,
defaultI16 = 42,
justU16 = 0,
maybeU16 = None,
defaultU16 = 42,
justI32 = 0,
maybeI32 = None,
defaultI32 = 42,
justU32 = 0,
maybeU32 = None,
defaultU32 = 42,
justI64 = 0,
maybeI64 = None,
defaultI64 = 42,
justU64 = 0,
maybeU64 = None,
defaultU64 = 42,
justF32 = 0.0,
maybeF32 = None,
defaultF32 = 42.0,
justF64 = 0.0,
maybeF64 = None,
defaultF64 = 42.0,
justBool = False,
maybeBool = None,
defaultBool = True,
justEnum = 0,
maybeEnum = None,
defaultEnum = 1,
):
self.justI8 = justI8 # type: int
self.maybeI8 = maybeI8 # type: Optional[int]
self.defaultI8 = defaultI8 # type: int
self.justU8 = justU8 # type: int
self.maybeU8 = maybeU8 # type: Optional[int]
self.defaultU8 = defaultU8 # type: int
self.justI16 = justI16 # type: int
self.maybeI16 = maybeI16 # type: Optional[int]
self.defaultI16 = defaultI16 # type: int
self.justU16 = justU16 # type: int
self.maybeU16 = maybeU16 # type: Optional[int]
self.defaultU16 = defaultU16 # type: int
self.justI32 = justI32 # type: int
self.maybeI32 = maybeI32 # type: Optional[int]
self.defaultI32 = defaultI32 # type: int
self.justU32 = justU32 # type: int
self.maybeU32 = maybeU32 # type: Optional[int]
self.defaultU32 = defaultU32 # type: int
self.justI64 = justI64 # type: int
self.maybeI64 = maybeI64 # type: Optional[int]
self.defaultI64 = defaultI64 # type: int
self.justU64 = justU64 # type: int
self.maybeU64 = maybeU64 # type: Optional[int]
self.defaultU64 = defaultU64 # type: int
self.justF32 = justF32 # type: float
self.maybeF32 = maybeF32 # type: Optional[float]
self.defaultF32 = defaultF32 # type: float
self.justF64 = justF64 # type: float
self.maybeF64 = maybeF64 # type: Optional[float]
self.defaultF64 = defaultF64 # type: float
self.justBool = justBool # type: bool
self.maybeBool = maybeBool # type: Optional[bool]
self.defaultBool = defaultBool # type: bool
self.justEnum = justEnum # type: int
self.maybeEnum = maybeEnum # type: Optional[int]
self.defaultEnum = defaultEnum # type: int
@classmethod
def InitFromBuf(cls, buf, pos):