Skip to content

Commit 3fec909

Browse files
ahilgerfacebook-github-bot
authored andcommitted
make Lists appear to originate in .types
Summary: Use the same technique as enums to hide the `containers_` submodule and make the `List__i32` appear to originate from `.types`. Differential Revision: D63801989 fbshipit-source-id: 15d77daf2357157263b3a5809da639f9d956dccb
1 parent 85d36f2 commit 3fec909

File tree

69 files changed

+349
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+349
-104
lines changed

third-party/thrift/src/thrift/compiler/generate/templates/py3/containers_FBTHRIFT_ONLY_DO_NOT_USE.py.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ from collections.abc import Sequence
4545
If you `import` them directly from here, you will get nasty import errors.
4646
"""
4747
48+
_fbthrift__module_name__ = "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types"
49+
4850
import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as {{> types/current_module_types}}
4951
{{#program:includeNamespaces}}
5052
{{#hasTypes?}}
@@ -62,7 +64,10 @@ __all__ = []
6264
{{#program:containerTypes}}
6365
{{#type:list?}}
6466
class {{type:flat_name}}(thrift.py3.types.List):
65-
__slots__ = []
67+
{{! make the type appear to originate from .types module }}
68+
__module__ = _fbthrift__module_name__
69+
{{! __slots__ prevents accidental treatment as py-deprecated }}
70+
__slots__ = ()
6671
6772
def __init__(self, items=None, private_ctor_token=None) -> None:
6873
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:

third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():
@@ -26,7 +28,8 @@ def get_types_reflection():
2628
__all__ = []
2729

2830
class std_deque_std_string__List__string(thrift.py3.types.List):
29-
__slots__ = []
31+
__module__ = _fbthrift__module_name__
32+
__slots__ = ()
3033

3134
def __init__(self, items=None, private_ctor_token=None) -> None:
3235
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:

third-party/thrift/src/thrift/compiler/test/fixtures/basic-enum/out/py3/gen-py3/test/fixtures/enumstrict/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "test.fixtures.enumstrict.module.types"
20+
1921
import test.fixtures.enumstrict.module.types as _test_fixtures_enumstrict_module_types
2022

2123
def get_types_reflection():

third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():

third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "test.fixtures.basic.module.types"
20+
1921
import test.fixtures.basic.module.types as _test_fixtures_basic_module_types
2022

2123
def get_types_reflection():
@@ -26,7 +28,8 @@ def get_types_reflection():
2628
__all__ = []
2729

2830
class List__i32(thrift.py3.types.List):
29-
__slots__ = []
31+
__module__ = _fbthrift__module_name__
32+
__slots__ = ()
3033

3134
def __init__(self, items=None, private_ctor_token=None) -> None:
3235
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:

third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():
@@ -26,7 +28,8 @@ def get_types_reflection():
2628
__all__ = []
2729

2830
class List__i64(thrift.py3.types.List):
29-
__slots__ = []
31+
__module__ = _fbthrift__module_name__
32+
__slots__ = ()
3033

3134
def __init__(self, items=None, private_ctor_token=None) -> None:
3235
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:
@@ -65,7 +68,8 @@ def __get_reflection__():
6568
__all__.append('List__i64')
6669

6770
class List__string(thrift.py3.types.List):
68-
__slots__ = []
71+
__module__ = _fbthrift__module_name__
72+
__slots__ = ()
6973

7074
def __init__(self, items=None, private_ctor_token=None) -> None:
7175
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:

third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():
@@ -26,7 +28,8 @@ def get_types_reflection():
2628
__all__ = []
2729

2830
class List__i32(thrift.py3.types.List):
29-
__slots__ = []
31+
__module__ = _fbthrift__module_name__
32+
__slots__ = ()
3033

3134
def __init__(self, items=None, private_ctor_token=None) -> None:
3235
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:
@@ -65,7 +68,8 @@ def __get_reflection__():
6568
__all__.append('List__i32')
6669

6770
class List__Map__string_i32(thrift.py3.types.List):
68-
__slots__ = []
71+
__module__ = _fbthrift__module_name__
72+
__slots__ = ()
6973

7074
def __init__(self, items=None, private_ctor_token=None) -> None:
7175
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:
@@ -108,7 +112,8 @@ def __get_reflection__():
108112
__all__.append('List__Map__string_i32')
109113

110114
class List__Range(thrift.py3.types.List):
111-
__slots__ = []
115+
__module__ = _fbthrift__module_name__
116+
__slots__ = ()
112117

113118
def __init__(self, items=None, private_ctor_token=None) -> None:
114119
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:
@@ -147,7 +152,8 @@ def __get_reflection__():
147152
__all__.append('List__Range')
148153

149154
class List__Internship(thrift.py3.types.List):
150-
__slots__ = []
155+
__module__ = _fbthrift__module_name__
156+
__slots__ = ()
151157

152158
def __init__(self, items=None, private_ctor_token=None) -> None:
153159
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:
@@ -186,7 +192,8 @@ def __get_reflection__():
186192
__all__.append('List__Internship')
187193

188194
class List__string(thrift.py3.types.List):
189-
__slots__ = []
195+
__module__ = _fbthrift__module_name__
196+
__slots__ = ()
190197

191198
def __init__(self, items=None, private_ctor_token=None) -> None:
192199
if private_ctor_token is thrift.py3.types._fbthrift_list_private_ctor:

third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():

third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/py3/gen-py3/test/fixtures/enums/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "test.fixtures.enums.module.types"
20+
1921
import test.fixtures.enums.module.types as _test_fixtures_enums_module_types
2022

2123
def get_types_reflection():

third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
If you `import` them directly from here, you will get nasty import errors.
1717
"""
1818

19+
_fbthrift__module_name__ = "module.types"
20+
1921
import module.types as _module_types
2022

2123
def get_types_reflection():

0 commit comments

Comments
 (0)