Skip to content

Commit cb9dbc9

Browse files
Filip Franceticfacebook-github-bot
Filip Francetic
authored andcommitted
Change types_reflection.py to use thrift-py3 specific thrift types import
Summary: Previously, thrift py3 container flatnames were made available in auto-migrate mode in D66985311, but only when imported from `.types` rather than `.thrift_types`. In `types_reflection.py` we were importing from `.thrift_types` when building in auto-migrate mode, which meant that the container flatname types were not available, which meant any code trying to introspect on containers wasn't working. Fixing this by changing the import alias to be `.types` even in auto-migrate mode. Reviewed By: yoney, prakashgayasen Differential Revision: D68756851 fbshipit-source-id: 0d26ca0a1c7bc69d55ba831bdb7b137504e3bc66
1 parent 774d26f commit cb9dbc9

File tree

15 files changed

+13
-19
lines changed

15 files changed

+13
-19
lines changed

thrift/compiler/generate/templates/py3/types_reflection.py.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeN
5454
{{/hasTypes?}}
5555
{{/program:includeNamespaces}}
5656
57-
import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_import_prefix }}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types
57+
import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types
5858
5959
6060

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/includes/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import transitive.types as _transitive_types
2323

24-
import includes.thrift_types as _includes_types
24+
import includes.types as _includes_types
2525

2626

2727

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/module/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import includes.types as _includes_types
2323

24-
import module.thrift_types as _module_types
24+
import module.types as _module_types
2525

2626

2727

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/transitive/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import transitive.thrift_types as _transitive_types
23+
import transitive.types as _transitive_types
2424

2525

2626

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/includes/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import transitive.types as _transitive_types
2323

24-
import includes.thrift_types as _includes_types
24+
import includes.types as _includes_types
2525

2626

2727

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/transitive/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import transitive.thrift_types as _transitive_types
23+
import transitive.types as _transitive_types
2424

2525

2626

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/includes/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import transitive.types as _transitive_types
2323

24-
import includes.thrift_types as _includes_types
24+
import includes.types as _includes_types
2525

2626

2727

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/module/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import includes.types as _includes_types
2323

24-
import module.thrift_types as _module_types
24+
import module.types as _module_types
2525

2626

2727

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/service/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import module.types as _module_types
2424
import transitive.types as _transitive_types
2525

26-
import service.thrift_types as _service_types
26+
import service.types as _service_types
2727

2828

2929

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/transitive/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import transitive.thrift_types as _transitive_types
23+
import transitive.types as _transitive_types
2424

2525

2626

thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_transitive/gen-py3/transitive/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import transitive.thrift_types as _transitive_types
23+
import transitive.types as _transitive_types
2424

2525

2626

thrift/compiler/test/fixtures/py3/out/py3_auto_migrate/gen-py3/module/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import module.thrift_types as _module_types
23+
import module.types as _module_types
2424

2525

2626

thrift/compiler/test/fixtures/py3/out/py3_auto_migrate_legacy_container_converters/gen-py3/module/types_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
import module.thrift_types as _module_types
23+
import module.types as _module_types
2424

2525

2626

thrift/lib/py3/test/auto_migrate/converter.py

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def brokenInAutoMigrate(): # pyre-ignore[3] unittest isn't very well typed
3535

3636

3737
class PyDeprecatedToPy3ConverterTest(unittest.TestCase):
38-
@brokenInAutoMigrate()
3938
def test_simple(self) -> None:
4039
simple = py_deprecated_types.Simple(
4140
intField=42,
@@ -105,19 +104,16 @@ def test_nested(self) -> None:
105104
nested.colorToSimpleMap[py3_types.Color.BLUE].color, py3_types.Color.BLUE
106105
)
107106

108-
@brokenInAutoMigrate()
109107
def test_simple_union(self) -> None:
110108
simple_union = py_deprecated_types.Union(intField=42)._to_py3()
111109
self.assertEqual(simple_union.type, py3_types.Union.Type.intField)
112110
self.assertEqual(simple_union.value, 42)
113111

114-
@brokenInAutoMigrate()
115112
def test_union_with_py3_name_annotation(self) -> None:
116113
simple_union = py_deprecated_types.Union(name="myname")._to_py3()
117114
self.assertEqual(simple_union.type, py3_types.Union.Type.name_)
118115
self.assertEqual(simple_union.value, "myname")
119116

120-
@brokenInAutoMigrate()
121117
def test_union_with_containers(self) -> None:
122118
union_with_list = py_deprecated_types.Union(intList=[1, 2, 3])._to_py3()
123119
self.assertEqual(union_with_list.type, py3_types.Union.Type.intList)
@@ -187,7 +183,6 @@ def test_union_with_mismatching_field(self) -> None:
187183
self.assertEqual(to.type, py3_types.Potahto.Type.to)
188184
self.assertEqual(to.value, True)
189185

190-
@brokenInAutoMigrate()
191186
def test_py_bad_enum(self) -> None:
192187
simple = py_deprecated_types.Simple(
193188
intField=42,

thrift/lib/py3/test/auto_migrate/reflection.py

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
class ReflectionTests(unittest.TestCase):
4444
# Fails due to containers not working
45-
@brokenInAutoMigrate()
4645
def test_struct(self) -> None:
4746
x = easy(val=1, an_int=Integers(small=300), name="foo", val_list=[1, 2, 3, 4])
4847
self.assertTrue(inspectable(x))

0 commit comments

Comments
 (0)