Skip to content

Commit f830c47

Browse files
authored
[Python] Avoid double flatbuffers include in pyi files (google#8626)
1 parent 501810f commit f830c47

File tree

12 files changed

+1
-11
lines changed

12 files changed

+1
-11
lines changed

src/idl_gen_python.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ class PythonStubGenerator {
587587
std::map<std::string, std::set<std::string>> names_by_module;
588588
for (const Import &import : imports.imports) {
589589
if (import.IsLocal()) continue; // skip all local imports
590+
if (import.module == "flatbuffers" && import.name == "") continue; // skip double include hardcoded flatbuffers
590591
if (import.name == "") {
591592
modules.insert(import.module);
592593
} else {

tests/MyGame/Example/ArrayStruct.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.NestedStruct import NestedStruct, NestedStructT
98
from MyGame.Example.TestEnum import TestEnum

tests/MyGame/Example/ArrayTable.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.ArrayStruct import ArrayStruct, ArrayStructT
98

tests/MyGame/Example/NestedStruct.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.TestEnum import TestEnum
98

tests/MyGame/Example/NestedUnion/Any.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.NestedUnion.TestSimpleTableWithEnum import TestSimpleTableWithEnum
98
from MyGame.Example.NestedUnion.Vec3 import Vec3

tests/MyGame/Example/NestedUnion/Color.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from typing import cast
98

tests/MyGame/Example/NestedUnion/NestedUnionTest.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.NestedUnion.Any import Any
98
from MyGame.Example.NestedUnion.TestSimpleTableWithEnum import TestSimpleTableWithEnumT

tests/MyGame/Example/NestedUnion/Test.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87

98
uoffset: typing.TypeAlias = flatbuffers.number_types.UOffsetTFlags.py_type

tests/MyGame/Example/NestedUnion/TestSimpleTableWithEnum.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.NestedUnion.Color import Color
98

tests/MyGame/Example/NestedUnion/Vec3.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from __future__ import annotations
33
import flatbuffers
44
import numpy as np
55

6-
import flatbuffers
76
import typing
87
from MyGame.Example.NestedUnion.Color import Color
98
from MyGame.Example.NestedUnion.Test import Test, TestT

0 commit comments

Comments
 (0)