diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/common/thrift_patch_callback.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/common/thrift_patch_callback.mustache index 318ef682440f55..64f63bbdabfe6e 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/common/thrift_patch_callback.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/common/thrift_patch_callback.mustache @@ -33,5 +33,5 @@ }}MapPatch({{> common/thrift_patch_callback}}, patch.as_map_patch(), type_info){{! }}{{/type:value_type}}{{/type:map?}}{{! }}{{#type:struct}}{{! - }}{{type:patch_module_path}}.{{struct:py_name}}Patch(patch){{! + }}{{#type:need_patch_module_path?}}{{type:patch_module_path}}.{{/type:need_patch_module_path?}}{{struct:py_name}}Patch(patch){{! }}{{/type:struct}} diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_patch.py.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_patch.py.mustache index 024e7f1dcb5832..278bf9f3eb9259 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_patch.py.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_patch.py.mustache @@ -16,6 +16,7 @@ }} # @{{!}}generated +from __future__ import annotations import typing import typing as _typing diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/unadapted_pep484_patch_type.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/unadapted_pep484_patch_type.mustache index 04188e02459505..6b75b88ccf6f2b 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/unadapted_pep484_patch_type.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/unadapted_pep484_patch_type.mustache @@ -27,7 +27,10 @@ This is for pep 484 typing for thrift patch types }}{{#type:float?}}FloatPatch{{/type:float?}}{{! }}{{#type:string?}}StringPatch{{/type:string?}}{{! }}{{#type:binary?}}BinaryPatch{{/type:binary?}}{{! -}}{{#type:struct}}{{struct:py_name}}Patch{{/type:struct}}{{! +}}{{#type:struct}}{{! + }}{{#type:need_patch_module_path?}}{{type:patch_module_path}}.{{/type:need_patch_module_path?}}{{! + }}{{struct:py_name}}Patch{{! +}}{{/type:struct}}{{! }}{{#type:list?}}ListPatch[{{! }}{{#type:list_elem_type}}{{> types/unadapted_pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_patch/gen-python-patch/test/fixtures/basic/module/thrift_patch.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_patch/gen-python-patch/test/fixtures/basic/module/thrift_patch.py index e79f0228caf744..2701763cbe825e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_patch/gen-python-patch/test/fixtures/basic/module/thrift_patch.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_patch/gen-python-patch/test/fixtures/basic/module/thrift_patch.py @@ -1,4 +1,5 @@ # @generated +from __future__ import annotations import typing import typing as _typing @@ -59,7 +60,7 @@ def MyDataField(self) -> OptionalFieldPatch[ MyDataItemPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyDataItemPatch(patch), + lambda patch, type_info: MyDataItemPatch(patch), self._patch, 3, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyDataItem)) @@ -181,7 +182,7 @@ def myStruct(self) -> OptionalFieldPatch[ MyStructPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyStructPatch(patch), + lambda patch, type_info: MyStructPatch(patch), self._patch, 2, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyStruct)) @@ -191,7 +192,7 @@ def myDataItem(self) -> OptionalFieldPatch[ MyDataItemPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyDataItemPatch(patch), + lambda patch, type_info: MyDataItemPatch(patch), self._patch, 3, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyDataItem)) @@ -235,7 +236,7 @@ def myStruct(self) -> OptionalFieldPatch[ MyStructPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyStructPatch(patch), + lambda patch, type_info: MyStructPatch(patch), self._patch, 3, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyStruct)) @@ -245,7 +246,7 @@ def myUnion(self) -> OptionalFieldPatch[ MyUnionPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyUnionPatch(patch), + lambda patch, type_info: MyUnionPatch(patch), self._patch, 4, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyUnion)) @@ -279,7 +280,7 @@ def myStruct(self) -> OptionalFieldPatch[ MyStructPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyStructPatch(patch), + lambda patch, type_info: MyStructPatch(patch), self._patch, 3, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyStruct)) @@ -289,7 +290,7 @@ def myUnion(self) -> OptionalFieldPatch[ MyUnionPatch]: return OptionalFieldPatch( - lambda patch, type_info: test.fixtures.basic.module.thrift_patch.MyUnionPatch(patch), + lambda patch, type_info: MyUnionPatch(patch), self._patch, 4, _fbthrift_python_types.StructTypeInfo(test.fixtures.basic.module.thrift_types.MyUnion))