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 96fbbfeaac781..444a4b89f0ec9 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 @@ -25,6 +25,10 @@ Generated Python classes for abstract thrift-python types. import abc as _abc import typing as _typing +{{#program:unions?}} +import enum as _enum + +{{/program:unions?}} import folly.iobuf as _fbthrift_iobuf {{#program:include_namespaces}} @@ -82,6 +86,23 @@ class {{struct:py_name}}({{! @_abc.abstractmethod def _to_py_deprecated(self) -> "{{program:py_deprecated_module_path}}.ttypes.{{struct:py_name}}": ... # type: ignore {{/struct:legacy_api?}} + {{#struct:union?}} + + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: {{struct:py_name}}.FbThriftUnionFieldEnum = 0 + {{#struct:fields_ordered_by_id}} + {{field:py_name}}: {{struct:py_name}}.FbThriftUnionFieldEnum = {{field:key}} + {{/struct:fields_ordered_by_id}} + + {{! For backwards compatibility, set the name to the name + used in immutable thrift-python, which is the name + of the Union (sigh!) + }}FbThriftUnionFieldEnum.__name__ = "{{struct:py_name}}" + + fbthrift_current_value: _typing.Final[{{ > types/field_value_pep484_union_type}}] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + {{/struct:union?}} {{#struct:has_adapter?}} # TODO: Figure out how to handle adapters # {{struct:py_name}} = {{adapter:type_hint}}{{#adapter:is_generic?}}[{{> structs/unadapted_name}}]{{/adapter:is_generic?}} diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/field_value_pep484_union_type.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/field_value_pep484_union_type.mustache index b02e432d4a424..395abad26a65b 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/field_value_pep484_union_type.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/field_value_pep484_union_type.mustache @@ -17,5 +17,12 @@ }}{{! Typing for a union field }}_typing.Union[None{{#struct:fields_ordered_by_id}}{{! - }}, {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{! + }}, {{#field:type}}{{! + Do not use adapted abstract types until abstract types support them. + }}{{#program:generate_abstract_types}}{{! + }}{{> types/unadapted_pep484_type}}{{! + }}{{/program:generate_abstract_types}}{{! + }}{{^program:generate_abstract_types}}{{! + }}{{> types/pep484_type}}{{! + }}{{/program:generate_abstract_types}}{{/field:type}}{{! }}{{/struct:fields_ordered_by_id}}] diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types.mustache index 5d79a62c0d195..c15334065147f 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types.mustache @@ -21,7 +21,7 @@ Generated Python classes for Thrift types import folly.iobuf as _fbthrift_iobuf {{#program:generate_unified_thrift_python_type_hints?}} -import {{program:module_path}}.thrift_abstract_types +import {{program:module_path}}.thrift_abstract_types as _fbthrift_abstract_types {{/program:generate_unified_thrift_python_type_hints?}} import {{program:base_library_package}}.types as _fbthrift_python_types {{#program:generate_immutable_types}} @@ -52,7 +52,7 @@ If the class uses the abstract class as a direct baseclass, it results in the er Until we resolve the above error, register the class as virtual subclass of the abstract class. }} -@{{program:module_path}}.thrift_abstract_types.{{struct:py_name}}.register +@_fbthrift_abstract_types.{{struct:py_name}}.register {{/program:generate_unified_thrift_python_type_hints?}}{{! }}class {{> structs/unadapted_name}}{{! }}(metaclass={{! @@ -77,7 +77,16 @@ Until we resolve the above error, register the class as virtual subclass of the {{field:idl_type}}, # IDL type (see BaseTypeEnum) ), {{/struct:fields_ordered_by_id}} - ) + ){{! + }}{{#struct:union?}}{{! + }}{{#program:generate_unified_thrift_python_type_hints?}}{{! + }} + + _fbthrift_union_field_enum = _fbthrift_abstract_types.{{struct:py_name}}.FbThriftUnionFieldEnum + {{! + }}{{/program:generate_unified_thrift_python_type_hints?}}{{! + }}{{/struct:union?}} + @staticmethod def __get_thrift_name__() -> str: diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types_pyi.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types_pyi.mustache index a1ffe3fceb01f..5482660b04b4d 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types_pyi.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/python/types/types_pyi.mustache @@ -120,6 +120,7 @@ class {{> structs/unadapted_name}}({{! {{/struct:plain?}} {{#struct:union?}} +{{^program:generate_unified_thrift_python_type_hints?}} {{#program:generate_immutable_types}} class Type(enum.Enum): EMPTY: {{> structs/unadapted_name}}.Type = ... @@ -138,6 +139,12 @@ class {{> structs/unadapted_name}}({{! {{#program:generate_immutable_types}} FbThriftUnionFieldEnum = Type {{/program:generate_immutable_types}} +{{/program:generate_unified_thrift_python_type_hints?}} +{{#program:generate_unified_thrift_python_type_hints?}} +{{#program:generate_immutable_types}} + Type = FbThriftUnionFieldEnum +{{/program:generate_immutable_types}} +{{/program:generate_unified_thrift_python_type_hints?}} {{#program:generate_immutable_types}} @classmethod diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_abstract_types.py index a58041e3ae8df..64f96d40d3901 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_abstract_types.py @@ -13,6 +13,8 @@ import abc as _abc import typing as _typing +import enum as _enum + import folly.iobuf as _fbthrift_iobuf @@ -118,6 +120,19 @@ def _to_py3(self) -> "test.fixtures.basic.module.types.MyUnion": ... # type: ig @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.MyUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: MyUnion.FbThriftUnionFieldEnum = 0 + myEnum: MyUnion.FbThriftUnionFieldEnum = 1 + myStruct: MyUnion.FbThriftUnionFieldEnum = 2 + myDataItem: MyUnion.FbThriftUnionFieldEnum = 3 + floatSet: MyUnion.FbThriftUnionFieldEnum = 4 + + FbThriftUnionFieldEnum.__name__ = "MyUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, MyStruct, MyDataItem, _typing.AbstractSet[float]]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class MyException(_abc.ABC): @property @_abc.abstractmethod @@ -194,5 +209,15 @@ def _to_py3(self) -> "test.fixtures.basic.module.types.UnionToBeRenamed": ... # @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.UnionToBeRenamed": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: UnionToBeRenamed.FbThriftUnionFieldEnum = 0 + reserved_field: UnionToBeRenamed.FbThriftUnionFieldEnum = 1 + + FbThriftUnionFieldEnum.__name__ = "UnionToBeRenamed" + + fbthrift_current_value: _typing.Final[_typing.Union[None, int]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + MyEnumAlias = MyEnum MyDataItemAlias = MyDataItem diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.py index f6fc8ab07d1d4..4ecefa6908945 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.basic.module.thrift_abstract_types +import test.fixtures.basic.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@test.fixtures.basic.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -157,7 +157,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@test.fixtures.basic.module.thrift_abstract_types.Containers.register +@_fbthrift_abstract_types.Containers.register class Containers(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -228,7 +228,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Containers, self) -@test.fixtures.basic.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -266,7 +266,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@test.fixtures.basic.module.thrift_abstract_types.MyUnion.register +@_fbthrift_abstract_types.MyUnion.register class MyUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -315,6 +315,9 @@ class MyUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnion" @@ -348,7 +351,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnion, self) -@test.fixtures.basic.module.thrift_abstract_types.MyException.register +@_fbthrift_abstract_types.MyException.register class MyException(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -430,7 +433,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyException, self) -@test.fixtures.basic.module.thrift_abstract_types.MyExceptionWithMessage.register +@_fbthrift_abstract_types.MyExceptionWithMessage.register class MyExceptionWithMessage(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -519,7 +522,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyExceptionWithMessage, self) -@test.fixtures.basic.module.thrift_abstract_types.ReservedKeyword.register +@_fbthrift_abstract_types.ReservedKeyword.register class ReservedKeyword(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -568,7 +571,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ReservedKeyword, self) -@test.fixtures.basic.module.thrift_abstract_types.UnionToBeRenamed.register +@_fbthrift_abstract_types.UnionToBeRenamed.register class UnionToBeRenamed(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -584,6 +587,9 @@ class UnionToBeRenamed(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.UnionToBeRenamed.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.UnionToBeRenamed" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.pyi index f58e93582e0cf..d2c81826233a8 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_mutable_types.pyi @@ -190,13 +190,6 @@ class MyUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible_ ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: MyUnion.FbThriftUnionFieldEnum = ... - myEnum: MyUnion.FbThriftUnionFieldEnum = ... - myStruct: MyUnion.FbThriftUnionFieldEnum = ... - myDataItem: MyUnion.FbThriftUnionFieldEnum = ... - floatSet: MyUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, MyStruct, MyDataItem, _fbthrift_python_mutable_containers.MutableSet[float]]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -289,10 +282,6 @@ class UnionToBeRenamed(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_co ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: UnionToBeRenamed.FbThriftUnionFieldEnum = ... - reserved_field: UnionToBeRenamed.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, int]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.py index 06e40fa3e62cd..2347e25c52a4f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.basic.module.thrift_abstract_types +import test.fixtures.basic.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@test.fixtures.basic.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -156,7 +156,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@test.fixtures.basic.module.thrift_abstract_types.Containers.register +@_fbthrift_abstract_types.Containers.register class Containers(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -232,7 +232,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Containers, self) -@test.fixtures.basic.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -275,7 +275,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@test.fixtures.basic.module.thrift_abstract_types.MyUnion.register +@_fbthrift_abstract_types.MyUnion.register class MyUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -324,6 +324,9 @@ class MyUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnion" @@ -362,7 +365,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnion, self) -@test.fixtures.basic.module.thrift_abstract_types.MyException.register +@_fbthrift_abstract_types.MyException.register class MyException(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -449,7 +452,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyException, self) -@test.fixtures.basic.module.thrift_abstract_types.MyExceptionWithMessage.register +@_fbthrift_abstract_types.MyExceptionWithMessage.register class MyExceptionWithMessage(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -543,7 +546,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyExceptionWithMessage, self) -@test.fixtures.basic.module.thrift_abstract_types.ReservedKeyword.register +@_fbthrift_abstract_types.ReservedKeyword.register class ReservedKeyword(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -597,7 +600,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ReservedKeyword, self) -@test.fixtures.basic.module.thrift_abstract_types.UnionToBeRenamed.register +@_fbthrift_abstract_types.UnionToBeRenamed.register class UnionToBeRenamed(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -613,6 +616,9 @@ class UnionToBeRenamed(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.UnionToBeRenamed.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.UnionToBeRenamed" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.pyi index 632a310cb4217..01b5ff512c45b 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/basic/module/thrift_types.pyi @@ -150,14 +150,7 @@ class MyUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_MyUnion, t ) -> None: ... - class Type(enum.Enum): - EMPTY: MyUnion.Type = ... - myEnum: MyUnion.Type = ... - myStruct: MyUnion.Type = ... - myDataItem: MyUnion.Type = ... - floatSet: MyUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, MyEnum, MyStruct, MyDataItem, _typing.AbstractSet[float]]) -> MyUnion: ... @@ -252,11 +245,7 @@ class UnionToBeRenamed(_fbthrift_python_types.Union, _fbthrift_compatible_with_U ) -> None: ... - class Type(enum.Enum): - EMPTY: UnionToBeRenamed.Type = ... - reserved_field: UnionToBeRenamed.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, int]) -> UnionToBeRenamed: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py index 28b896c2b8324..84bb638883364 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py @@ -13,6 +13,8 @@ import abc as _abc import typing as _typing +import enum as _enum + import folly.iobuf as _fbthrift_iobuf @@ -334,6 +336,21 @@ def _to_py3(self) -> "module.types.MyUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.MyUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: MyUnion.FbThriftUnionFieldEnum = 0 + myEnum: MyUnion.FbThriftUnionFieldEnum = 1 + myStruct: MyUnion.FbThriftUnionFieldEnum = 2 + myDataItem: MyUnion.FbThriftUnionFieldEnum = 3 + complexNestedStruct: MyUnion.FbThriftUnionFieldEnum = 4 + longValue: MyUnion.FbThriftUnionFieldEnum = 5 + intValue: MyUnion.FbThriftUnionFieldEnum = 6 + + FbThriftUnionFieldEnum.__name__ = "MyUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, MyStruct, MyDataItem, ComplexNestedStruct, int, int]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class MyUnionFloatFieldThrowExp(_abc.ABC): @property @_abc.abstractmethod @@ -356,6 +373,19 @@ def _to_py3(self) -> "module.types.MyUnionFloatFieldThrowExp": ... # type: igno @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.MyUnionFloatFieldThrowExp": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = 0 + myEnum: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = 1 + setFloat: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = 2 + myDataItem: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = 3 + complexNestedStruct: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = 4 + + FbThriftUnionFieldEnum.__name__ = "MyUnionFloatFieldThrowExp" + + fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, _typing.Sequence[_typing.Sequence[float]], MyDataItem, ComplexNestedStruct]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class ComplexNestedStruct(_abc.ABC): @property @_abc.abstractmethod diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index eb12aaae8a804..d274980f77d5c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.MyStructFloatFieldThrowExp.register +@_fbthrift_abstract_types.MyStructFloatFieldThrowExp.register class MyStructFloatFieldThrowExp(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -102,7 +102,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructFloatFieldThrowExp, self) -@module.thrift_abstract_types.MyStructMapFloatThrowExp.register +@_fbthrift_abstract_types.MyStructMapFloatThrowExp.register class MyStructMapFloatThrowExp(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -162,7 +162,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructMapFloatThrowExp, self) -@module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -508,7 +508,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@module.thrift_abstract_types.SimpleStruct.register +@_fbthrift_abstract_types.SimpleStruct.register class SimpleStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -568,7 +568,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SimpleStruct, self) -@module.thrift_abstract_types.defaultStruct.register +@_fbthrift_abstract_types.defaultStruct.register class defaultStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -848,7 +848,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.defaultStruct, self) -@module.thrift_abstract_types.MyStructTypeDef.register +@_fbthrift_abstract_types.MyStructTypeDef.register class MyStructTypeDef(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -985,7 +985,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructTypeDef, self) -@module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -1023,7 +1023,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@module.thrift_abstract_types.MyUnion.register +@_fbthrift_abstract_types.MyUnion.register class MyUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1094,6 +1094,9 @@ class MyUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnion" @@ -1127,7 +1130,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnion, self) -@module.thrift_abstract_types.MyUnionFloatFieldThrowExp.register +@_fbthrift_abstract_types.MyUnionFloatFieldThrowExp.register class MyUnionFloatFieldThrowExp(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1176,6 +1179,9 @@ class MyUnionFloatFieldThrowExp(metaclass=_fbthrift_python_mutable_types.Mutable ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnionFloatFieldThrowExp" @@ -1209,7 +1215,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnionFloatFieldThrowExp, self) -@module.thrift_abstract_types.ComplexNestedStruct.register +@_fbthrift_abstract_types.ComplexNestedStruct.register class ComplexNestedStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1445,7 +1451,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexNestedStruct, self) -@module.thrift_abstract_types.TypeRemapped.register +@_fbthrift_abstract_types.TypeRemapped.register class TypeRemapped(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1527,7 +1533,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TypeRemapped, self) -@module.thrift_abstract_types.emptyXcep.register +@_fbthrift_abstract_types.emptyXcep.register class emptyXcep(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -1565,7 +1571,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.emptyXcep, self) -@module.thrift_abstract_types.reqXcep.register +@_fbthrift_abstract_types.reqXcep.register class reqXcep(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1625,7 +1631,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.reqXcep, self) -@module.thrift_abstract_types.optXcep.register +@_fbthrift_abstract_types.optXcep.register class optXcep(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1685,7 +1691,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.optXcep, self) -@module.thrift_abstract_types.complexException.register +@_fbthrift_abstract_types.complexException.register class complexException(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi index b500d0c367a8d..2973c6832ce3e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi @@ -572,15 +572,6 @@ class MyUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible_ ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: MyUnion.FbThriftUnionFieldEnum = ... - myEnum: MyUnion.FbThriftUnionFieldEnum = ... - myStruct: MyUnion.FbThriftUnionFieldEnum = ... - myDataItem: MyUnion.FbThriftUnionFieldEnum = ... - complexNestedStruct: MyUnion.FbThriftUnionFieldEnum = ... - longValue: MyUnion.FbThriftUnionFieldEnum = ... - intValue: MyUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, MyStruct, MyDataItem, ComplexNestedStruct, int, int]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -614,13 +605,6 @@ class MyUnionFloatFieldThrowExp(_fbthrift_python_mutable_types.MutableUnion, _fb ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = ... - myEnum: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = ... - setFloat: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = ... - myDataItem: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = ... - complexNestedStruct: MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, _fbthrift_python_mutable_containers.MutableList[_fbthrift_python_mutable_containers.MutableList[float]], MyDataItem, ComplexNestedStruct]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index c29551919ed60..8d36c460888c1 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.MyStructFloatFieldThrowExp.register +@_fbthrift_abstract_types.MyStructFloatFieldThrowExp.register class MyStructFloatFieldThrowExp(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -101,7 +101,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructFloatFieldThrowExp, self) -@module.thrift_abstract_types.MyStructMapFloatThrowExp.register +@_fbthrift_abstract_types.MyStructMapFloatThrowExp.register class MyStructMapFloatThrowExp(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -166,7 +166,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructMapFloatThrowExp, self) -@module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -517,7 +517,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@module.thrift_abstract_types.SimpleStruct.register +@_fbthrift_abstract_types.SimpleStruct.register class SimpleStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -582,7 +582,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SimpleStruct, self) -@module.thrift_abstract_types.defaultStruct.register +@_fbthrift_abstract_types.defaultStruct.register class defaultStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -867,7 +867,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.defaultStruct, self) -@module.thrift_abstract_types.MyStructTypeDef.register +@_fbthrift_abstract_types.MyStructTypeDef.register class MyStructTypeDef(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1009,7 +1009,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructTypeDef, self) -@module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1052,7 +1052,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@module.thrift_abstract_types.MyUnion.register +@_fbthrift_abstract_types.MyUnion.register class MyUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1123,6 +1123,9 @@ class MyUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnion" @@ -1161,7 +1164,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnion, self) -@module.thrift_abstract_types.MyUnionFloatFieldThrowExp.register +@_fbthrift_abstract_types.MyUnionFloatFieldThrowExp.register class MyUnionFloatFieldThrowExp(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1210,6 +1213,9 @@ class MyUnionFloatFieldThrowExp(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.MyUnionFloatFieldThrowExp.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.MyUnionFloatFieldThrowExp" @@ -1248,7 +1254,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyUnionFloatFieldThrowExp, self) -@module.thrift_abstract_types.ComplexNestedStruct.register +@_fbthrift_abstract_types.ComplexNestedStruct.register class ComplexNestedStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1489,7 +1495,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexNestedStruct, self) -@module.thrift_abstract_types.TypeRemapped.register +@_fbthrift_abstract_types.TypeRemapped.register class TypeRemapped(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1576,7 +1582,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TypeRemapped, self) -@module.thrift_abstract_types.emptyXcep.register +@_fbthrift_abstract_types.emptyXcep.register class emptyXcep(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -1619,7 +1625,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.emptyXcep, self) -@module.thrift_abstract_types.reqXcep.register +@_fbthrift_abstract_types.reqXcep.register class reqXcep(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1684,7 +1690,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.reqXcep, self) -@module.thrift_abstract_types.optXcep.register +@_fbthrift_abstract_types.optXcep.register class optXcep(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1749,7 +1755,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.optXcep, self) -@module.thrift_abstract_types.complexException.register +@_fbthrift_abstract_types.complexException.register class complexException(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi index 7b5a5a7cb95e6..41b4194573dd5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi @@ -387,16 +387,7 @@ class MyUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_MyUnion, m ) -> None: ... - class Type(enum.Enum): - EMPTY: MyUnion.Type = ... - myEnum: MyUnion.Type = ... - myStruct: MyUnion.Type = ... - myDataItem: MyUnion.Type = ... - complexNestedStruct: MyUnion.Type = ... - longValue: MyUnion.Type = ... - intValue: MyUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, MyEnum, MyStruct, MyDataItem, ComplexNestedStruct, int, int]) -> MyUnion: ... @@ -427,14 +418,7 @@ class MyUnionFloatFieldThrowExp(_fbthrift_python_types.Union, _fbthrift_compatib ) -> None: ... - class Type(enum.Enum): - EMPTY: MyUnionFloatFieldThrowExp.Type = ... - myEnum: MyUnionFloatFieldThrowExp.Type = ... - setFloat: MyUnionFloatFieldThrowExp.Type = ... - myDataItem: MyUnionFloatFieldThrowExp.Type = ... - complexNestedStruct: MyUnionFloatFieldThrowExp.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, MyEnum, _typing.Sequence[_typing.Sequence[float]], MyDataItem, ComplexNestedStruct]) -> MyUnionFloatFieldThrowExp: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py index e291c202067d2..3445b00306802 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py @@ -13,6 +13,8 @@ import abc as _abc import typing as _typing +import enum as _enum + import folly.iobuf as _fbthrift_iobuf @@ -45,6 +47,21 @@ def _to_py3(self) -> "module.types.ComplexUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.ComplexUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: ComplexUnion.FbThriftUnionFieldEnum = 0 + intValue: ComplexUnion.FbThriftUnionFieldEnum = 1 + intListValue: ComplexUnion.FbThriftUnionFieldEnum = 2 + stringListValue: ComplexUnion.FbThriftUnionFieldEnum = 3 + stringValue: ComplexUnion.FbThriftUnionFieldEnum = 5 + typedefValue: ComplexUnion.FbThriftUnionFieldEnum = 9 + stringRef: ComplexUnion.FbThriftUnionFieldEnum = 14 + + FbThriftUnionFieldEnum.__name__ = "ComplexUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, int, _typing.Sequence[int], _typing.Sequence[str], str, _typing.Mapping[int, str], str]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class ListUnion(_abc.ABC): @property @_abc.abstractmethod @@ -61,6 +78,17 @@ def _to_py3(self) -> "module.types.ListUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.ListUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: ListUnion.FbThriftUnionFieldEnum = 0 + intListValue: ListUnion.FbThriftUnionFieldEnum = 2 + stringListValue: ListUnion.FbThriftUnionFieldEnum = 3 + + FbThriftUnionFieldEnum.__name__ = "ListUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, _typing.Sequence[int], _typing.Sequence[str]]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class DataUnion(_abc.ABC): @property @_abc.abstractmethod @@ -77,6 +105,17 @@ def _to_py3(self) -> "module.types.DataUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.DataUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: DataUnion.FbThriftUnionFieldEnum = 0 + binaryData: DataUnion.FbThriftUnionFieldEnum = 1 + stringData: DataUnion.FbThriftUnionFieldEnum = 2 + + FbThriftUnionFieldEnum.__name__ = "DataUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, bytes, str]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class Val(_abc.ABC): @property @_abc.abstractmethod @@ -114,6 +153,17 @@ def _to_py3(self) -> "module.types.ValUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.ValUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: ValUnion.FbThriftUnionFieldEnum = 0 + v1: ValUnion.FbThriftUnionFieldEnum = 1 + v2: ValUnion.FbThriftUnionFieldEnum = 2 + + FbThriftUnionFieldEnum.__name__ = "ValUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, Val, Val]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class VirtualComplexUnion(_abc.ABC): @property @_abc.abstractmethod @@ -130,6 +180,17 @@ def _to_py3(self) -> "module.types.VirtualComplexUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.VirtualComplexUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: VirtualComplexUnion.FbThriftUnionFieldEnum = 0 + thingOne: VirtualComplexUnion.FbThriftUnionFieldEnum = 1 + thingTwo: VirtualComplexUnion.FbThriftUnionFieldEnum = 2 + + FbThriftUnionFieldEnum.__name__ = "VirtualComplexUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, str, str]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class NonCopyableStruct(_abc.ABC): @property @_abc.abstractmethod @@ -158,4 +219,14 @@ def _to_py3(self) -> "module.types.NonCopyableUnion": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.NonCopyableUnion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: NonCopyableUnion.FbThriftUnionFieldEnum = 0 + s: NonCopyableUnion.FbThriftUnionFieldEnum = 1 + + FbThriftUnionFieldEnum.__name__ = "NonCopyableUnion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, NonCopyableStruct]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + containerTypedef = _typing.Mapping[int, str] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index 2e25b5722328d..d1a76f92e30d5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.ComplexUnion.register +@_fbthrift_abstract_types.ComplexUnion.register class ComplexUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -91,6 +91,9 @@ class ComplexUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ComplexUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ComplexUnion" @@ -124,7 +127,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexUnion, self) -@module.thrift_abstract_types.ListUnion.register +@_fbthrift_abstract_types.ListUnion.register class ListUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -151,6 +154,9 @@ class ListUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ListUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ListUnion" @@ -184,7 +190,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ListUnion, self) -@module.thrift_abstract_types.DataUnion.register +@_fbthrift_abstract_types.DataUnion.register class DataUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -211,6 +217,9 @@ class DataUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.DataUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.DataUnion" @@ -244,7 +253,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DataUnion, self) -@module.thrift_abstract_types.Val.register +@_fbthrift_abstract_types.Val.register class Val(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -315,7 +324,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Val, self) -@module.thrift_abstract_types.ValUnion.register +@_fbthrift_abstract_types.ValUnion.register class ValUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -342,6 +351,9 @@ class ValUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ValUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ValUnion" @@ -375,7 +387,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ValUnion, self) -@module.thrift_abstract_types.VirtualComplexUnion.register +@_fbthrift_abstract_types.VirtualComplexUnion.register class VirtualComplexUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -402,6 +414,9 @@ class VirtualComplexUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionM ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.VirtualComplexUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.VirtualComplexUnion" @@ -435,7 +450,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.VirtualComplexUnion, self) -@module.thrift_abstract_types.NonCopyableStruct.register +@_fbthrift_abstract_types.NonCopyableStruct.register class NonCopyableStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -484,7 +499,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.NonCopyableStruct, self) -@module.thrift_abstract_types.NonCopyableUnion.register +@_fbthrift_abstract_types.NonCopyableUnion.register class NonCopyableUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -500,6 +515,9 @@ class NonCopyableUnion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.NonCopyableUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.NonCopyableUnion" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi index 827445b87ae05..481ab4ea5ce1f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi @@ -69,15 +69,6 @@ class ComplexUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compat ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: ComplexUnion.FbThriftUnionFieldEnum = ... - intValue: ComplexUnion.FbThriftUnionFieldEnum = ... - intListValue: ComplexUnion.FbThriftUnionFieldEnum = ... - stringListValue: ComplexUnion.FbThriftUnionFieldEnum = ... - stringValue: ComplexUnion.FbThriftUnionFieldEnum = ... - typedefValue: ComplexUnion.FbThriftUnionFieldEnum = ... - stringRef: ComplexUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, int, _fbthrift_python_mutable_containers.MutableList[int], _fbthrift_python_mutable_containers.MutableList[str], str, _fbthrift_python_mutable_containers.MutableMap[int, str], str]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -112,11 +103,6 @@ class ListUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatibl ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: ListUnion.FbThriftUnionFieldEnum = ... - intListValue: ListUnion.FbThriftUnionFieldEnum = ... - stringListValue: ListUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, _fbthrift_python_mutable_containers.MutableList[int], _fbthrift_python_mutable_containers.MutableList[str]]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -141,11 +127,6 @@ class DataUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatibl ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: DataUnion.FbThriftUnionFieldEnum = ... - binaryData: DataUnion.FbThriftUnionFieldEnum = ... - stringData: DataUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, bytes, str]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -203,11 +184,6 @@ class ValUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: ValUnion.FbThriftUnionFieldEnum = ... - v1: ValUnion.FbThriftUnionFieldEnum = ... - v2: ValUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, Val, Val]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -232,11 +208,6 @@ class VirtualComplexUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: VirtualComplexUnion.FbThriftUnionFieldEnum = ... - thingOne: VirtualComplexUnion.FbThriftUnionFieldEnum = ... - thingTwo: VirtualComplexUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, str, str]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -281,10 +252,6 @@ class NonCopyableUnion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_co ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: NonCopyableUnion.FbThriftUnionFieldEnum = ... - s: NonCopyableUnion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, NonCopyableStruct]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 4d19395035a60..a1210449f4a46 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.ComplexUnion.register +@_fbthrift_abstract_types.ComplexUnion.register class ComplexUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -85,6 +85,9 @@ class ComplexUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ComplexUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ComplexUnion" @@ -123,7 +126,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexUnion, self) -@module.thrift_abstract_types.ListUnion.register +@_fbthrift_abstract_types.ListUnion.register class ListUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -150,6 +153,9 @@ class ListUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ListUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ListUnion" @@ -188,7 +194,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ListUnion, self) -@module.thrift_abstract_types.DataUnion.register +@_fbthrift_abstract_types.DataUnion.register class DataUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -215,6 +221,9 @@ class DataUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.DataUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.DataUnion" @@ -253,7 +262,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DataUnion, self) -@module.thrift_abstract_types.Val.register +@_fbthrift_abstract_types.Val.register class Val(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -329,7 +338,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Val, self) -@module.thrift_abstract_types.ValUnion.register +@_fbthrift_abstract_types.ValUnion.register class ValUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -356,6 +365,9 @@ class ValUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.ValUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.ValUnion" @@ -394,7 +406,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ValUnion, self) -@module.thrift_abstract_types.VirtualComplexUnion.register +@_fbthrift_abstract_types.VirtualComplexUnion.register class VirtualComplexUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -421,6 +433,9 @@ class VirtualComplexUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.VirtualComplexUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.VirtualComplexUnion" @@ -459,7 +474,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.VirtualComplexUnion, self) -@module.thrift_abstract_types.NonCopyableStruct.register +@_fbthrift_abstract_types.NonCopyableStruct.register class NonCopyableStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -513,7 +528,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.NonCopyableStruct, self) -@module.thrift_abstract_types.NonCopyableUnion.register +@_fbthrift_abstract_types.NonCopyableUnion.register class NonCopyableUnion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -529,6 +544,9 @@ class NonCopyableUnion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.NonCopyableUnion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.NonCopyableUnion" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi index 926f291512ae5..469d9c319e5fd 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi @@ -39,16 +39,7 @@ class ComplexUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_Compl ) -> None: ... - class Type(enum.Enum): - EMPTY: ComplexUnion.Type = ... - intValue: ComplexUnion.Type = ... - intListValue: ComplexUnion.Type = ... - stringListValue: ComplexUnion.Type = ... - stringValue: ComplexUnion.Type = ... - typedefValue: ComplexUnion.Type = ... - stringRef: ComplexUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, int, _typing.Sequence[int], _typing.Sequence[str], str, _typing.Mapping[int, str], str]) -> ComplexUnion: ... @@ -75,12 +66,7 @@ class ListUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_ListUnio ) -> None: ... - class Type(enum.Enum): - EMPTY: ListUnion.Type = ... - intListValue: ListUnion.Type = ... - stringListValue: ListUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, _typing.Sequence[int], _typing.Sequence[str]]) -> ListUnion: ... @@ -107,12 +93,7 @@ class DataUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_DataUnio ) -> None: ... - class Type(enum.Enum): - EMPTY: DataUnion.Type = ... - binaryData: DataUnion.Type = ... - stringData: DataUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, bytes, str]) -> DataUnion: ... @@ -167,12 +148,7 @@ class ValUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_ValUnion, ) -> None: ... - class Type(enum.Enum): - EMPTY: ValUnion.Type = ... - v1: ValUnion.Type = ... - v2: ValUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, Val, Val]) -> ValUnion: ... @@ -199,12 +175,7 @@ class VirtualComplexUnion(_fbthrift_python_types.Union, _fbthrift_compatible_wit ) -> None: ... - class Type(enum.Enum): - EMPTY: VirtualComplexUnion.Type = ... - thingOne: VirtualComplexUnion.Type = ... - thingTwo: VirtualComplexUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, str, str]) -> VirtualComplexUnion: ... @@ -251,11 +222,7 @@ class NonCopyableUnion(_fbthrift_python_types.Union, _fbthrift_compatible_with_N ) -> None: ... - class Type(enum.Enum): - EMPTY: NonCopyableUnion.Type = ... - s: NonCopyableUnion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, NonCopyableStruct]) -> NonCopyableUnion: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py index b3456d1b1a119..5c75d080b7ac5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_abstract_types.py @@ -13,6 +13,8 @@ import abc as _abc import typing as _typing +import enum as _enum + import folly.iobuf as _fbthrift_iobuf @@ -171,6 +173,17 @@ def _to_py3(self) -> "module.types.union1": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.union1": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: union1.FbThriftUnionFieldEnum = 0 + i: union1.FbThriftUnionFieldEnum = 1 + d: union1.FbThriftUnionFieldEnum = 2 + + FbThriftUnionFieldEnum.__name__ = "union1" + + fbthrift_current_value: _typing.Final[_typing.Union[None, int, float]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + class union2(_abc.ABC): @property @_abc.abstractmethod @@ -193,6 +206,19 @@ def _to_py3(self) -> "module.types.union2": ... # type: ignore @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.union2": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: union2.FbThriftUnionFieldEnum = 0 + i: union2.FbThriftUnionFieldEnum = 1 + d: union2.FbThriftUnionFieldEnum = 2 + s: union2.FbThriftUnionFieldEnum = 3 + u: union2.FbThriftUnionFieldEnum = 4 + + FbThriftUnionFieldEnum.__name__ = "union2" + + fbthrift_current_value: _typing.Final[_typing.Union[None, int, float, struct1, union1]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + MyCompany = Company MyStringIdentifier = str MyIntIdentifier = int diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index d13d84ac1832f..24ecdb8eff2ef 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.Internship.register +@_fbthrift_abstract_types.Internship.register class Internship(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -113,7 +113,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Internship, self) -@module.thrift_abstract_types.Range.register +@_fbthrift_abstract_types.Range.register class Range(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -173,7 +173,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Range, self) -@module.thrift_abstract_types.struct1.register +@_fbthrift_abstract_types.struct1.register class struct1(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -233,7 +233,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct1, self) -@module.thrift_abstract_types.struct2.register +@_fbthrift_abstract_types.struct2.register class struct2(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -315,7 +315,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct2, self) -@module.thrift_abstract_types.struct3.register +@_fbthrift_abstract_types.struct3.register class struct3(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -386,7 +386,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct3, self) -@module.thrift_abstract_types.struct4.register +@_fbthrift_abstract_types.struct4.register class struct4(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -457,7 +457,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct4, self) -@module.thrift_abstract_types.union1.register +@_fbthrift_abstract_types.union1.register class union1(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -484,6 +484,9 @@ class union1(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.union1.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.union1" @@ -517,7 +520,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.union1, self) -@module.thrift_abstract_types.union2.register +@_fbthrift_abstract_types.union2.register class union2(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -566,6 +569,9 @@ class union2(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.union2.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.union2" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi index 6426d7b552c91..4226adf0e6a49 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.pyi @@ -257,11 +257,6 @@ class union1(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible_w ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: union1.FbThriftUnionFieldEnum = ... - i: union1.FbThriftUnionFieldEnum = ... - d: union1.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, int, float]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] @@ -290,13 +285,6 @@ class union2(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible_w ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: union2.FbThriftUnionFieldEnum = ... - i: union2.FbThriftUnionFieldEnum = ... - d: union2.FbThriftUnionFieldEnum = ... - s: union2.FbThriftUnionFieldEnum = ... - u: union2.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, int, float, struct1, union1]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 9e12ad77ee82b..a66f11d19d9af 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.Internship.register +@_fbthrift_abstract_types.Internship.register class Internship(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -112,7 +112,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Internship, self) -@module.thrift_abstract_types.Range.register +@_fbthrift_abstract_types.Range.register class Range(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -177,7 +177,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Range, self) -@module.thrift_abstract_types.struct1.register +@_fbthrift_abstract_types.struct1.register class struct1(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -242,7 +242,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct1, self) -@module.thrift_abstract_types.struct2.register +@_fbthrift_abstract_types.struct2.register class struct2(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -329,7 +329,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct2, self) -@module.thrift_abstract_types.struct3.register +@_fbthrift_abstract_types.struct3.register class struct3(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -405,7 +405,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct3, self) -@module.thrift_abstract_types.struct4.register +@_fbthrift_abstract_types.struct4.register class struct4(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -481,7 +481,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.struct4, self) -@module.thrift_abstract_types.union1.register +@_fbthrift_abstract_types.union1.register class union1(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -508,6 +508,9 @@ class union1(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.union1.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.union1" @@ -546,7 +549,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.union1, self) -@module.thrift_abstract_types.union2.register +@_fbthrift_abstract_types.union2.register class union2(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -595,6 +598,9 @@ class union2(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.union2.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.union2" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi index ca533466710c4..2eb9045cf12eb 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.pyi @@ -237,12 +237,7 @@ class union1(_fbthrift_python_types.Union, _fbthrift_compatible_with_union1, mod ) -> None: ... - class Type(enum.Enum): - EMPTY: union1.Type = ... - i: union1.Type = ... - d: union1.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, int, float]) -> union1: ... @@ -273,14 +268,7 @@ class union2(_fbthrift_python_types.Union, _fbthrift_compatible_with_union2, mod ) -> None: ... - class Type(enum.Enum): - EMPTY: union2.Type = ... - i: union2.Type = ... - d: union2.Type = ... - s: union2.Type = ... - u: union2.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, int, float, struct1, union1]) -> union2: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_mutable_types.py index 83f2b72649161..03208c95fe3c7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.enums.module.thrift_abstract_types +import test.fixtures.enums.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@test.fixtures.enums.module.thrift_abstract_types.SomeStruct.register +@_fbthrift_abstract_types.SomeStruct.register class SomeStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -102,7 +102,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SomeStruct, self) -@test.fixtures.enums.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_types.py index 2902cb385028f..7fee181e816ac 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/enums/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.enums.module.thrift_abstract_types +import test.fixtures.enums.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@test.fixtures.enums.module.thrift_abstract_types.SomeStruct.register +@_fbthrift_abstract_types.SomeStruct.register class SomeStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -101,7 +101,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SomeStruct, self) -@test.fixtures.enums.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index 96c33c127d49e..40dabf2e0bd01 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.Fiery.register +@_fbthrift_abstract_types.Fiery.register class Fiery(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -76,7 +76,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Fiery, self) -@module.thrift_abstract_types.Serious.register +@_fbthrift_abstract_types.Serious.register class Serious(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -132,7 +132,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Serious, self) -@module.thrift_abstract_types.ComplexFieldNames.register +@_fbthrift_abstract_types.ComplexFieldNames.register class ComplexFieldNames(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -199,7 +199,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexFieldNames, self) -@module.thrift_abstract_types.CustomFieldNames.register +@_fbthrift_abstract_types.CustomFieldNames.register class CustomFieldNames(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -266,7 +266,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CustomFieldNames, self) -@module.thrift_abstract_types.ExceptionWithPrimitiveField.register +@_fbthrift_abstract_types.ExceptionWithPrimitiveField.register class ExceptionWithPrimitiveField(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -333,7 +333,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ExceptionWithPrimitiveField, self) -@module.thrift_abstract_types.ExceptionWithStructuredAnnotation.register +@_fbthrift_abstract_types.ExceptionWithStructuredAnnotation.register class ExceptionWithStructuredAnnotation(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -400,7 +400,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ExceptionWithStructuredAnnotation, self) -@module.thrift_abstract_types.Banal.register +@_fbthrift_abstract_types.Banal.register class Banal(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( ) diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 1f460f9af2735..eadccbdcb8dee 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.Fiery.register +@_fbthrift_abstract_types.Fiery.register class Fiery(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -75,7 +75,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Fiery, self) -@module.thrift_abstract_types.Serious.register +@_fbthrift_abstract_types.Serious.register class Serious(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -136,7 +136,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Serious, self) -@module.thrift_abstract_types.ComplexFieldNames.register +@_fbthrift_abstract_types.ComplexFieldNames.register class ComplexFieldNames(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -208,7 +208,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexFieldNames, self) -@module.thrift_abstract_types.CustomFieldNames.register +@_fbthrift_abstract_types.CustomFieldNames.register class CustomFieldNames(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -280,7 +280,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CustomFieldNames, self) -@module.thrift_abstract_types.ExceptionWithPrimitiveField.register +@_fbthrift_abstract_types.ExceptionWithPrimitiveField.register class ExceptionWithPrimitiveField(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -352,7 +352,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ExceptionWithPrimitiveField, self) -@module.thrift_abstract_types.ExceptionWithStructuredAnnotation.register +@_fbthrift_abstract_types.ExceptionWithStructuredAnnotation.register class ExceptionWithStructuredAnnotation(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -424,7 +424,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ExceptionWithStructuredAnnotation, self) -@module.thrift_abstract_types.Banal.register +@_fbthrift_abstract_types.Banal.register class Banal(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( ) diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index 364ab8692c2f4..7e688a2cb675f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -22,7 +22,7 @@ import includes.thrift_mutable_types -@module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 759b957a0b50a..3a0d89fb7a730 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,7 +8,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions @@ -16,7 +16,7 @@ import includes.thrift_types -@module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index f3dee02767eba..3ff173942e77b 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -22,7 +22,7 @@ import foo.thrift_mutable_types -@module.thrift_abstract_types.Fields.register +@_fbthrift_abstract_types.Fields.register class Fields(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -71,7 +71,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Fields, self) -@module.thrift_abstract_types.FieldsInjectedToEmptyStruct.register +@_fbthrift_abstract_types.FieldsInjectedToEmptyStruct.register class FieldsInjectedToEmptyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -120,7 +120,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FieldsInjectedToEmptyStruct, self) -@module.thrift_abstract_types.FieldsInjectedToStruct.register +@_fbthrift_abstract_types.FieldsInjectedToStruct.register class FieldsInjectedToStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -180,7 +180,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FieldsInjectedToStruct, self) -@module.thrift_abstract_types.FieldsInjectedWithIncludedStruct.register +@_fbthrift_abstract_types.FieldsInjectedWithIncludedStruct.register class FieldsInjectedWithIncludedStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 695bef56428a5..a4a36f0d1d450 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,7 +8,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions @@ -16,7 +16,7 @@ import foo.thrift_types -@module.thrift_abstract_types.Fields.register +@_fbthrift_abstract_types.Fields.register class Fields(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -70,7 +70,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Fields, self) -@module.thrift_abstract_types.FieldsInjectedToEmptyStruct.register +@_fbthrift_abstract_types.FieldsInjectedToEmptyStruct.register class FieldsInjectedToEmptyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -124,7 +124,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FieldsInjectedToEmptyStruct, self) -@module.thrift_abstract_types.FieldsInjectedToStruct.register +@_fbthrift_abstract_types.FieldsInjectedToStruct.register class FieldsInjectedToStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -189,7 +189,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FieldsInjectedToStruct, self) -@module.thrift_abstract_types.FieldsInjectedWithIncludedStruct.register +@_fbthrift_abstract_types.FieldsInjectedWithIncludedStruct.register class FieldsInjectedWithIncludedStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index 19609b08089d8..c49df6ffc0cd5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.Limits.register +@_fbthrift_abstract_types.Limits.register class Limits(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 4fdb8a745d5a8..54b84fd392a62 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.Limits.register +@_fbthrift_abstract_types.Limits.register class Limits(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_mutable_types.py index 841613b25d4d4..e966cd56c3e66 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.interactions.module.thrift_abstract_types +import test.fixtures.interactions.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -22,7 +22,7 @@ import test.fixtures.another_interactions.shared.thrift_mutable_types -@test.fixtures.interactions.module.thrift_abstract_types.CustomException.register +@_fbthrift_abstract_types.CustomException.register class CustomException(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_types.py index 9e6adef186830..7b6d5130fb549 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/interactions/module/thrift_types.py @@ -8,7 +8,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.interactions.module.thrift_abstract_types +import test.fixtures.interactions.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions @@ -16,7 +16,7 @@ import test.fixtures.another_interactions.shared.thrift_types -@test.fixtures.interactions.module.thrift_abstract_types.CustomException.register +@_fbthrift_abstract_types.CustomException.register class CustomException(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index d15a5745f31ea..82a7ed8ae50ea 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.Mixin1.register +@_fbthrift_abstract_types.Mixin1.register class Mixin1(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -69,7 +69,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin1, self) -@module.thrift_abstract_types.Mixin2.register +@_fbthrift_abstract_types.Mixin2.register class Mixin2(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -129,7 +129,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin2, self) -@module.thrift_abstract_types.Mixin3Base.register +@_fbthrift_abstract_types.Mixin3Base.register class Mixin3Base(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -178,7 +178,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin3Base, self) -@module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 8e3dc8db1f839..1ce046cc65d2e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.Mixin1.register +@_fbthrift_abstract_types.Mixin1.register class Mixin1(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -68,7 +68,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin1, self) -@module.thrift_abstract_types.Mixin2.register +@_fbthrift_abstract_types.Mixin2.register class Mixin2(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -133,7 +133,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin2, self) -@module.thrift_abstract_types.Mixin3Base.register +@_fbthrift_abstract_types.Mixin3Base.register class Mixin3Base(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -187,7 +187,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Mixin3Base, self) -@module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_mutable_types.py index 6dd2b26524730..eccc667c987df 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.namespace_from_package.module.thrift_abstract_types +import test.namespace_from_package.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@test.namespace_from_package.module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_types.py index 42953b4320553..3c451ae648635 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.namespace_from_package.module.thrift_abstract_types +import test.namespace_from_package.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@test.namespace_from_package.module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_mutable_types.py index d15ee5d5f8452..6c53bde76958d 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.namespace_from_package_without_module_name.module.thrift_abstract_types +import test.namespace_from_package_without_module_name.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@test.namespace_from_package_without_module_name.module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_types.py index ecbc65a2ee22c..e8e352199f55b 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/namespace_from_package_without_module_name/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.namespace_from_package_without_module_name.module.thrift_abstract_types +import test.namespace_from_package_without_module_name.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@test.namespace_from_package_without_module_name.module.thrift_abstract_types.Foo.register +@_fbthrift_abstract_types.Foo.register class Foo(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py index f2dc744556451..b1a323b6633a2 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py @@ -13,6 +13,8 @@ import abc as _abc import typing as _typing +import enum as _enum + import folly.iobuf as _fbthrift_iobuf import apache.thrift.type.id.thrift_abstract_types @@ -411,6 +413,22 @@ def _to_py3(self) -> "test.fixtures.python_capi.module.types.Onion": ... # type @_abc.abstractmethod def _to_py_deprecated(self) -> "module.ttypes.Onion": ... # type: ignore + class FbThriftUnionFieldEnum(_enum.Enum): + EMPTY: Onion.FbThriftUnionFieldEnum = 0 + myEnum: Onion.FbThriftUnionFieldEnum = 1 + myStruct: Onion.FbThriftUnionFieldEnum = 2 + myString: Onion.FbThriftUnionFieldEnum = 4 + intSet: Onion.FbThriftUnionFieldEnum = 6 + doubleList: Onion.FbThriftUnionFieldEnum = 8 + strMap: Onion.FbThriftUnionFieldEnum = 9 + adapted_int: Onion.FbThriftUnionFieldEnum = 10 + + FbThriftUnionFieldEnum.__name__ = "Onion" + + fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, PrimitiveStruct, str, _typing.AbstractSet[int], _typing.Sequence[float], _typing.Mapping[bytes, str], int]] + fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] + + uint64 = int ui64 = int signed_byte = int diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.py index d68dec5a9cb00..5f53502f13763 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.python_capi.module.thrift_abstract_types +import test.fixtures.python_capi.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -28,7 +28,7 @@ import test.fixtures.python_capi.thrift_dep.thrift_mutable_types -@test.fixtures.python_capi.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -154,7 +154,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -203,7 +203,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@test.fixtures.python_capi.module.thrift_abstract_types.TransitiveDoubler.register +@_fbthrift_abstract_types.TransitiveDoubler.register class TransitiveDoubler(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -241,7 +241,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TransitiveDoubler, self) -@test.fixtures.python_capi.module.thrift_abstract_types.DoubledPair.register +@_fbthrift_abstract_types.DoubledPair.register class DoubledPair(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -301,7 +301,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DoubledPair, self) -@test.fixtures.python_capi.module.thrift_abstract_types.StringPair.register +@_fbthrift_abstract_types.StringPair.register class StringPair(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -361,7 +361,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.StringPair, self) -@test.fixtures.python_capi.module.thrift_abstract_types.EmptyStruct.register +@_fbthrift_abstract_types.EmptyStruct.register class EmptyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -399,7 +399,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.EmptyStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.PrimitiveStruct.register +@_fbthrift_abstract_types.PrimitiveStruct.register class PrimitiveStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -613,7 +613,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.PrimitiveStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.AdaptedFields.register +@_fbthrift_abstract_types.AdaptedFields.register class AdaptedFields(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -695,7 +695,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedFields, self) -@test.fixtures.python_capi.module.thrift_abstract_types.ListStruct.register +@_fbthrift_abstract_types.ListStruct.register class ListStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -832,7 +832,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ListStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.SetStruct.register +@_fbthrift_abstract_types.SetStruct.register class SetStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -947,7 +947,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SetStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.MapStruct.register +@_fbthrift_abstract_types.MapStruct.register class MapStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1095,7 +1095,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MapStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.ComposeStruct.register +@_fbthrift_abstract_types.ComposeStruct.register class ComposeStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1243,7 +1243,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComposeStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.Onion.register +@_fbthrift_abstract_types.Onion.register class Onion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1325,6 +1325,9 @@ class Onion(metaclass=_fbthrift_python_mutable_types.MutableUnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.Onion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.Onion" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.pyi index de88cde757f6c..8b19f1b280111 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_mutable_types.pyi @@ -696,16 +696,6 @@ class Onion(_fbthrift_python_mutable_types.MutableUnion, _fbthrift_compatible_wi ) -> None: ... - class FbThriftUnionFieldEnum(enum.Enum): - EMPTY: Onion.FbThriftUnionFieldEnum = ... - myEnum: Onion.FbThriftUnionFieldEnum = ... - myStruct: Onion.FbThriftUnionFieldEnum = ... - myString: Onion.FbThriftUnionFieldEnum = ... - intSet: Onion.FbThriftUnionFieldEnum = ... - doubleList: Onion.FbThriftUnionFieldEnum = ... - strMap: Onion.FbThriftUnionFieldEnum = ... - adapted_int: Onion.FbThriftUnionFieldEnum = ... - fbthrift_current_value: _typing.Final[_typing.Union[None, MyEnum, PrimitiveStruct, str, _fbthrift_python_mutable_containers.MutableSet[int], _fbthrift_python_mutable_containers.MutableList[float], _fbthrift_python_mutable_containers.MutableMap[bytes, str], int]] fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.py index 41ec9ec62c69e..9d8908eb35bdb 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.py @@ -8,7 +8,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import test.fixtures.python_capi.module.thrift_abstract_types +import test.fixtures.python_capi.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions @@ -22,7 +22,7 @@ import test.fixtures.python_capi.thrift_dep.thrift_types -@test.fixtures.python_capi.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -153,7 +153,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -207,7 +207,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@test.fixtures.python_capi.module.thrift_abstract_types.TransitiveDoubler.register +@_fbthrift_abstract_types.TransitiveDoubler.register class TransitiveDoubler(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -250,7 +250,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TransitiveDoubler, self) -@test.fixtures.python_capi.module.thrift_abstract_types.DoubledPair.register +@_fbthrift_abstract_types.DoubledPair.register class DoubledPair(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -315,7 +315,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DoubledPair, self) -@test.fixtures.python_capi.module.thrift_abstract_types.StringPair.register +@_fbthrift_abstract_types.StringPair.register class StringPair(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -380,7 +380,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.StringPair, self) -@test.fixtures.python_capi.module.thrift_abstract_types.EmptyStruct.register +@_fbthrift_abstract_types.EmptyStruct.register class EmptyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -423,7 +423,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.EmptyStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.PrimitiveStruct.register +@_fbthrift_abstract_types.PrimitiveStruct.register class PrimitiveStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -642,7 +642,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.PrimitiveStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.AdaptedFields.register +@_fbthrift_abstract_types.AdaptedFields.register class AdaptedFields(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -729,7 +729,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedFields, self) -@test.fixtures.python_capi.module.thrift_abstract_types.ListStruct.register +@_fbthrift_abstract_types.ListStruct.register class ListStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -871,7 +871,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ListStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.SetStruct.register +@_fbthrift_abstract_types.SetStruct.register class SetStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -991,7 +991,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.SetStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.MapStruct.register +@_fbthrift_abstract_types.MapStruct.register class MapStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1144,7 +1144,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MapStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.ComposeStruct.register +@_fbthrift_abstract_types.ComposeStruct.register class ComposeStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1297,7 +1297,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComposeStruct, self) -@test.fixtures.python_capi.module.thrift_abstract_types.Onion.register +@_fbthrift_abstract_types.Onion.register class Onion(metaclass=_fbthrift_python_types.UnionMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1379,6 +1379,9 @@ class Onion(metaclass=_fbthrift_python_types.UnionMeta): ), ) + _fbthrift_union_field_enum = _fbthrift_abstract_types.Onion.FbThriftUnionFieldEnum + + @staticmethod def __get_thrift_name__() -> str: return "module.Onion" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.pyi index aceacd687cdf0..a322db46e6769 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/python_capi/out/python_experimental_unify_thrift_python_type_hints/gen-python/test/fixtures/python_capi/module/thrift_types.pyi @@ -506,17 +506,7 @@ class Onion(_fbthrift_python_types.Union, _fbthrift_compatible_with_Onion, test. ) -> None: ... - class Type(enum.Enum): - EMPTY: Onion.Type = ... - myEnum: Onion.Type = ... - myStruct: Onion.Type = ... - myString: Onion.Type = ... - intSet: Onion.Type = ... - doubleList: Onion.Type = ... - strMap: Onion.Type = ... - adapted_int: Onion.Type = ... - - FbThriftUnionFieldEnum = Type + Type = FbThriftUnionFieldEnum @classmethod def fromValue(cls, value: _typing.Union[None, MyEnum, PrimitiveStruct, str, _typing.AbstractSet[int], _typing.Sequence[float], _typing.Mapping[bytes, str], int]) -> Onion: ... diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py index b2d9460d222d6..efc69a24eaa56 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -20,7 +20,7 @@ -@module.thrift_abstract_types.FooStreamEx.register +@_fbthrift_abstract_types.FooStreamEx.register class FooStreamEx(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -58,7 +58,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FooStreamEx, self) -@module.thrift_abstract_types.FooEx.register +@_fbthrift_abstract_types.FooEx.register class FooEx(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -96,7 +96,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FooEx, self) -@module.thrift_abstract_types.FooEx2.register +@_fbthrift_abstract_types.FooEx2.register class FooEx2(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta): _fbthrift_SPEC = ( ) diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py index 0afe237d97a3d..0aeca532f2364 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/python_experimental_unify_thrift_python_type_hints/gen-python/module/thrift_types.py @@ -8,13 +8,13 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import module.thrift_abstract_types +import module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions -@module.thrift_abstract_types.FooStreamEx.register +@_fbthrift_abstract_types.FooStreamEx.register class FooStreamEx(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -57,7 +57,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FooStreamEx, self) -@module.thrift_abstract_types.FooEx.register +@_fbthrift_abstract_types.FooEx.register class FooEx(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( ) @@ -100,7 +100,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.FooEx, self) -@module.thrift_abstract_types.FooEx2.register +@_fbthrift_abstract_types.FooEx2.register class FooEx2(metaclass=_fbthrift_python_exceptions.GeneratedErrorMeta): _fbthrift_SPEC = ( ) diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_mutable_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_mutable_types.py index f284a920b0c16..f3f15f043e507 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_mutable_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_mutable_types.py @@ -12,7 +12,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import apache.thrift.fixtures.types.module.thrift_abstract_types +import apache.thrift.fixtures.types.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.mutable_types as _fbthrift_python_mutable_types import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions @@ -22,7 +22,7 @@ import apache.thrift.fixtures.types.included.thrift_mutable_types -@apache.thrift.fixtures.types.module.thrift_abstract_types.empty_struct.register +@_fbthrift_abstract_types.empty_struct.register class empty_struct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -60,7 +60,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.empty_struct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.decorated_struct.register +@_fbthrift_abstract_types.decorated_struct.register class decorated_struct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -109,7 +109,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.decorated_struct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ContainerStruct.register +@_fbthrift_abstract_types.ContainerStruct.register class ContainerStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -235,7 +235,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ContainerStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CppTypeStruct.register +@_fbthrift_abstract_types.CppTypeStruct.register class CppTypeStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -284,7 +284,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CppTypeStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.VirtualStruct.register +@_fbthrift_abstract_types.VirtualStruct.register class VirtualStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -333,7 +333,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.VirtualStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyStructWithForwardRefEnum.register +@_fbthrift_abstract_types.MyStructWithForwardRefEnum.register class MyStructWithForwardRefEnum(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -393,7 +393,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructWithForwardRefEnum, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TrivialNumeric.register +@_fbthrift_abstract_types.TrivialNumeric.register class TrivialNumeric(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -453,7 +453,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TrivialNumeric, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TrivialNestedWithDefault.register +@_fbthrift_abstract_types.TrivialNestedWithDefault.register class TrivialNestedWithDefault(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -513,7 +513,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TrivialNestedWithDefault, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ComplexString.register +@_fbthrift_abstract_types.ComplexString.register class ComplexString(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -573,7 +573,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexString, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ComplexNestedWithDefault.register +@_fbthrift_abstract_types.ComplexNestedWithDefault.register class ComplexNestedWithDefault(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -633,7 +633,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexNestedWithDefault, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MinPadding.register +@_fbthrift_abstract_types.MinPadding.register class MinPadding(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -726,7 +726,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MinPadding, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MinPaddingWithCustomType.register +@_fbthrift_abstract_types.MinPaddingWithCustomType.register class MinPaddingWithCustomType(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -819,7 +819,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MinPaddingWithCustomType, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -901,7 +901,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -939,7 +939,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.Renaming.register +@_fbthrift_abstract_types.Renaming.register class Renaming(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -988,7 +988,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Renaming, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AnnotatedTypes.register +@_fbthrift_abstract_types.AnnotatedTypes.register class AnnotatedTypes(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1048,7 +1048,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AnnotatedTypes, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageRoot.register +@_fbthrift_abstract_types.ForwardUsageRoot.register class ForwardUsageRoot(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1108,7 +1108,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageRoot, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageStruct.register +@_fbthrift_abstract_types.ForwardUsageStruct.register class ForwardUsageStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1157,7 +1157,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageByRef.register +@_fbthrift_abstract_types.ForwardUsageByRef.register class ForwardUsageByRef(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1206,7 +1206,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageByRef, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteMap.register +@_fbthrift_abstract_types.IncompleteMap.register class IncompleteMap(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1255,7 +1255,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteMap, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteMapDep.register +@_fbthrift_abstract_types.IncompleteMapDep.register class IncompleteMapDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -1293,7 +1293,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteMapDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteMap.register +@_fbthrift_abstract_types.CompleteMap.register class CompleteMap(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1342,7 +1342,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteMap, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteMapDep.register +@_fbthrift_abstract_types.CompleteMapDep.register class CompleteMapDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -1380,7 +1380,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteMapDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteList.register +@_fbthrift_abstract_types.IncompleteList.register class IncompleteList(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1429,7 +1429,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteListDep.register +@_fbthrift_abstract_types.IncompleteListDep.register class IncompleteListDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -1467,7 +1467,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteList.register +@_fbthrift_abstract_types.CompleteList.register class CompleteList(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1516,7 +1516,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteListDep.register +@_fbthrift_abstract_types.CompleteListDep.register class CompleteListDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( ) @@ -1554,7 +1554,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AdaptedList.register +@_fbthrift_abstract_types.AdaptedList.register class AdaptedList(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1603,7 +1603,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AdaptedListDep.register +@_fbthrift_abstract_types.AdaptedListDep.register class AdaptedListDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1652,7 +1652,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.DependentAdaptedList.register +@_fbthrift_abstract_types.DependentAdaptedList.register class DependentAdaptedList(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1701,7 +1701,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DependentAdaptedList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.DependentAdaptedListDep.register +@_fbthrift_abstract_types.DependentAdaptedListDep.register class DependentAdaptedListDep(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1750,7 +1750,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DependentAdaptedListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AllocatorAware.register +@_fbthrift_abstract_types.AllocatorAware.register class AllocatorAware(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1865,7 +1865,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AllocatorAware, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AllocatorAware2.register +@_fbthrift_abstract_types.AllocatorAware2.register class AllocatorAware2(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1925,7 +1925,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AllocatorAware2, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TypedefStruct.register +@_fbthrift_abstract_types.TypedefStruct.register class TypedefStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1996,7 +1996,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TypedefStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.StructWithDoubleUnderscores.register +@_fbthrift_abstract_types.StructWithDoubleUnderscores.register class StructWithDoubleUnderscores(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_types.py b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_types.py index 11e4269626d69..7a20218d2d5d1 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_types.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/python_experimental_unify_thrift_python_type_hints/gen-python/apache/thrift/fixtures/types/module/thrift_types.py @@ -8,7 +8,7 @@ from __future__ import annotations import folly.iobuf as _fbthrift_iobuf -import apache.thrift.fixtures.types.module.thrift_abstract_types +import apache.thrift.fixtures.types.module.thrift_abstract_types as _fbthrift_abstract_types import thrift.python.types as _fbthrift_python_types import thrift.python.exceptions as _fbthrift_python_exceptions @@ -16,7 +16,7 @@ import apache.thrift.fixtures.types.included.thrift_types -@apache.thrift.fixtures.types.module.thrift_abstract_types.empty_struct.register +@_fbthrift_abstract_types.empty_struct.register class empty_struct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -59,7 +59,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.empty_struct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.decorated_struct.register +@_fbthrift_abstract_types.decorated_struct.register class decorated_struct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -113,7 +113,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.decorated_struct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ContainerStruct.register +@_fbthrift_abstract_types.ContainerStruct.register class ContainerStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -244,7 +244,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ContainerStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CppTypeStruct.register +@_fbthrift_abstract_types.CppTypeStruct.register class CppTypeStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -298,7 +298,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CppTypeStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.VirtualStruct.register +@_fbthrift_abstract_types.VirtualStruct.register class VirtualStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -352,7 +352,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.VirtualStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyStructWithForwardRefEnum.register +@_fbthrift_abstract_types.MyStructWithForwardRefEnum.register class MyStructWithForwardRefEnum(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -417,7 +417,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStructWithForwardRefEnum, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TrivialNumeric.register +@_fbthrift_abstract_types.TrivialNumeric.register class TrivialNumeric(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -482,7 +482,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TrivialNumeric, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TrivialNestedWithDefault.register +@_fbthrift_abstract_types.TrivialNestedWithDefault.register class TrivialNestedWithDefault(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -547,7 +547,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TrivialNestedWithDefault, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ComplexString.register +@_fbthrift_abstract_types.ComplexString.register class ComplexString(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -612,7 +612,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexString, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ComplexNestedWithDefault.register +@_fbthrift_abstract_types.ComplexNestedWithDefault.register class ComplexNestedWithDefault(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -677,7 +677,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ComplexNestedWithDefault, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MinPadding.register +@_fbthrift_abstract_types.MinPadding.register class MinPadding(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -775,7 +775,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MinPadding, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MinPaddingWithCustomType.register +@_fbthrift_abstract_types.MinPaddingWithCustomType.register class MinPaddingWithCustomType(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -873,7 +873,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MinPaddingWithCustomType, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyStruct.register +@_fbthrift_abstract_types.MyStruct.register class MyStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -960,7 +960,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.MyDataItem.register +@_fbthrift_abstract_types.MyDataItem.register class MyDataItem(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1003,7 +1003,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.MyDataItem, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.Renaming.register +@_fbthrift_abstract_types.Renaming.register class Renaming(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1057,7 +1057,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.Renaming, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AnnotatedTypes.register +@_fbthrift_abstract_types.AnnotatedTypes.register class AnnotatedTypes(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1122,7 +1122,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AnnotatedTypes, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageRoot.register +@_fbthrift_abstract_types.ForwardUsageRoot.register class ForwardUsageRoot(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1187,7 +1187,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageRoot, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageStruct.register +@_fbthrift_abstract_types.ForwardUsageStruct.register class ForwardUsageStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1241,7 +1241,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.ForwardUsageByRef.register +@_fbthrift_abstract_types.ForwardUsageByRef.register class ForwardUsageByRef(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1295,7 +1295,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.ForwardUsageByRef, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteMap.register +@_fbthrift_abstract_types.IncompleteMap.register class IncompleteMap(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1349,7 +1349,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteMap, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteMapDep.register +@_fbthrift_abstract_types.IncompleteMapDep.register class IncompleteMapDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1392,7 +1392,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteMapDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteMap.register +@_fbthrift_abstract_types.CompleteMap.register class CompleteMap(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1446,7 +1446,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteMap, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteMapDep.register +@_fbthrift_abstract_types.CompleteMapDep.register class CompleteMapDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1489,7 +1489,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteMapDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteList.register +@_fbthrift_abstract_types.IncompleteList.register class IncompleteList(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1543,7 +1543,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.IncompleteListDep.register +@_fbthrift_abstract_types.IncompleteListDep.register class IncompleteListDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1586,7 +1586,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.IncompleteListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteList.register +@_fbthrift_abstract_types.CompleteList.register class CompleteList(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1640,7 +1640,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.CompleteListDep.register +@_fbthrift_abstract_types.CompleteListDep.register class CompleteListDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( ) @@ -1683,7 +1683,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.CompleteListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AdaptedList.register +@_fbthrift_abstract_types.AdaptedList.register class AdaptedList(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1737,7 +1737,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AdaptedListDep.register +@_fbthrift_abstract_types.AdaptedListDep.register class AdaptedListDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1791,7 +1791,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AdaptedListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.DependentAdaptedList.register +@_fbthrift_abstract_types.DependentAdaptedList.register class DependentAdaptedList(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1845,7 +1845,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DependentAdaptedList, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.DependentAdaptedListDep.register +@_fbthrift_abstract_types.DependentAdaptedListDep.register class DependentAdaptedListDep(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -1899,7 +1899,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.DependentAdaptedListDep, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AllocatorAware.register +@_fbthrift_abstract_types.AllocatorAware.register class AllocatorAware(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -2019,7 +2019,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AllocatorAware, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.AllocatorAware2.register +@_fbthrift_abstract_types.AllocatorAware2.register class AllocatorAware2(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -2084,7 +2084,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.AllocatorAware2, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.TypedefStruct.register +@_fbthrift_abstract_types.TypedefStruct.register class TypedefStruct(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( @@ -2160,7 +2160,7 @@ def _to_py_deprecated(self): return thrift.util.converter.to_py_struct(py_asyncio_types.TypedefStruct, self) -@apache.thrift.fixtures.types.module.thrift_abstract_types.StructWithDoubleUnderscores.register +@_fbthrift_abstract_types.StructWithDoubleUnderscores.register class StructWithDoubleUnderscores(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( _fbthrift_python_types.FieldInfo( diff --git a/third-party/thrift/src/thrift/lib/python/mutable_types.pyx b/third-party/thrift/src/thrift/lib/python/mutable_types.pyx index c2d70bd1b9a59..38e8cc96d58a9 100644 --- a/third-party/thrift/src/thrift/lib/python/mutable_types.pyx +++ b/third-party/thrift/src/thrift/lib/python/mutable_types.pyx @@ -1197,9 +1197,10 @@ class MutableUnionMeta(type): union_name, field_infos ) - union_class_namespace["FbThriftUnionFieldEnum"] = enum.Enum( - f"{union_name}", - _gen_mutable_union_field_enum_members(field_infos) + union_class_namespace["FbThriftUnionFieldEnum"] = ( + union_class_namespace.pop('_fbthrift_union_field_enum') + if "_fbthrift_union_field_enum" in union_class_namespace + else enum.Enum(f"{union_name}", _gen_mutable_union_field_enum_members(field_infos)) ) slots = [field_info.py_name for field_info in field_infos] diff --git a/third-party/thrift/src/thrift/lib/python/types.pyx b/third-party/thrift/src/thrift/lib/python/types.pyx index bdbd12c395133..9ad17c197d544 100644 --- a/third-party/thrift/src/thrift/lib/python/types.pyx +++ b/third-party/thrift/src/thrift/lib/python/types.pyx @@ -1800,7 +1800,13 @@ class UnionMeta(type): field_info.py_name, _make_fget_union(field_info.id, field_info.adapter_info), ) - FbThriftUnionFieldEnum = enum.Enum(union_name, _gen_union_field_enum_members(field_infos)) + + FbThriftUnionFieldEnum = ( + union_class_namespace.pop('_fbthrift_union_field_enum') + if "_fbthrift_union_field_enum" in union_class_namespace + else enum.Enum(union_name, _gen_union_field_enum_members(field_infos)) + ) + type.__setattr__( klass, "FbThriftUnionFieldEnum", @@ -1811,6 +1817,7 @@ class UnionMeta(type): "Type", FbThriftUnionFieldEnum, ) + return klass def __dir__(cls): diff --git a/third-party/thrift/src/thrift/test/thrift-python/abstract_types_test.py b/third-party/thrift/src/thrift/test/thrift-python/abstract_types_test.py index 088232b3b6c75..a448cc4edcb89 100644 --- a/third-party/thrift/src/thrift/test/thrift-python/abstract_types_test.py +++ b/third-party/thrift/src/thrift/test/thrift-python/abstract_types_test.py @@ -666,3 +666,43 @@ def test_to_py_deprecated(self) -> None: # Rather than pull in py-deprecated types, just check that the method exists. self.assertTrue(hasattr(TestStructAbstract, "_to_py_deprecated")) self.assertTrue(hasattr(TestUnionAbstract, "_to_py_deprecated")) + + @parameterized.expand( + [ + ( + "immutable_union", + TestUnionImmutable(), + TestUnionImmutable(string_field="Hello, world!"), + ), + ( + "mutable_union", + TestUnionMutable(), + TestUnionMutable(string_field="Hello, world!"), + ), + ], + ) + def test_create_union( + self, + test_name: str, + empty_union: TestUnionAbstract, + string_field_union: TestUnionAbstract, + ) -> None: + self.assertEqual( + empty_union.fbthrift_current_field, + TestUnionAbstract.FbThriftUnionFieldEnum.EMPTY, + ) + self.assertIsNone(empty_union.fbthrift_current_value) + with self.assertRaises(AttributeError): + empty_union.string_field + + self.assertIs( + string_field_union.fbthrift_current_field, + TestUnionMutable.FbThriftUnionFieldEnum.string_field, + ) + self.assertEqual(string_field_union.fbthrift_current_value, "Hello, world!") + self.assertEqual(string_field_union.string_field, "Hello, world!") + # Trying to access any other field should raise an error. + with self.assertRaises( + AttributeError, + ): + string_field_union.int_field