diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache index 0832ee016e9c1c..3461586232abe6 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache @@ -91,9 +91,11 @@ class {{> structs/unadapted_name}}({{! used in immutable thrift-python, which is the name of the Union (sigh!) }}FbThriftUnionFieldEnum.__name__ = "{{struct:py_name}}" + {{^struct:has_invariant_field?}} @_fbthrift_property {{> fields/maybe_abstract_method_annotation}} def fbthrift_current_value(self) -> {{> types/field_value_pep484_union_type}}: ... + {{/struct:has_invariant_field?}} @_fbthrift_property {{> fields/maybe_abstract_method_annotation}} def fbthrift_current_field(self) -> FbThriftUnionFieldEnum: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_invariant_types/gen-python/invariant/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_invariant_types/gen-python/invariant/thrift_abstract_types.py index f622cf5bbd30bf..a006f6a8dd99fb 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_invariant_types/gen-python/invariant/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_invariant_types/gen-python/invariant/thrift_abstract_types.py @@ -71,9 +71,6 @@ class FbThriftUnionFieldEnum(_enum.Enum): FbThriftUnionFieldEnum.__name__ = "InvariantTypes" @_fbthrift_property @_abc.abstractmethod - def fbthrift_current_value(self) -> _typing.Union[None, _typing.Mapping[_fbthrift_StructForInvariantTypes, int], _typing.Mapping[_fbthrift_UnionForInvariantTypes, int]]: ... - @_fbthrift_property - @_abc.abstractmethod def fbthrift_current_field(self) -> FbThriftUnionFieldEnum: ... _fbthrift_InvariantTypes = InvariantTypes