Given a very simple FlatBuffer definition:
table Foo {
bar: string;
baz: int64;
}
root_type Foo;
The generated type stubs (flatc --python --python-typing foo.fbs) include an incorrect alias to uoffset:
from __future__ import annotations
import flatbuffers
import numpy as np
import typing
uoffset: typing.TypeAlias = flatbuffers.number_types.UOffsetTFlags.py_type
- The corresponding
Foo.py file does not define an uoffset alias.
>>> from Foo import uoffset
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
from Foo import uoffset
ImportError: cannot import name 'uoffset' from 'Foo' (/.../Foo.py)
flatbuffers.number_types is not accessible with a simple import flatbuffers, as flatbuffers/__init__.py doesn't re-export number_types. An explicit import flatbuffers.number_types is needed.
- The stub adds an unconditional
import numpy as np, which breaks type checking when numpy is not installed.
Tested with Python 3.14.7, Pyright 1.1.411 and flatbuffers/flatc 25.12.19.
Given a very simple FlatBuffer definition:
The generated type stubs (
flatc --python --python-typing foo.fbs) include an incorrect alias touoffset:Foo.pyfile does not define anuoffsetalias.flatbuffers.number_typesis not accessible with a simpleimport flatbuffers, as flatbuffers/__init__.py doesn't re-exportnumber_types. An explicitimport flatbuffers.number_typesis needed.import numpy as np, which breaks type checking when numpy is not installed.Tested with Python 3.14.7, Pyright 1.1.411 and flatbuffers/flatc 25.12.19.