From 11b6422e3f73639d8e01af034feb0effea13dfa0 Mon Sep 17 00:00:00 2001 From: Satish Kumar Date: Wed, 27 Nov 2024 21:41:13 -0800 Subject: [PATCH] Use unified thrift enums with thrift-python abstract types Summary: # TL;DR Provide a single identity for enums in a thrift schema through a .thrift_enums module. # Problem Statement With the introduction of thrift mutable types (`.thrift_mutable_types`) and thrift abstract types (`.thrift_abstract_types`), along with current thrift types (`.thrift_types`), which are immutable there are three different flavors of types for a given thrift schema. Enums are just enums and are neither mutable nor abstract. This implies enums should have a single identity irrespective of whether they are from `.thrift_abstract_types`, `.thrift_types`, or `.thrift_mutable_types`. # Solution To capture this nature of enums, create a single identity for thrift enums via a `.thrift_enums` module and refer to that from the other python flavors. # Current diff This diff uses the enums from `.thrift_enums` with abstract types in `.thrift_abstract_types`. Reviewed By: Filip-F Differential Revision: D66421089 fbshipit-source-id: c93835067c79c52775ce20c98dafe8b0cca84537 --- .../python/thrift_abstract_types.py.mustache | 6 +-- .../templates/python/thrift_enums.py.mustache | 14 ++++++- .../python/thrift_enums.pyi.mustache | 8 +--- .../python/types/import_enums.mustache | 30 +++++++++++++ .../templates/python/types/types_pyi.mustache | 14 +------ .../fixtures/basic/module/thrift_enums.py | 12 +++++- .../basic/module/thrift_abstract_types.py | 9 ++-- .../fixtures/basic/module/thrift_enums.py | 12 +++++- .../fixtures/basic/module/thrift_enums.pyi | 5 +-- .../fixtures/basic/module/thrift_types.pyi | 4 +- .../fixtures/basic/module/thrift_enums.py | 12 +++++- .../python/gen-python/module/thrift_enums.py | 6 ++- .../module/thrift_abstract_types.py | 5 +-- .../gen-python/module/thrift_enums.py | 6 ++- .../gen-python/module/thrift_enums.pyi | 3 +- .../gen-python/module/thrift_types.pyi | 2 +- .../gen-python/module/thrift_enums.py | 6 ++- .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../python/gen-python/module/thrift_enums.py | 18 ++++++-- .../module/thrift_abstract_types.py | 13 ++---- .../gen-python/module/thrift_enums.py | 18 ++++++-- .../gen-python/module/thrift_enums.pyi | 7 ++-- .../gen-python/module/thrift_types.pyi | 6 +-- .../gen-python/module/thrift_enums.py | 18 ++++++-- .../fixtures/enums/module/thrift_enums.py | 42 +++++++++++++++---- .../enums/module/thrift_abstract_types.py | 31 ++++---------- .../fixtures/enums/module/thrift_enums.py | 42 +++++++++++++++---- .../fixtures/enums/module/thrift_enums.pyi | 15 ++++--- .../fixtures/enums/module/thrift_types.pyi | 14 +++---- .../fixtures/enums/module/thrift_enums.py | 42 +++++++++++++++---- .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../interactions/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../module/thrift_enums.pyi | 1 - .../module/thrift_abstract_types.py | 1 + .../module/thrift_enums.pyi | 1 - .../python/gen-python/module/thrift_enums.py | 18 ++++++-- .../gen-python/module/thrift_enums.py | 18 ++++++-- .../python_capi/module/thrift_enums.py | 12 +++++- .../module/thrift_abstract_types.py | 9 ++-- .../python_capi/module/thrift_enums.py | 12 +++++- .../python_capi/module/thrift_enums.pyi | 5 +-- .../python_capi/module/thrift_types.pyi | 4 +- .../python_capi/module/thrift_enums.py | 12 +++++- .../python/gen-python/module/thrift_enums.py | 6 ++- .../gen-python/module/thrift_enums.py | 6 ++- .../module/thrift_abstract_types.py | 1 + .../gen-python/module/thrift_enums.pyi | 1 - .../fixtures/types/module/thrift_enums.py | 18 ++++++-- .../types/module/thrift_abstract_types.py | 13 ++---- .../fixtures/types/module/thrift_enums.py | 18 ++++++-- .../fixtures/types/module/thrift_enums.pyi | 7 ++-- .../fixtures/types/module/thrift_types.pyi | 6 +-- .../fixtures/types/module/thrift_enums.py | 18 ++++++-- .../test/thrift-python/abstract_types_test.py | 15 +++++++ 66 files changed, 442 insertions(+), 195 deletions(-) create mode 100644 thrift/compiler/generate/templates/python/types/import_enums.mustache diff --git a/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache b/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache index e42476f20bb..4c0f4af012e 100644 --- a/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache +++ b/thrift/compiler/generate/templates/python/thrift_abstract_types.py.mustache @@ -49,11 +49,7 @@ import {{included_module_path}}.thrift_abstract_types as {{included_module_mangl import {{module_path}} {{/program:adapter_type_hint_modules}} -{{#program:enums}} -class {{enum:name}}: - pass - -{{/program:enums}} +{{> types/import_enums}} {{#program:structs}} class {{> structs/unadapted_name}}({{! diff --git a/thrift/compiler/generate/templates/python/thrift_enums.py.mustache b/thrift/compiler/generate/templates/python/thrift_enums.py.mustache index 93b2223fed9..9dab6697dfe 100644 --- a/thrift/compiler/generate/templates/python/thrift_enums.py.mustache +++ b/thrift/compiler/generate/templates/python/thrift_enums.py.mustache @@ -23,9 +23,21 @@ import {{program:base_library_package}}.types as _fbthrift_python_types import {{program:module_path}}.thrift_metadata {{#program:enums}} +{{! + thrift_enums.pyi already defines class _fbthrift_compatible_with_.... + This is necessary in the thrift_enums.py file as well because + thrift_abstract_types.py imports this (see a generated file for reference), + and .py files only import symbols from .py files. +}} +class _fbthrift_compatible_with_{{enum:name}}: + pass + + class {{enum:name}}(_fbthrift_python_types.{{! }}{{#enum:flags?}}Flag{{/enum:flags?}}{{! - }}{{^enum:flags?}}Enum, int{{/enum:flags?}}): + }}{{^enum:flags?}}Enum, int{{/enum:flags?}}{{! + }}, _fbthrift_compatible_with_{{enum:name}}{{! + }}): {{#enum:values}} {{enum_value:py_name}} = {{enum_value:value}} {{/enum:values}} diff --git a/thrift/compiler/generate/templates/python/thrift_enums.pyi.mustache b/thrift/compiler/generate/templates/python/thrift_enums.pyi.mustache index 9c5eb2ed4f2..138b670d012 100644 --- a/thrift/compiler/generate/templates/python/thrift_enums.pyi.mustache +++ b/thrift/compiler/generate/templates/python/thrift_enums.pyi.mustache @@ -20,10 +20,7 @@ Generated Python typestubs for Thrift enums {{> common/auto_generated_py}} import {{program:base_library_package}}.types as _fbthrift_python_types -{{#program:enable_abstract_types?}} -import {{program:module_path}}.thrift_abstract_types -{{/program:enable_abstract_types?}}{{! -}}{{#program:enums}} +{{#program:enums}} class _fbthrift_compatible_with_{{enum:name}}: pass @@ -32,9 +29,6 @@ class _fbthrift_compatible_with_{{enum:name}}: class {{enum:name}}(_fbthrift_python_types.{{! }}{{#enum:flags?}}Flag{{/enum:flags?}}{{! }}{{^enum:flags?}}Enum, int{{/enum:flags?}}{{! - }}{{#program:enable_abstract_types?}}{{! - }}, {{program:module_path}}.thrift_abstract_types.{{enum:name}}{{! - }}{{/program:enable_abstract_types?}}{{! }}, _fbthrift_compatible_with_{{enum:name}}): {{#enum:values}} {{enum_value:py_name}}: {{enum:name}} = ... diff --git a/thrift/compiler/generate/templates/python/types/import_enums.mustache b/thrift/compiler/generate/templates/python/types/import_enums.mustache new file mode 100644 index 00000000000..bb6b1480df3 --- /dev/null +++ b/thrift/compiler/generate/templates/python/types/import_enums.mustache @@ -0,0 +1,30 @@ +{{! + + Copyright (c) Meta Platforms, Inc. and affiliates. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +}}{{! + Import enums into the modules that reference enums. +}} +{{! + from module_path.thrift_enums import * + +below does not import private symbols _fbthrift_compatible_with_*. +These are referenced in the generated pyi files and, for simplicity, +need to be imported through the types modules. +}}{{#program:enums}} +from {{program:module_path}}.thrift_enums import _fbthrift_compatible_with_{{enum:name}} +{{/program:enums}} + +from {{program:module_path}}.thrift_enums import * diff --git a/thrift/compiler/generate/templates/python/types/types_pyi.mustache b/thrift/compiler/generate/templates/python/types/types_pyi.mustache index 141db8137c5..2b3ea4fd152 100644 --- a/thrift/compiler/generate/templates/python/types/types_pyi.mustache +++ b/thrift/compiler/generate/templates/python/types/types_pyi.mustache @@ -57,9 +57,6 @@ class _fbthrift_compatible_with_{{enum:name}}: class {{enum:name}}(_fbthrift_python_types.{{! }}{{#enum:flags?}}Flag{{/enum:flags?}}{{! }}{{^enum:flags?}}Enum, int{{/enum:flags?}}{{! - }}{{#program:enable_abstract_types?}}{{! - }}, _fbthrift_python_abstract_types.{{enum:name}}{{! - }}{{/program:enable_abstract_types?}}{{! }}, _fbthrift_compatible_with_{{enum:name}}): {{#enum:values}} {{enum_value:py_name}}: {{enum:name}} = ... @@ -72,17 +69,8 @@ class {{enum:name}}(_fbthrift_python_types.{{! {{/program:enums}} {{/program:generate_immutable_types}} {{#program:generate_mutable_types}} -{{! - from module_path.thrift_enums import * - -below does not import private symbols _fbthrift_compatible_with_*. -These are referenced in the generated pyi files and, for simplicity, -need to be imported through the types modules. -}}{{#program:enums}} -from {{program:module_path}}.thrift_enums import _fbthrift_compatible_with_{{enum:name}} -{{/program:enums}} +{{> types/import_enums}} -from {{program:module_path}}.thrift_enums import * {{/program:generate_mutable_types}} {{#program:structs}} diff --git a/thrift/compiler/test/fixtures/basic/out/python/gen-python/test/fixtures/basic/module/thrift_enums.py b/thrift/compiler/test/fixtures/basic/out/python/gen-python/test/fixtures/basic/module/thrift_enums.py index 539aa908a3b..c3634745e8b 100644 --- a/thrift/compiler/test/fixtures/basic/out/python/gen-python/test/fixtures/basic/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/basic/out/python/gen-python/test/fixtures/basic/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.basic.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class HackEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_HackEnum: + pass + + +class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_HackEnum): Value1 = 0 Value2 = 1 @staticmethod diff --git a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_abstract_types.py index eadd994fbff..aa30ebf95ee 100644 --- a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_abstract_types.py @@ -22,13 +22,10 @@ import folly.iobuf as _fbthrift_iobuf import thrift.python.abstract_types as _fbthrift_python_abstract_types -class MyEnum: - pass - -class HackEnum: - pass - +from test.fixtures.basic.module.thrift_enums import _fbthrift_compatible_with_MyEnum +from test.fixtures.basic.module.thrift_enums import _fbthrift_compatible_with_HackEnum +from test.fixtures.basic.module.thrift_enums import * class MyStruct(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.py b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.py index 539aa908a3b..c3634745e8b 100644 --- a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.basic.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class HackEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_HackEnum: + pass + + +class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_HackEnum): Value1 = 0 Value2 = 1 @staticmethod diff --git a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.pyi index 12c6979ee91..55bda9efb64 100644 --- a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.fixtures.basic.module.thrift_abstract_types class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, test.fixtures.basic.module.thrift_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... def _to_python(self) -> MyEnum: ... @@ -25,7 +24,7 @@ class _fbthrift_compatible_with_HackEnum: pass -class HackEnum(_fbthrift_python_types.Enum, int, test.fixtures.basic.module.thrift_abstract_types.HackEnum, _fbthrift_compatible_with_HackEnum): +class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_HackEnum): Value1: HackEnum = ... Value2: HackEnum = ... def _to_python(self) -> HackEnum: ... diff --git a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_types.pyi b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_types.pyi index f5e6cc7a804..b24f8a97ef5 100644 --- a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/basic/module/thrift_types.pyi @@ -20,7 +20,7 @@ class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... def _to_python(self) -> MyEnum: ... @@ -31,7 +31,7 @@ class _fbthrift_compatible_with_HackEnum: pass -class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.HackEnum, _fbthrift_compatible_with_HackEnum): +class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_HackEnum): Value1: HackEnum = ... Value2: HackEnum = ... def _to_python(self) -> HackEnum: ... diff --git a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/basic/module/thrift_enums.py b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/basic/module/thrift_enums.py index 539aa908a3b..c3634745e8b 100644 --- a/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/basic/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/basic/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/basic/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.basic.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class HackEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_HackEnum: + pass + + +class HackEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_HackEnum): Value1 = 0 Value2 = 1 @staticmethod diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/complex-struct/out/python/gen-python/module/thrift_enums.py index a158466994f..eee19521b4e 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/complex-struct/out/python/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 MyValue3 = 3 diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 2f7b0ed19d5..7f34b159ee4 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -22,10 +22,9 @@ import folly.iobuf as _fbthrift_iobuf import thrift.python.abstract_types as _fbthrift_python_abstract_types -class MyEnum: - pass - +from module.thrift_enums import _fbthrift_compatible_with_MyEnum +from module.thrift_enums import * class MyStructFloatFieldThrowExp(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py index a158466994f..eee19521b4e 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 MyValue3 = 3 diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 411d4f1cd26..5a176541e6e 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, module.thrift_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... MyValue3: MyEnum = ... diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi index c3e97e8e2f1..5f2afc9ba68 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi @@ -20,7 +20,7 @@ class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... MyValue3: MyEnum = ... diff --git a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py index a158466994f..eee19521b4e 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/complex-struct/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 MyValue3 = 3 diff --git a/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 23a856a7884..5ff8269b812 100644 --- a/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -23,6 +23,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from module.thrift_enums import * class ComplexUnion(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/complex-union/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/constants/out/python/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/constants/out/python/gen-python/module/thrift_enums.py index 866345e804f..e94e2f3ff96 100644 --- a/thrift/compiler/test/fixtures/constants/out/python/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/constants/out/python/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class EmptyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_EmptyEnum: + pass + + +class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_EmptyEnum): @staticmethod def __get_thrift_name__() -> str: return "module.EmptyEnum" @@ -34,7 +38,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class City(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_City: + pass + + +class City(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_City): NYC = 0 MPK = 1 SEA = 2 @@ -62,7 +70,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class Company(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Company: + pass + + +class Company(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Company): FACEBOOK = 0 WHATSAPP = 1 OCULUS = 2 diff --git a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 3b3a3b11d9b..d921d6d9eaa 100644 --- a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -22,16 +22,11 @@ import folly.iobuf as _fbthrift_iobuf import thrift.python.abstract_types as _fbthrift_python_abstract_types -class EmptyEnum: - pass - -class City: - pass - -class Company: - pass - +from module.thrift_enums import _fbthrift_compatible_with_EmptyEnum +from module.thrift_enums import _fbthrift_compatible_with_City +from module.thrift_enums import _fbthrift_compatible_with_Company +from module.thrift_enums import * class Internship(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py index 866345e804f..e94e2f3ff96 100644 --- a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class EmptyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_EmptyEnum: + pass + + +class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_EmptyEnum): @staticmethod def __get_thrift_name__() -> str: return "module.EmptyEnum" @@ -34,7 +38,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class City(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_City: + pass + + +class City(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_City): NYC = 0 MPK = 1 SEA = 2 @@ -62,7 +70,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class Company(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Company: + pass + + +class Company(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Company): FACEBOOK = 0 WHATSAPP = 1 OCULUS = 2 diff --git a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 4b6931a470b..678f67a4376 100644 --- a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types class _fbthrift_compatible_with_EmptyEnum: pass -class EmptyEnum(_fbthrift_python_types.Enum, int, module.thrift_abstract_types.EmptyEnum, _fbthrift_compatible_with_EmptyEnum): +class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_EmptyEnum): def _to_python(self) -> EmptyEnum: ... def _to_py3(self) -> "module.types.EmptyEnum": ... # type: ignore def _to_py_deprecated(self) -> int: ... @@ -23,7 +22,7 @@ class _fbthrift_compatible_with_City: pass -class City(_fbthrift_python_types.Enum, int, module.thrift_abstract_types.City, _fbthrift_compatible_with_City): +class City(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_City): NYC: City = ... MPK: City = ... SEA: City = ... @@ -36,7 +35,7 @@ class _fbthrift_compatible_with_Company: pass -class Company(_fbthrift_python_types.Enum, int, module.thrift_abstract_types.Company, _fbthrift_compatible_with_Company): +class Company(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Company): FACEBOOK: Company = ... WHATSAPP: Company = ... OCULUS: Company = ... diff --git a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi index 38af79dd114..c6581781464 100644 --- a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_abstract_types/gen-python/module/thrift_types.pyi @@ -20,7 +20,7 @@ class _fbthrift_compatible_with_EmptyEnum: pass -class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.EmptyEnum, _fbthrift_compatible_with_EmptyEnum): +class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_EmptyEnum): def _to_python(self) -> EmptyEnum: ... def _to_py3(self) -> "module.types.EmptyEnum": ... # type: ignore def _to_py_deprecated(self) -> int: ... @@ -29,7 +29,7 @@ class _fbthrift_compatible_with_City: pass -class City(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.City, _fbthrift_compatible_with_City): +class City(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_City): NYC: City = ... MPK: City = ... SEA: City = ... @@ -42,7 +42,7 @@ class _fbthrift_compatible_with_Company: pass -class Company(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.Company, _fbthrift_compatible_with_Company): +class Company(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Company): FACEBOOK: Company = ... WHATSAPP: Company = ... OCULUS: Company = ... diff --git a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py index 866345e804f..e94e2f3ff96 100644 --- a/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/constants/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class EmptyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_EmptyEnum: + pass + + +class EmptyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_EmptyEnum): @staticmethod def __get_thrift_name__() -> str: return "module.EmptyEnum" @@ -34,7 +38,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class City(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_City: + pass + + +class City(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_City): NYC = 0 MPK = 1 SEA = 2 @@ -62,7 +70,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class Company(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Company: + pass + + +class Company(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Company): FACEBOOK = 0 WHATSAPP = 1 OCULUS = 2 diff --git a/thrift/compiler/test/fixtures/enums/out/python/gen-python/test/fixtures/enums/module/thrift_enums.py b/thrift/compiler/test/fixtures/enums/out/python/gen-python/test/fixtures/enums/module/thrift_enums.py index 63a66cbdb66..a75a6f633e6 100644 --- a/thrift/compiler/test/fixtures/enums/out/python/gen-python/test/fixtures/enums/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/enums/out/python/gen-python/test/fixtures/enums/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.enums.module.thrift_metadata -class Metasyntactic(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Metasyntactic: + pass + + +class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Metasyntactic): FOO = 1 BAR = 2 BAZ = 3 @@ -38,7 +42,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum1: + pass + + +class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum1): ME1_0 = 0 ME1_1 = 1 ME1_2 = 2 @@ -68,7 +76,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum2: + pass + + +class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum2): ME2_0 = 0 ME2_1 = 1 ME2_2 = 2 @@ -95,7 +107,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum3(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum3: + pass + + +class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum3): ME3_0 = 0 ME3_1 = 1 ME3_N2 = -2 @@ -125,7 +141,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum4(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum4: + pass + + +class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum4): ME4_A = 2147483645 ME4_B = 2147483646 ME4_C = 2147483647 @@ -153,7 +173,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum1: + pass + + +class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum1): ONE = 1 TWO = 2 FOUR = 4 @@ -180,7 +204,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum2: + pass + + +class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum2): ONE = 1 TWO = 2 FOUR = 4 diff --git a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_abstract_types.py index 83e3ae73658..4ee16955df5 100644 --- a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_abstract_types.py @@ -20,28 +20,15 @@ import folly.iobuf as _fbthrift_iobuf import thrift.python.abstract_types as _fbthrift_python_abstract_types -class Metasyntactic: - pass - -class MyEnum1: - pass - -class MyEnum2: - pass - -class MyEnum3: - pass - -class MyEnum4: - pass - -class MyBitmaskEnum1: - pass - -class MyBitmaskEnum2: - pass - - +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_Metasyntactic +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyEnum1 +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyEnum2 +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyEnum3 +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyEnum4 +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyBitmaskEnum1 +from test.fixtures.enums.module.thrift_enums import _fbthrift_compatible_with_MyBitmaskEnum2 + +from test.fixtures.enums.module.thrift_enums import * class SomeStruct(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.py b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.py index 63a66cbdb66..a75a6f633e6 100644 --- a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.enums.module.thrift_metadata -class Metasyntactic(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Metasyntactic: + pass + + +class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Metasyntactic): FOO = 1 BAR = 2 BAZ = 3 @@ -38,7 +42,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum1: + pass + + +class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum1): ME1_0 = 0 ME1_1 = 1 ME1_2 = 2 @@ -68,7 +76,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum2: + pass + + +class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum2): ME2_0 = 0 ME2_1 = 1 ME2_2 = 2 @@ -95,7 +107,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum3(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum3: + pass + + +class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum3): ME3_0 = 0 ME3_1 = 1 ME3_N2 = -2 @@ -125,7 +141,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum4(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum4: + pass + + +class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum4): ME4_A = 2147483645 ME4_B = 2147483646 ME4_C = 2147483647 @@ -153,7 +173,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum1: + pass + + +class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum1): ONE = 1 TWO = 2 FOUR = 4 @@ -180,7 +204,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum2: + pass + + +class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum2): ONE = 1 TWO = 2 FOUR = 4 diff --git a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.pyi index 61653b7dc7a..2d2b9a5deb8 100644 --- a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.fixtures.enums.module.thrift_abstract_types class _fbthrift_compatible_with_Metasyntactic: pass -class Metasyntactic(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.Metasyntactic, _fbthrift_compatible_with_Metasyntactic): +class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Metasyntactic): FOO: Metasyntactic = ... BAR: Metasyntactic = ... BAZ: Metasyntactic = ... @@ -27,7 +26,7 @@ class _fbthrift_compatible_with_MyEnum1: pass -class MyEnum1(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyEnum1, _fbthrift_compatible_with_MyEnum1): +class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum1): ME1_0: MyEnum1 = ... ME1_1: MyEnum1 = ... ME1_2: MyEnum1 = ... @@ -42,7 +41,7 @@ class _fbthrift_compatible_with_MyEnum2: pass -class MyEnum2(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyEnum2, _fbthrift_compatible_with_MyEnum2): +class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum2): ME2_0: MyEnum2 = ... ME2_1: MyEnum2 = ... ME2_2: MyEnum2 = ... @@ -54,7 +53,7 @@ class _fbthrift_compatible_with_MyEnum3: pass -class MyEnum3(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyEnum3, _fbthrift_compatible_with_MyEnum3): +class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum3): ME3_0: MyEnum3 = ... ME3_1: MyEnum3 = ... ME3_N2: MyEnum3 = ... @@ -69,7 +68,7 @@ class _fbthrift_compatible_with_MyEnum4: pass -class MyEnum4(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyEnum4, _fbthrift_compatible_with_MyEnum4): +class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum4): ME4_A: MyEnum4 = ... ME4_B: MyEnum4 = ... ME4_C: MyEnum4 = ... @@ -82,7 +81,7 @@ class _fbthrift_compatible_with_MyBitmaskEnum1: pass -class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyBitmaskEnum1, _fbthrift_compatible_with_MyBitmaskEnum1): +class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum1): ONE: MyBitmaskEnum1 = ... TWO: MyBitmaskEnum1 = ... FOUR: MyBitmaskEnum1 = ... @@ -94,7 +93,7 @@ class _fbthrift_compatible_with_MyBitmaskEnum2: pass -class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, test.fixtures.enums.module.thrift_abstract_types.MyBitmaskEnum2, _fbthrift_compatible_with_MyBitmaskEnum2): +class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum2): ONE: MyBitmaskEnum2 = ... TWO: MyBitmaskEnum2 = ... FOUR: MyBitmaskEnum2 = ... diff --git a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_types.pyi b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_types.pyi index c01b361f9a6..ce64fc72314 100644 --- a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/enums/module/thrift_types.pyi @@ -18,7 +18,7 @@ class _fbthrift_compatible_with_Metasyntactic: pass -class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.Metasyntactic, _fbthrift_compatible_with_Metasyntactic): +class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Metasyntactic): FOO: Metasyntactic = ... BAR: Metasyntactic = ... BAZ: Metasyntactic = ... @@ -31,7 +31,7 @@ class _fbthrift_compatible_with_MyEnum1: pass -class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum1, _fbthrift_compatible_with_MyEnum1): +class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum1): ME1_0: MyEnum1 = ... ME1_1: MyEnum1 = ... ME1_2: MyEnum1 = ... @@ -46,7 +46,7 @@ class _fbthrift_compatible_with_MyEnum2: pass -class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum2, _fbthrift_compatible_with_MyEnum2): +class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum2): ME2_0: MyEnum2 = ... ME2_1: MyEnum2 = ... ME2_2: MyEnum2 = ... @@ -58,7 +58,7 @@ class _fbthrift_compatible_with_MyEnum3: pass -class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum3, _fbthrift_compatible_with_MyEnum3): +class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum3): ME3_0: MyEnum3 = ... ME3_1: MyEnum3 = ... ME3_N2: MyEnum3 = ... @@ -73,7 +73,7 @@ class _fbthrift_compatible_with_MyEnum4: pass -class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum4, _fbthrift_compatible_with_MyEnum4): +class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum4): ME4_A: MyEnum4 = ... ME4_B: MyEnum4 = ... ME4_C: MyEnum4 = ... @@ -86,7 +86,7 @@ class _fbthrift_compatible_with_MyBitmaskEnum1: pass -class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyBitmaskEnum1, _fbthrift_compatible_with_MyBitmaskEnum1): +class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum1): ONE: MyBitmaskEnum1 = ... TWO: MyBitmaskEnum1 = ... FOUR: MyBitmaskEnum1 = ... @@ -98,7 +98,7 @@ class _fbthrift_compatible_with_MyBitmaskEnum2: pass -class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyBitmaskEnum2, _fbthrift_compatible_with_MyBitmaskEnum2): +class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum2): ONE: MyBitmaskEnum2 = ... TWO: MyBitmaskEnum2 = ... FOUR: MyBitmaskEnum2 = ... diff --git a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/enums/module/thrift_enums.py b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/enums/module/thrift_enums.py index 63a66cbdb66..a75a6f633e6 100644 --- a/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/enums/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/enums/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/enums/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.enums.module.thrift_metadata -class Metasyntactic(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Metasyntactic: + pass + + +class Metasyntactic(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Metasyntactic): FOO = 1 BAR = 2 BAZ = 3 @@ -38,7 +42,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum1: + pass + + +class MyEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum1): ME1_0 = 0 ME1_1 = 1 ME1_2 = 2 @@ -68,7 +76,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum2: + pass + + +class MyEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum2): ME2_0 = 0 ME2_1 = 1 ME2_2 = 2 @@ -95,7 +107,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum3(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum3: + pass + + +class MyEnum3(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum3): ME3_0 = 0 ME3_1 = 1 ME3_N2 = -2 @@ -125,7 +141,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyEnum4(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum4: + pass + + +class MyEnum4(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum4): ME4_A = 2147483645 ME4_B = 2147483646 ME4_C = 2147483647 @@ -153,7 +173,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum1(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum1: + pass + + +class MyBitmaskEnum1(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum1): ONE = 1 TWO = 2 FOUR = 4 @@ -180,7 +204,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyBitmaskEnum2(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyBitmaskEnum2: + pass + + +class MyBitmaskEnum2(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyBitmaskEnum2): ONE = 1 TWO = 2 FOUR = 4 diff --git a/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index df8268b2e5a..5719c9d8f23 100644 --- a/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from module.thrift_enums import * class Fiery(_fbthrift_python_abstract_types.AbstractGeneratedError): @_fbthrift_property def message(self) -> str: ... diff --git a/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/exceptions/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 903212eb65a..3039fe269bd 100644 --- a/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -22,6 +22,7 @@ import includes.thrift_abstract_types as _fbthrift__includes__thrift_abstract_types +from module.thrift_enums import * class MyStruct(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/includes/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 5e0a9673d0c..f6c8af416a7 100644 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -22,6 +22,7 @@ import foo.thrift_abstract_types as _fbthrift__foo__thrift_abstract_types +from module.thrift_enums import * class Fields(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/inject_metadata_fields/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index ee8cf92fa58..e92a8fa1398 100644 --- a/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from module.thrift_enums import * class Limits(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/int_limits/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_abstract_types.py index aefa46c7eff..b6d8044f019 100644 --- a/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_abstract_types.py @@ -22,6 +22,7 @@ import test.fixtures.another_interactions.shared.thrift_abstract_types as _fbthrift__test__fixtures__another_interactions__shared__thrift_abstract_types +from test.fixtures.interactions.module.thrift_enums import * class CustomException(_fbthrift_python_abstract_types.AbstractGeneratedError): @_fbthrift_property def message(self) -> str: ... diff --git a/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_enums.pyi index a2e60506b67..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/interactions/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/interactions/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.fixtures.interactions.module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 898f2a085ed..2b48403aedb 100644 --- a/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from module.thrift_enums import * class Mixin1(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/mixin/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_abstract_types.py index 36573a60e98..4cbb165ce96 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from test.namespace_from_package.module.thrift_enums import * class Foo(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_enums.pyi index a9fb27c6879..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/namespace_from_package/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.namespace_from_package.module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_abstract_types.py index 73c3bfa4e80..e23cbb7274e 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from test.namespace_from_package_without_module_name.module.thrift_enums import * class Foo(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_enums.pyi index dc7943762b7..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/python_experimental_generate_abstract_types/gen-python/test/namespace_from_package_without_module_name/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.namespace_from_package_without_module_name.module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/py3/out/python/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/py3/out/python/gen-python/module/thrift_enums.py index 94d14f3dd21..6c1ed6a82de 100644 --- a/thrift/compiler/test/fixtures/py3/out/python/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/py3/out/python/gen-python/module/thrift_enums.py @@ -12,7 +12,11 @@ import fbcode.thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class AnEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnEnum: + pass + + +class AnEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnEnum): NOTSET = 0 ONE = 1 TWO = 2 @@ -41,7 +45,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class AnEnumRenamed(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnEnumRenamed: + pass + + +class AnEnumRenamed(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnEnumRenamed): name_ = 0 value_ = 1 renamed_ = 2 @@ -68,7 +76,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class Flags(_fbthrift_python_types.Flag): +class _fbthrift_compatible_with_Flags: + pass + + +class Flags(_fbthrift_python_types.Flag, _fbthrift_compatible_with_Flags): flag_A = 1 flag_B = 2 flag_C = 4 diff --git a/thrift/compiler/test/fixtures/py3/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/py3/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py index 94d14f3dd21..6c1ed6a82de 100644 --- a/thrift/compiler/test/fixtures/py3/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/py3/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py @@ -12,7 +12,11 @@ import fbcode.thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class AnEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnEnum: + pass + + +class AnEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnEnum): NOTSET = 0 ONE = 1 TWO = 2 @@ -41,7 +45,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class AnEnumRenamed(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnEnumRenamed: + pass + + +class AnEnumRenamed(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnEnumRenamed): name_ = 0 value_ = 1 renamed_ = 2 @@ -68,7 +76,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class Flags(_fbthrift_python_types.Flag): +class _fbthrift_compatible_with_Flags: + pass + + +class Flags(_fbthrift_python_types.Flag, _fbthrift_compatible_with_Flags): flag_A = 1 flag_B = 2 flag_C = 4 diff --git a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_enums.py b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_enums.py index 6cf117a54a3..ff93cd4a988 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.python_capi.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class AnnoyingEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnnoyingEnum: + pass + + +class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnnoyingEnum): FOO = 1 BAR = 2 @staticmethod diff --git a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py index a9d93970b48..3c0abf13390 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_abstract_types.py @@ -26,13 +26,10 @@ import test.fixtures.python_capi.serialized_dep.thrift_abstract_types as _fbthrift__test__fixtures__python_capi__serialized_dep__thrift_abstract_types import test.fixtures.python_capi.thrift_dep.thrift_abstract_types as _fbthrift__test__fixtures__python_capi__thrift_dep__thrift_abstract_types -class MyEnum: - pass - -class AnnoyingEnum: - pass - +from test.fixtures.python_capi.module.thrift_enums import _fbthrift_compatible_with_MyEnum +from test.fixtures.python_capi.module.thrift_enums import _fbthrift_compatible_with_AnnoyingEnum +from test.fixtures.python_capi.module.thrift_enums import * class MyStruct(_abc.ABC): @_fbthrift_property @_abc.abstractmethod diff --git a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py index 6cf117a54a3..ff93cd4a988 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.python_capi.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class AnnoyingEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnnoyingEnum: + pass + + +class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnnoyingEnum): FOO = 1 BAR = 2 @staticmethod diff --git a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.pyi index c93d290dca5..f956042cfd5 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import test.fixtures.python_capi.module.thrift_abstract_types class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, test.fixtures.python_capi.module.thrift_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... def _to_python(self) -> MyEnum: ... @@ -25,7 +24,7 @@ class _fbthrift_compatible_with_AnnoyingEnum: pass -class AnnoyingEnum(_fbthrift_python_types.Enum, int, test.fixtures.python_capi.module.thrift_abstract_types.AnnoyingEnum, _fbthrift_compatible_with_AnnoyingEnum): +class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnnoyingEnum): FOO: AnnoyingEnum = ... BAR: AnnoyingEnum = ... def _to_python(self) -> AnnoyingEnum: ... diff --git a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_types.pyi b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_types.pyi index 43166496241..bf5200f2349 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_abstract_types/gen-python/test/fixtures/python_capi/module/thrift_types.pyi @@ -28,7 +28,7 @@ class _fbthrift_compatible_with_MyEnum: pass -class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyEnum, _fbthrift_compatible_with_MyEnum): +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1: MyEnum = ... MyValue2: MyEnum = ... def _to_python(self) -> MyEnum: ... @@ -39,7 +39,7 @@ class _fbthrift_compatible_with_AnnoyingEnum: pass -class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.AnnoyingEnum, _fbthrift_compatible_with_AnnoyingEnum): +class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnnoyingEnum): FOO: AnnoyingEnum = ... BAR: AnnoyingEnum = ... def _to_python(self) -> AnnoyingEnum: ... diff --git a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py index 6cf117a54a3..ff93cd4a988 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python_experimental_generate_mutable_types/gen-python/test/fixtures/python_capi/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import test.fixtures.python_capi.module.thrift_metadata -class MyEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyEnum: + pass + + +class MyEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyEnum): MyValue1 = 0 MyValue2 = 1 @staticmethod @@ -36,7 +40,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class AnnoyingEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_AnnoyingEnum: + pass + + +class AnnoyingEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_AnnoyingEnum): FOO = 1 BAR = 2 @staticmethod diff --git a/thrift/compiler/test/fixtures/service-schema/out/python/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/service-schema/out/python/gen-python/module/thrift_enums.py index 48b4c8b5530..76b685151a0 100644 --- a/thrift/compiler/test/fixtures/service-schema/out/python/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/service-schema/out/python/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class Result(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Result: + pass + + +class Result(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Result): OK = 0 SO_SO = 1 GOOD = 2 diff --git a/thrift/compiler/test/fixtures/service-schema/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py b/thrift/compiler/test/fixtures/service-schema/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py index 48b4c8b5530..76b685151a0 100644 --- a/thrift/compiler/test/fixtures/service-schema/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/service-schema/out/python_experimental_generate_mutable_types/gen-python/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import module.thrift_metadata -class Result(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_Result: + pass + + +class Result(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_Result): OK = 0 SO_SO = 1 GOOD = 2 diff --git a/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py index 4262a445d15..6c69ede6298 100644 --- a/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_abstract_types.py @@ -21,6 +21,7 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types +from module.thrift_enums import * class FooStreamEx(_fbthrift_python_abstract_types.AbstractGeneratedError): def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Union[None]]]: ... def _to_mutable_python(self) -> "module.thrift_mutable_types.FooStreamEx": ... # type: ignore diff --git a/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi index 8c147498467..a0469eae297 100644 --- a/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/stream/out/python_experimental_generate_abstract_types/gen-python/module/thrift_enums.pyi @@ -8,4 +8,3 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import module.thrift_abstract_types diff --git a/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py b/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py index 3f8bb3ad4e1..2cf9318d9d5 100644 --- a/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import apache.thrift.fixtures.types.module.thrift_metadata -class has_bitwise_ops(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_has_bitwise_ops: + pass + + +class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_has_bitwise_ops): none = 0 zero = 1 one = 2 @@ -39,7 +43,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class is_unscoped(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_is_unscoped: + pass + + +class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_is_unscoped): hello = 0 world = 1 @staticmethod @@ -65,7 +73,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyForwardRefEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyForwardRefEnum: + pass + + +class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyForwardRefEnum): ZERO = 0 NONZERO = 12 @staticmethod diff --git a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_abstract_types.py b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_abstract_types.py index de2fa94038e..52bd9e3dae7 100644 --- a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_abstract_types.py +++ b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_abstract_types.py @@ -21,16 +21,11 @@ import thrift.python.abstract_types as _fbthrift_python_abstract_types import apache.thrift.fixtures.types.included.thrift_abstract_types as _fbthrift__apache__thrift__fixtures__types__included__thrift_abstract_types -class has_bitwise_ops: - pass - -class is_unscoped: - pass - -class MyForwardRefEnum: - pass - +from apache.thrift.fixtures.types.module.thrift_enums import _fbthrift_compatible_with_has_bitwise_ops +from apache.thrift.fixtures.types.module.thrift_enums import _fbthrift_compatible_with_is_unscoped +from apache.thrift.fixtures.types.module.thrift_enums import _fbthrift_compatible_with_MyForwardRefEnum +from apache.thrift.fixtures.types.module.thrift_enums import * class empty_struct(_abc.ABC): @_abc.abstractmethod def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Union[None]]]: ... diff --git a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py index 3f8bb3ad4e1..2cf9318d9d5 100644 --- a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import apache.thrift.fixtures.types.module.thrift_metadata -class has_bitwise_ops(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_has_bitwise_ops: + pass + + +class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_has_bitwise_ops): none = 0 zero = 1 one = 2 @@ -39,7 +43,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class is_unscoped(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_is_unscoped: + pass + + +class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_is_unscoped): hello = 0 world = 1 @staticmethod @@ -65,7 +73,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyForwardRefEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyForwardRefEnum: + pass + + +class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyForwardRefEnum): ZERO = 0 NONZERO = 12 @staticmethod diff --git a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.pyi b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.pyi index 1ed17d926c1..021c1073324 100644 --- a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.pyi +++ b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.pyi @@ -8,13 +8,12 @@ from __future__ import annotations import thrift.python.types as _fbthrift_python_types -import apache.thrift.fixtures.types.module.thrift_abstract_types class _fbthrift_compatible_with_has_bitwise_ops: pass -class has_bitwise_ops(_fbthrift_python_types.Enum, int, apache.thrift.fixtures.types.module.thrift_abstract_types.has_bitwise_ops, _fbthrift_compatible_with_has_bitwise_ops): +class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_has_bitwise_ops): none: has_bitwise_ops = ... zero: has_bitwise_ops = ... one: has_bitwise_ops = ... @@ -28,7 +27,7 @@ class _fbthrift_compatible_with_is_unscoped: pass -class is_unscoped(_fbthrift_python_types.Enum, int, apache.thrift.fixtures.types.module.thrift_abstract_types.is_unscoped, _fbthrift_compatible_with_is_unscoped): +class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_is_unscoped): hello: is_unscoped = ... world: is_unscoped = ... def _to_python(self) -> is_unscoped: ... @@ -39,7 +38,7 @@ class _fbthrift_compatible_with_MyForwardRefEnum: pass -class MyForwardRefEnum(_fbthrift_python_types.Enum, int, apache.thrift.fixtures.types.module.thrift_abstract_types.MyForwardRefEnum, _fbthrift_compatible_with_MyForwardRefEnum): +class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyForwardRefEnum): ZERO: MyForwardRefEnum = ... NONZERO: MyForwardRefEnum = ... def _to_python(self) -> MyForwardRefEnum: ... diff --git a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_types.pyi b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_types.pyi index b5d20527e39..77dc42c6461 100644 --- a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_types.pyi +++ b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_abstract_types/gen-python/apache/thrift/fixtures/types/module/thrift_types.pyi @@ -20,7 +20,7 @@ class _fbthrift_compatible_with_has_bitwise_ops: pass -class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.has_bitwise_ops, _fbthrift_compatible_with_has_bitwise_ops): +class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_has_bitwise_ops): none: has_bitwise_ops = ... zero: has_bitwise_ops = ... one: has_bitwise_ops = ... @@ -34,7 +34,7 @@ class _fbthrift_compatible_with_is_unscoped: pass -class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.is_unscoped, _fbthrift_compatible_with_is_unscoped): +class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_is_unscoped): hello: is_unscoped = ... world: is_unscoped = ... def _to_python(self) -> is_unscoped: ... @@ -45,7 +45,7 @@ class _fbthrift_compatible_with_MyForwardRefEnum: pass -class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_python_abstract_types.MyForwardRefEnum, _fbthrift_compatible_with_MyForwardRefEnum): +class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyForwardRefEnum): ZERO: MyForwardRefEnum = ... NONZERO: MyForwardRefEnum = ... def _to_python(self) -> MyForwardRefEnum: ... diff --git a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_mutable_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_mutable_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py index 3f8bb3ad4e1..2cf9318d9d5 100644 --- a/thrift/compiler/test/fixtures/types/out/python_experimental_generate_mutable_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py +++ b/thrift/compiler/test/fixtures/types/out/python_experimental_generate_mutable_types/gen-python/apache/thrift/fixtures/types/module/thrift_enums.py @@ -10,7 +10,11 @@ import thrift.python.types as _fbthrift_python_types import apache.thrift.fixtures.types.module.thrift_metadata -class has_bitwise_ops(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_has_bitwise_ops: + pass + + +class has_bitwise_ops(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_has_bitwise_ops): none = 0 zero = 1 one = 2 @@ -39,7 +43,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class is_unscoped(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_is_unscoped: + pass + + +class is_unscoped(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_is_unscoped): hello = 0 world = 1 @staticmethod @@ -65,7 +73,11 @@ def _to_py3(self): def _to_py_deprecated(self): return self.value -class MyForwardRefEnum(_fbthrift_python_types.Enum, int): +class _fbthrift_compatible_with_MyForwardRefEnum: + pass + + +class MyForwardRefEnum(_fbthrift_python_types.Enum, int, _fbthrift_compatible_with_MyForwardRefEnum): ZERO = 0 NONZERO = 12 @staticmethod diff --git a/thrift/test/thrift-python/abstract_types_test.py b/thrift/test/thrift-python/abstract_types_test.py index ce4585e5f54..5789a931f49 100644 --- a/thrift/test/thrift-python/abstract_types_test.py +++ b/thrift/test/thrift-python/abstract_types_test.py @@ -18,6 +18,10 @@ import typing import unittest +import thrift.test.thrift_python.enum_test.thrift_abstract_types as enum_test_abstract_types + +import thrift.test.thrift_python.enum_test.thrift_enums as enum_test_enums + import thrift.test.thrift_python.included.thrift_abstract_types from folly import iobuf @@ -841,3 +845,14 @@ def test_create_union( AttributeError, ): string_field_union.int_field + + def test_enum_identity(self) -> None: + self.assertIs( + enum_test_enums.PositiveNumber, enum_test_abstract_types.PositiveNumber + ) + + def test_enum_value(self) -> None: + self.assertEqual( + enum_test_enums.PositiveNumber.THREE, + enum_test_abstract_types.PositiveNumber.THREE, + )