diff --git a/third-party/thrift/src/thrift/compiler/generate/templates/py3/containers_FBTHRIFT_ONLY_DO_NOT_USE.py.mustache b/third-party/thrift/src/thrift/compiler/generate/templates/py3/containers_FBTHRIFT_ONLY_DO_NOT_USE.py.mustache index 468340023ad3e..ad9d519e1c525 100644 --- a/third-party/thrift/src/thrift/compiler/generate/templates/py3/containers_FBTHRIFT_ONLY_DO_NOT_USE.py.mustache +++ b/third-party/thrift/src/thrift/compiler/generate/templates/py3/containers_FBTHRIFT_ONLY_DO_NOT_USE.py.mustache @@ -36,7 +36,7 @@ want to include. import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -203,7 +203,99 @@ class {{type:flat_name}}(thrift.py3.types.Set): Set.register({{type:flat_name}}) -{{/type:set?}}{{^type:map?}} -__all__.append('{{type:flat_name}}') + +{{/type:set?}}{{#type:map?}} +class {{type:flat_name}}(thrift.py3.types.MapNew): + {{! make the type appear to originate from .types module }} + __module__ = _fbthrift__module_name__ + {{! __slots__ prevents accidental treatment as py-deprecated }} + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = {{! + }}{{#type:defaultTemplate?}}True{{/type:defaultTemplate?}}{{! + }}{{^type:defaultTemplate?}}False{{/type:defaultTemplate?}} + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + {{! + For internal use only, when items dict has been created internally + and each item has been converted from cpp so we can trust the type. + Do not use with user-exposed `dict` to avoid accidental mutability. + }} + _py_obj = items + elif isinstance(items, {{type:flat_name}}): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = {{type:flat_name}}._check_key_type_or_raise + check_val = {{type:flat_name}}._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, {{type:flat_name}}) + + @staticmethod + def _check_key_type_or_raise(key): + {{#type:key_type}} + {{#type:container?}} + if key is None: + raise TypeError("None is not of the type {{> types/pep484_type}}") + if not isinstance(key, {{> types/python_type}}): + key = {{> types/python_type}}(key) + {{/type:container?}} + {{^type:container?}} + if not ( + isinstance(key, {{> types/python_is_instance_type}}){{#type:enum?}} or + isinstance(key, thrift.py3.types.BadEnum){{/type:enum?}} + ): + raise TypeError(f"{key!r} is not of type {{> types/pep484_type}}") + {{/type:container?}} + {{/type:key_type}} + return key + + {{! __contains__ doesn't raise TypeError; __getitem__ uses KeyError }} + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + {{#type:key_type}} + if isinstance(key, {{> types/python_type}}): + return key + {{#type:container?}} + try: + return {{> types/python_type}}(key) + except: + return None + {{/type:container?}} + {{/type:key_type}} + + @staticmethod + def _check_val_type_or_raise(item): + {{#type:value_type}} + {{#type:container?}} + if item is None: + raise TypeError("None is not of the type {{> types/pep484_type}}") + if not isinstance(item, {{> types/python_type}}): + item = {{> types/python_type}}(item) + {{/type:container?}} + {{^type:container?}} + if not ( + isinstance(item, {{> types/python_is_instance_type}}){{#type:enum?}} or + isinstance(item, thrift.py3.types.BadEnum){{/type:enum?}} + ): + raise TypeError(f"{item!r} is not of type {{> types/pep484_type}}") + {{/type:container?}} + {{/type:value_type}} + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__{{type:flat_name}}() + + +Mapping.register({{type:flat_name}}) {{/type:map?}} +__all__.append('{{type:flat_name}}') + + {{/program:containerTypes}} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 97d08c31951be..a8304763461d7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -69,3 +69,5 @@ def __get_reflection__(): Sequence.register(std_deque_std_string__List__string) __all__.append('std_deque_std_string__List__string') + + diff --git a/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 b/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 index 5e599df1947f6..dedb86debb9a3 100644 --- a/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 +++ b/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 @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -27,3 +27,56 @@ def get_types_reflection(): __all__ = [] +class Map__MyEnum_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__MyEnum_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__MyEnum_string._check_key_type_or_raise + check_val = Map__MyEnum_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__MyEnum_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _test_fixtures_enumstrict_module_types.MyEnum) or + isinstance(key, thrift.py3.types.BadEnum) + ): + raise TypeError(f"{key!r} is not of type _test_fixtures_enumstrict_module_types.MyEnum") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _test_fixtures_enumstrict_module_types.MyEnum): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__MyEnum_string() + + +Mapping.register(Map__MyEnum_string) +__all__.append('Map__MyEnum_string') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 55bc36c198d2c..822d0f2d0cdbf 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 3df116148f89d..7e75ae95030ef 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -65,7 +65,10 @@ def __get_reflection__(): Set.register(Set__float) + __all__.append('Set__float') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -106,6 +109,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -146,4 +151,111 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + +class Map__string_i64(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i64): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i64._check_key_type_or_raise + check_val = Map__string_i64._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i64) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i64() + + +Mapping.register(Map__string_i64) +__all__.append('Map__string_i64') + + +class Map__string_List__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_List__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_List__i32._check_key_type_or_raise + check_val = Map__string_List__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_List__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[int]") + if not isinstance(item, _test_fixtures_basic_module_types.List__i32): + item = _test_fixtures_basic_module_types.List__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_List__i32() + + +Mapping.register(Map__string_List__i32) +__all__.append('Map__string_List__i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index cb8e94186afc6..1e9a1ca1d7bac 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,8 @@ def __get_reflection__(): Sequence.register(List__i64) __all__.append('List__i64') + + class List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -109,3 +111,57 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + +class Map__i16_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i16_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i16_string._check_key_type_or_raise + check_val = Map__i16_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i16_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i16_string() + + +Mapping.register(Map__i16_string) +__all__.append('Map__i16_string') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 1fb31507a5793..5a4e00ec75ac6 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,60 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + class List__Map__string_i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -111,6 +165,60 @@ def __get_reflection__(): Sequence.register(List__Map__string_i32) __all__.append('List__Map__string_i32') + + +class Map__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_string._check_key_type_or_raise + check_val = Map__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_string() + + +Mapping.register(Map__string_string) +__all__.append('Map__string_string') + + class List__Company(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -152,6 +260,8 @@ def __get_reflection__(): Sequence.register(List__Company) __all__.append('List__Company') + + class List__Range(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -192,6 +302,8 @@ def __get_reflection__(): Sequence.register(List__Range) __all__.append('List__Range') + + class List__Internship(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -232,6 +344,8 @@ def __get_reflection__(): Sequence.register(List__Internship) __all__.append('List__Internship') + + class List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -274,6 +388,8 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -312,7 +428,10 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -353,4 +472,163 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + +class Map__i32_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_string._check_key_type_or_raise + check_val = Map__i32_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_string() + + +Mapping.register(Map__i32_string) +__all__.append('Map__i32_string') + + +class Map__i32_bool(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_bool): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_bool._check_key_type_or_raise + check_val = Map__i32_bool._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_bool) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, bool) + ): + raise TypeError(f"{item!r} is not of type bool") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_bool() + + +Mapping.register(Map__i32_bool) +__all__.append('Map__i32_bool') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index ea42d22122779..2527120a70f35 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/py3/gen-py3/test/fixtures/enums/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/py3/gen-py3/test/fixtures/enums/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index bae95ede09805..a947e819029f7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/py3/gen-py3/test/fixtures/enums/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/enums/out/py3/gen-py3/test/fixtures/enums/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -65,4 +65,7 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 4f659dfa888f5..ee42c9c7dd6ae 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b3ff10ab07daf..0d1b3fe5fff23 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 2f36f74d66675..32c49d686f2fa 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 931346a610b2a..aa7f48c46c17c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 6fc708f951b5b..59567be9f38e9 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 931346a610b2a..aa7f48c46c17c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_includes/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b3ff10ab07daf..0d1b3fe5fff23 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index bf765bb64a1d9..64e0478ef58d0 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 40ca27658f7cc..41055600df8fc 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 931346a610b2a..aa7f48c46c17c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_transitive/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_transitive/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 94a514c043d01..494731b2cc5af 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_transitive/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_auto_migrate_transitive/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b3ff10ab07daf..0d1b3fe5fff23 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/matching_struct_names/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/matching_struct_names/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 7ace3ec9dc6f0..e09cc32b0c85a 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/matching_struct_names/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/matching_struct_names/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -68,6 +68,8 @@ def __get_reflection__(): Sequence.register(List__MyStruct) __all__.append('List__MyStruct') + + class List__List__MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -112,6 +114,8 @@ def __get_reflection__(): Sequence.register(List__List__MyStruct) __all__.append('List__List__MyStruct') + + class List__module_MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -152,6 +156,8 @@ def __get_reflection__(): Sequence.register(List__module_MyStruct) __all__.append('List__module_MyStruct') + + class List__List__module_MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -196,3 +202,5 @@ def __get_reflection__(): Sequence.register(List__List__module_MyStruct) __all__.append('List__List__module_MyStruct') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index bf765bb64a1d9..64e0478ef58d0 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 931346a610b2a..aa7f48c46c17c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_matching_struct_names/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b3ff10ab07daf..0d1b3fe5fff23 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index bf765bb64a1d9..64e0478ef58d0 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 40ca27658f7cc..41055600df8fc 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/service/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 931346a610b2a..aa7f48c46c17c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/includes/out/py3_service/gen-py3/transitive/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/inheritance/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/inheritance/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b7420009b69b4..5fec8fef25eee 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/inheritance/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/inheritance/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/foo/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/foo/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 262f2b2b94237..d1e5cc9941b9e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/foo/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/foo/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b13b9462d61e3..a6a8ce8265f6f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/inject_metadata_fields/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 17d607d5c3340..616d3fe54f152 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/int_limits/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/another_interactions/shared/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/another_interactions/shared/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 26e1973f68b96..236b0470f8c21 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/another_interactions/shared/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/another_interactions/shared/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/interactions/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/interactions/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index e4fbd62b53aa2..db9a4b147b2e4 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/interactions/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/interactions/out/py3/gen-py3/test/fixtures/interactions/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/list/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/list/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 4d7e404f1e42a..fc9313c6249f2 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/list/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/list/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -69,3 +69,57 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + +class Map__i64_List__string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i64_List__string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i64_List__string._check_key_type_or_raise + check_val = Map__i64_List__string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i64_List__string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[str]") + if not isinstance(item, _module_types.List__string): + item = _module_types.List__string(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i64_List__string() + + +Mapping.register(Map__i64_List__string) +__all__.append('Map__i64_List__string') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index dd7b2b6bce01f..4d88ea325e6d7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/includes/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 98aebc9882c4d..720697e2ea7e8 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/mcpp2-compare/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -28,6 +28,110 @@ def get_types_reflection(): __all__ = [] +class Map__string_i64(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i64): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i64._check_key_type_or_raise + check_val = Map__string_i64._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i64) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i64() + + +Mapping.register(Map__string_i64) +__all__.append('Map__string_i64') + + +class Map__Empty_MyStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__Empty_MyStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__Empty_MyStruct._check_key_type_or_raise + check_val = Map__Empty_MyStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__Empty_MyStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _module_types.Empty) + ): + raise TypeError(f"{key!r} is not of type _module_types.Empty") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.Empty): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _module_types.MyStruct) + ): + raise TypeError(f"{item!r} is not of type _module_types.MyStruct") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__Empty_MyStruct() + + +Mapping.register(Map__Empty_MyStruct) +__all__.append('Map__Empty_MyStruct') + + class List__Map__Empty_MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -72,6 +176,8 @@ def __get_reflection__(): Sequence.register(List__Map__Empty_MyStruct) __all__.append('List__Map__Empty_MyStruct') + + class List__List__Map__Empty_MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -116,6 +222,8 @@ def __get_reflection__(): Sequence.register(List__List__Map__Empty_MyStruct) __all__.append('List__List__Map__Empty_MyStruct') + + class List__List__List__Map__Empty_MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -160,6 +268,8 @@ def __get_reflection__(): Sequence.register(List__List__List__Map__Empty_MyStruct) __all__.append('List__List__List__Map__Empty_MyStruct') + + class List__MyEnumA(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -201,6 +311,8 @@ def __get_reflection__(): Sequence.register(List__MyEnumA) __all__.append('List__MyEnumA') + + class Set__MyStruct(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -239,7 +351,10 @@ def __get_reflection__(): Set.register(Set__MyStruct) + __all__.append('Set__MyStruct') + + class List__ComplexUnion(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -280,6 +395,8 @@ def __get_reflection__(): Sequence.register(List__ComplexUnion) __all__.append('List__ComplexUnion') + + class List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -322,6 +439,8 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + class Set__List__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -364,7 +483,10 @@ def __get_reflection__(): Set.register(Set__List__string) + __all__.append('Set__List__string') + + class Set__List__List__Map__Empty_MyStruct(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -407,7 +529,62 @@ def __get_reflection__(): Set.register(Set__List__List__Map__Empty_MyStruct) + __all__.append('Set__List__List__Map__Empty_MyStruct') + + +class Map__i32_List__string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_List__string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_List__string._check_key_type_or_raise + check_val = Map__i32_List__string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_List__string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[str]") + if not isinstance(item, _module_types.List__string): + item = _module_types.List__string(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_List__string() + + +Mapping.register(Map__i32_List__string) +__all__.append('Map__i32_List__string') + + class List__bool(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -448,6 +625,8 @@ def __get_reflection__(): Sequence.register(List__bool) __all__.append('List__bool') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -488,6 +667,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -532,6 +713,8 @@ def __get_reflection__(): Sequence.register(List__List__i32) __all__.append('List__List__i32') + + class List__List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -576,6 +759,8 @@ def __get_reflection__(): Sequence.register(List__List__List__i32) __all__.append('List__List__List__i32') + + class List__List__List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -620,6 +805,8 @@ def __get_reflection__(): Sequence.register(List__List__List__List__i32) __all__.append('List__List__List__List__i32') + + class Set__List__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -662,7 +849,10 @@ def __get_reflection__(): Set.register(Set__List__i32) + __all__.append('Set__List__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -703,7 +893,10 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + class List__Set__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -748,6 +941,120 @@ def __get_reflection__(): Sequence.register(List__Set__string) __all__.append('List__Set__string') + + +class Map__List__Set__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__List__Set__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__List__Set__string_string._check_key_type_or_raise + check_val = Map__List__Set__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__List__Set__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if key is None: + raise TypeError("None is not of the type _typing.Sequence[_typing.AbstractSet[str]]") + if not isinstance(key, _module_types.List__Set__string): + key = _module_types.List__Set__string(key) + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.List__Set__string): + return key + try: + return _module_types.List__Set__string(key) + except: + return None + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__List__Set__string_string() + + +Mapping.register(Map__List__Set__string_string) +__all__.append('Map__List__Set__string_string') + + +class Map__Set__List__i32_Map__List__Set__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__Set__List__i32_Map__List__Set__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__Set__List__i32_Map__List__Set__string_string._check_key_type_or_raise + check_val = Map__Set__List__i32_Map__List__Set__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__Set__List__i32_Map__List__Set__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if key is None: + raise TypeError("None is not of the type _typing.AbstractSet[_typing.Sequence[int]]") + if not isinstance(key, _module_types.Set__List__i32): + key = _module_types.Set__List__i32(key) + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.Set__List__i32): + return key + try: + return _module_types.Set__List__i32(key) + except: + return None + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[_typing.Sequence[_typing.AbstractSet[str]], str]") + if not isinstance(item, _module_types.Map__List__Set__string_string): + item = _module_types.Map__List__Set__string_string(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__Set__List__i32_Map__List__Set__string_string() + + +Mapping.register(Map__Set__List__i32_Map__List__Set__string_string) +__all__.append('Map__Set__List__i32_Map__List__Set__string_string') + + class List__binary(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -790,6 +1097,61 @@ def __get_reflection__(): Sequence.register(List__binary) __all__.append('List__binary') + + +class Map__MyEnumA_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__MyEnumA_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__MyEnumA_string._check_key_type_or_raise + check_val = Map__MyEnumA_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__MyEnumA_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _module_types.MyEnumA) or + isinstance(key, thrift.py3.types.BadEnum) + ): + raise TypeError(f"{key!r} is not of type _module_types.MyEnumA") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.MyEnumA): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__MyEnumA_string() + + +Mapping.register(Map__MyEnumA_string) +__all__.append('Map__MyEnumA_string') + + class Set__i64(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -828,7 +1190,62 @@ def __get_reflection__(): Set.register(Set__i64) + __all__.append('Set__i64') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + class List__SimpleUnion(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -869,6 +1286,8 @@ def __get_reflection__(): Sequence.register(List__SimpleUnion) __all__.append('List__SimpleUnion') + + class Set__SimpleUnion(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -907,7 +1326,10 @@ def __get_reflection__(): Set.register(Set__SimpleUnion) + __all__.append('Set__SimpleUnion') + + class List__Set__SimpleUnion(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -952,6 +1374,60 @@ def __get_reflection__(): Sequence.register(List__Set__SimpleUnion) __all__.append('List__Set__SimpleUnion') + + +class Map__string_bool(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_bool): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_bool._check_key_type_or_raise + check_val = Map__string_bool._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_bool) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, bool) + ): + raise TypeError(f"{item!r} is not of type bool") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_bool() + + +Mapping.register(Map__string_bool) +__all__.append('Map__string_bool') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -990,7 +1466,114 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + +class Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, int]") + if not isinstance(item, _module_types.Map__string_i32): + item = _module_types.Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_i32') + + +class Map__string_Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, _typing.Mapping[str, int]]") + if not isinstance(item, _module_types.Map__string_Map__string_i32): + item = _module_types.Map__string_Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_Map__string_i32') + + class List__Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1035,6 +1618,60 @@ def __get_reflection__(): Sequence.register(List__Set__i32) __all__.append('List__Set__i32') + + +class Map__string_List__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_List__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_List__i32._check_key_type_or_raise + check_val = Map__string_List__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_List__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[int]") + if not isinstance(item, _module_types.List__i32): + item = _module_types.List__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_List__i32() + + +Mapping.register(Map__string_List__i32) +__all__.append('Map__string_List__i32') + + class Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1073,7 +1710,10 @@ def __get_reflection__(): Set.register(Set__bool) + __all__.append('Set__bool') + + class Set__Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1116,7 +1756,10 @@ def __get_reflection__(): Set.register(Set__Set__bool) + __all__.append('Set__Set__bool') + + class Set__Set__Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1159,7 +1802,62 @@ def __get_reflection__(): Set.register(Set__Set__Set__bool) + __all__.append('Set__Set__Set__bool') + + +class Map__Bar__double_Baz__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__Bar__double_Baz__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__Bar__double_Baz__i32._check_key_type_or_raise + check_val = Map__Bar__double_Baz__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__Bar__double_Baz__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, (float, int)) + ): + raise TypeError(f"{key!r} is not of type float") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, float): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__Bar__double_Baz__i32() + + +Mapping.register(Map__Bar__double_Baz__i32) +__all__.append('Map__Bar__double_Baz__i32') + + class folly_small_vector_int64_t_8__List__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1200,6 +1898,8 @@ def __get_reflection__(): Sequence.register(folly_small_vector_int64_t_8__List__i64) __all__.append('folly_small_vector_int64_t_8__List__i64') + + class folly_sorted_vector_set_std_string__Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1240,7 +1940,114 @@ def __get_reflection__(): Set.register(folly_sorted_vector_set_std_string__Set__string) + __all__.append('folly_sorted_vector_set_std_string__Set__string') + + +class FakeMap__Map__i64_double(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, FakeMap__Map__i64_double): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = FakeMap__Map__i64_double._check_key_type_or_raise + check_val = FakeMap__Map__i64_double._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, FakeMap__Map__i64_double) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, (float, int)) + ): + raise TypeError(f"{item!r} is not of type float") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__FakeMap__Map__i64_double() + + +Mapping.register(FakeMap__Map__i64_double) +__all__.append('FakeMap__Map__i64_double') + + +class std_unordered_map_std_string_containerStruct__Map__string_containerStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, std_unordered_map_std_string_containerStruct__Map__string_containerStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = std_unordered_map_std_string_containerStruct__Map__string_containerStruct._check_key_type_or_raise + check_val = std_unordered_map_std_string_containerStruct__Map__string_containerStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, std_unordered_map_std_string_containerStruct__Map__string_containerStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _module_types.containerStruct) + ): + raise TypeError(f"{item!r} is not of type _module_types.containerStruct") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__std_unordered_map_std_string_containerStruct__Map__string_containerStruct() + + +Mapping.register(std_unordered_map_std_string_containerStruct__Map__string_containerStruct) +__all__.append('std_unordered_map_std_string_containerStruct__Map__string_containerStruct') + + class std_list__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1281,6 +2088,8 @@ def __get_reflection__(): Sequence.register(std_list__List__i32) __all__.append('std_list__List__i32') + + class std_deque__List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1323,6 +2132,8 @@ def __get_reflection__(): Sequence.register(std_deque__List__string) __all__.append('std_deque__List__string') + + class folly_sorted_vector_set__Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1363,7 +2174,62 @@ def __get_reflection__(): Set.register(folly_sorted_vector_set__Set__string) + __all__.append('folly_sorted_vector_set__Set__string') + + +class folly_sorted_vector_map__Map__i64_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, folly_sorted_vector_map__Map__i64_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = folly_sorted_vector_map__Map__i64_string._check_key_type_or_raise + check_val = folly_sorted_vector_map__Map__i64_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, folly_sorted_vector_map__Map__i64_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__folly_sorted_vector_map__Map__i64_string() + + +Mapping.register(folly_sorted_vector_map__Map__i64_string) +__all__.append('folly_sorted_vector_map__Map__i64_string') + + class List__Bar__double(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1404,6 +2270,8 @@ def __get_reflection__(): Sequence.register(List__Bar__double) __all__.append('List__Bar__double') + + class Set__Baz__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1442,7 +2310,166 @@ def __get_reflection__(): Set.register(Set__Baz__i32) + __all__.append('Set__Baz__i32') + + +class Map__string_folly_IOBuf__binary(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_folly_IOBuf__binary): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_folly_IOBuf__binary._check_key_type_or_raise + check_val = Map__string_folly_IOBuf__binary._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_folly_IOBuf__binary) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _fbthrift_iobuf.IOBuf) + ): + raise TypeError(f"{item!r} is not of type _fbthrift_iobuf.IOBuf") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_folly_IOBuf__binary() + + +Mapping.register(Map__string_folly_IOBuf__binary) +__all__.append('Map__string_folly_IOBuf__binary') + + +class Map__string_std_unique_ptr_folly_IOBuf__binary(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_std_unique_ptr_folly_IOBuf__binary): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_std_unique_ptr_folly_IOBuf__binary._check_key_type_or_raise + check_val = Map__string_std_unique_ptr_folly_IOBuf__binary._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_std_unique_ptr_folly_IOBuf__binary) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _fbthrift_iobuf.IOBuf) + ): + raise TypeError(f"{item!r} is not of type _fbthrift_iobuf.IOBuf") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_std_unique_ptr_folly_IOBuf__binary() + + +Mapping.register(Map__string_std_unique_ptr_folly_IOBuf__binary) +__all__.append('Map__string_std_unique_ptr_folly_IOBuf__binary') + + +class Map__i32_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_string._check_key_type_or_raise + check_val = Map__i32_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_string() + + +Mapping.register(Map__i32_string) +__all__.append('Map__i32_string') + + class List__Map__string_i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1487,6 +2514,60 @@ def __get_reflection__(): Sequence.register(List__Map__string_i32) __all__.append('List__Map__string_i32') + + +class Map__i16_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i16_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i16_string._check_key_type_or_raise + check_val = Map__i16_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i16_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i16_string() + + +Mapping.register(Map__i16_string) +__all__.append('Map__i16_string') + + class List__Map__i16_string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1531,6 +2612,8 @@ def __get_reflection__(): Sequence.register(List__Map__i16_string) __all__.append('List__Map__i16_string') + + class List__MyStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -1571,3 +2654,5 @@ def __get_reflection__(): Sequence.register(List__MyStruct) __all__.append('List__MyStruct') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 43726b4e38557..8c8b58d701519 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/mixin/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3/gen-py3/my/namespacing/test/module/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3/gen-py3/my/namespacing/test/module/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 135a6d6e5d100..ae1e9ceb505f7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3/gen-py3/my/namespacing/test/module/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3/gen-py3/my/namespacing/test/module/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_emptyns/gen-py3/emptyns/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_emptyns/gen-py3/emptyns/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index d20dc242ca8c8..1b8eaf1c7e428 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_emptyns/gen-py3/emptyns/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_emptyns/gen-py3/emptyns/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/extend/test/extend/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/extend/test/extend/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index bf1983dfdae0b..7ebcfd7c9b503 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/extend/test/extend/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/extend/test/extend/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/test/hsmodule/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/test/hsmodule/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 46af683c9aa13..5558ef36bd7c1 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/test/hsmodule/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace/out/py3_extend/gen-py3/my/namespacing/test/hsmodule/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/py3/gen-py3/test/namespace_from_package/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/py3/gen-py3/test/namespace_from_package/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 03cbf934d9e93..427635617fa66 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/py3/gen-py3/test/namespace_from_package/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package/out/py3/gen-py3/test/namespace_from_package/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/py3/gen-py3/test/namespace_from_package_without_module_name/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/py3/gen-py3/test/namespace_from_package_without_module_name/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 9a580de53a91f..daa3977d4006c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/py3/gen-py3/test/namespace_from_package_without_module_name/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/py3/gen-py3/test/namespace_from_package_without_module_name/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/optionals/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/optionals/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 793402501a44c..0ee0daabf4117 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/optionals/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/optionals/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -65,7 +65,63 @@ def __get_reflection__(): Set.register(Set__i64) + __all__.append('Set__i64') + + +class Map__Animal_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__Animal_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__Animal_string._check_key_type_or_raise + check_val = Map__Animal_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__Animal_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _module_types.Animal) or + isinstance(key, thrift.py3.types.BadEnum) + ): + raise TypeError(f"{key!r} is not of type _module_types.Animal") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.Animal): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__Animal_string() + + +Mapping.register(Map__Animal_string) +__all__.append('Map__Animal_string') + + class List__Vehicle(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -106,3 +162,5 @@ def __get_reflection__(): Sequence.register(List__Vehicle) __all__.append('List__Vehicle') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/params/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/params/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 7a86c18bc9892..553eade11360f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/params/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/params/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,60 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + +class Map__i32_List__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_List__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_List__i32._check_key_type_or_raise + check_val = Map__i32_List__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_List__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[int]") + if not isinstance(item, _module_types.List__i32): + item = _module_types.List__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_List__i32() + + +Mapping.register(Map__i32_List__i32) +__all__.append('Map__i32_List__i32') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -105,7 +159,114 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + +class Map__i32_Set__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_Set__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_Set__i32._check_key_type_or_raise + check_val = Map__i32_Set__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_Set__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.AbstractSet[int]") + if not isinstance(item, _module_types.Set__i32): + item = _module_types.Set__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_Set__i32() + + +Mapping.register(Map__i32_Set__i32) +__all__.append('Map__i32_Set__i32') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + class List__Map__i32_i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -150,6 +311,8 @@ def __get_reflection__(): Sequence.register(List__Map__i32_i32) __all__.append('List__Map__i32_i32') + + class List__Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -194,6 +357,60 @@ def __get_reflection__(): Sequence.register(List__Set__i32) __all__.append('List__Set__i32') + + +class Map__i32_Map__i32_Set__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_Map__i32_Set__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_Map__i32_Set__i32._check_key_type_or_raise + check_val = Map__i32_Map__i32_Set__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_Map__i32_Set__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[int, _typing.AbstractSet[int]]") + if not isinstance(item, _module_types.Map__i32_Set__i32): + item = _module_types.Map__i32_Set__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_Map__i32_Set__i32() + + +Mapping.register(Map__i32_Map__i32_Set__i32) +__all__.append('Map__i32_Map__i32_Set__i32') + + class List__Map__i32_Map__i32_Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -238,6 +455,8 @@ def __get_reflection__(): Sequence.register(List__Map__i32_Map__i32_Set__i32) __all__.append('List__Map__i32_Map__i32_Set__i32') + + class List__List__Map__i32_Map__i32_Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -282,3 +501,5 @@ def __get_reflection__(): Sequence.register(List__List__Map__i32_Map__i32_Set__i32) __all__.append('List__List__Map__i32_Map__i32_Set__i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index e909c80e7f71a..83322a4938dee 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,8 @@ def __get_reflection__(): Sequence.register(List__i16) __all__.append('List__i16') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -107,6 +109,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class List__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -147,6 +151,8 @@ def __get_reflection__(): Sequence.register(List__i64) __all__.append('List__i64') + + class List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -189,6 +195,8 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + class List__SimpleStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -229,6 +237,8 @@ def __get_reflection__(): Sequence.register(List__SimpleStruct) __all__.append('List__SimpleStruct') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -267,7 +277,10 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -308,7 +321,166 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + +class Map__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_string._check_key_type_or_raise + check_val = Map__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_string() + + +Mapping.register(Map__string_string) +__all__.append('Map__string_string') + + +class Map__string_SimpleStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_SimpleStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_SimpleStruct._check_key_type_or_raise + check_val = Map__string_SimpleStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_SimpleStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _module_types.SimpleStruct) + ): + raise TypeError(f"{item!r} is not of type _module_types.SimpleStruct") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_SimpleStruct() + + +Mapping.register(Map__string_SimpleStruct) +__all__.append('Map__string_SimpleStruct') + + +class Map__string_i16(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i16): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i16._check_key_type_or_raise + check_val = Map__string_i16._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i16) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i16() + + +Mapping.register(Map__string_i16) +__all__.append('Map__string_i16') + + class List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -353,6 +525,112 @@ def __get_reflection__(): Sequence.register(List__List__i32) __all__.append('List__List__i32') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + +class Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, int]") + if not isinstance(item, _module_types.Map__string_i32): + item = _module_types.Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_i32') + + class List__Set__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -397,6 +675,60 @@ def __get_reflection__(): Sequence.register(List__Set__string) __all__.append('List__Set__string') + + +class Map__string_List__SimpleStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_List__SimpleStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_List__SimpleStruct._check_key_type_or_raise + check_val = Map__string_List__SimpleStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_List__SimpleStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[_module_types.SimpleStruct]") + if not isinstance(item, _module_types.List__SimpleStruct): + item = _module_types.List__SimpleStruct(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_List__SimpleStruct() + + +Mapping.register(Map__string_List__SimpleStruct) +__all__.append('Map__string_List__SimpleStruct') + + class List__List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -441,6 +773,8 @@ def __get_reflection__(): Sequence.register(List__List__string) __all__.append('List__List__string') + + class List__Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -485,6 +819,8 @@ def __get_reflection__(): Sequence.register(List__Set__i32) __all__.append('List__Set__i32') + + class List__Map__string_string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -529,6 +865,8 @@ def __get_reflection__(): Sequence.register(List__Map__string_string) __all__.append('List__Map__string_string') + + class List__binary(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -571,6 +909,8 @@ def __get_reflection__(): Sequence.register(List__binary) __all__.append('List__binary') + + class Set__binary(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -611,7 +951,10 @@ def __get_reflection__(): Set.register(Set__binary) + __all__.append('Set__binary') + + class List__AnEnum(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -653,6 +996,60 @@ def __get_reflection__(): Sequence.register(List__AnEnum) __all__.append('List__AnEnum') + + +class _std_unordered_map__Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, _std_unordered_map__Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = _std_unordered_map__Map__i32_i32._check_key_type_or_raise + check_val = _std_unordered_map__Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, _std_unordered_map__Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection___std_unordered_map__Map__i32_i32() + + +Mapping.register(_std_unordered_map__Map__i32_i32) +__all__.append('_std_unordered_map__Map__i32_i32') + + class _MyType__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -693,6 +1090,8 @@ def __get_reflection__(): Sequence.register(_MyType__List__i32) __all__.append('_MyType__List__i32') + + class _MyType__Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -731,7 +1130,166 @@ def __get_reflection__(): Set.register(_MyType__Set__i32) + __all__.append('_MyType__Set__i32') + + +class _MyType__Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, _MyType__Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = _MyType__Map__i32_i32._check_key_type_or_raise + check_val = _MyType__Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, _MyType__Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection___MyType__Map__i32_i32() + + +Mapping.register(_MyType__Map__i32_i32) +__all__.append('_MyType__Map__i32_i32') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + +class Map__i32_double(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_double): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_double._check_key_type_or_raise + check_val = Map__i32_double._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_double) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, (float, int)) + ): + raise TypeError(f"{item!r} is not of type float") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_double() + + +Mapping.register(Map__i32_double) +__all__.append('Map__i32_double') + + class List__Map__i32_double(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -776,3 +1334,58 @@ def __get_reflection__(): Sequence.register(List__Map__i32_double) __all__.append('List__Map__i32_double') + + +class Map__AnEnumRenamed_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__AnEnumRenamed_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__AnEnumRenamed_i32._check_key_type_or_raise + check_val = Map__AnEnumRenamed_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__AnEnumRenamed_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _module_types.AnEnumRenamed) or + isinstance(key, thrift.py3.types.BadEnum) + ): + raise TypeError(f"{key!r} is not of type _module_types.AnEnumRenamed") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.AnEnumRenamed): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__AnEnumRenamed_i32() + + +Mapping.register(Map__AnEnumRenamed_i32) +__all__.append('Map__AnEnumRenamed_i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index e909c80e7f71a..83322a4938dee 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_auto_migrate/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,8 @@ def __get_reflection__(): Sequence.register(List__i16) __all__.append('List__i16') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -107,6 +109,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class List__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -147,6 +151,8 @@ def __get_reflection__(): Sequence.register(List__i64) __all__.append('List__i64') + + class List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -189,6 +195,8 @@ def __get_reflection__(): Sequence.register(List__string) __all__.append('List__string') + + class List__SimpleStruct(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -229,6 +237,8 @@ def __get_reflection__(): Sequence.register(List__SimpleStruct) __all__.append('List__SimpleStruct') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -267,7 +277,10 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -308,7 +321,166 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + +class Map__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_string._check_key_type_or_raise + check_val = Map__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_string() + + +Mapping.register(Map__string_string) +__all__.append('Map__string_string') + + +class Map__string_SimpleStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_SimpleStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_SimpleStruct._check_key_type_or_raise + check_val = Map__string_SimpleStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_SimpleStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _module_types.SimpleStruct) + ): + raise TypeError(f"{item!r} is not of type _module_types.SimpleStruct") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_SimpleStruct() + + +Mapping.register(Map__string_SimpleStruct) +__all__.append('Map__string_SimpleStruct') + + +class Map__string_i16(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i16): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i16._check_key_type_or_raise + check_val = Map__string_i16._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i16) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i16() + + +Mapping.register(Map__string_i16) +__all__.append('Map__string_i16') + + class List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -353,6 +525,112 @@ def __get_reflection__(): Sequence.register(List__List__i32) __all__.append('List__List__i32') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + +class Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, int]") + if not isinstance(item, _module_types.Map__string_i32): + item = _module_types.Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_i32') + + class List__Set__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -397,6 +675,60 @@ def __get_reflection__(): Sequence.register(List__Set__string) __all__.append('List__Set__string') + + +class Map__string_List__SimpleStruct(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_List__SimpleStruct): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_List__SimpleStruct._check_key_type_or_raise + check_val = Map__string_List__SimpleStruct._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_List__SimpleStruct) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[_module_types.SimpleStruct]") + if not isinstance(item, _module_types.List__SimpleStruct): + item = _module_types.List__SimpleStruct(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_List__SimpleStruct() + + +Mapping.register(Map__string_List__SimpleStruct) +__all__.append('Map__string_List__SimpleStruct') + + class List__List__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -441,6 +773,8 @@ def __get_reflection__(): Sequence.register(List__List__string) __all__.append('List__List__string') + + class List__Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -485,6 +819,8 @@ def __get_reflection__(): Sequence.register(List__Set__i32) __all__.append('List__Set__i32') + + class List__Map__string_string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -529,6 +865,8 @@ def __get_reflection__(): Sequence.register(List__Map__string_string) __all__.append('List__Map__string_string') + + class List__binary(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -571,6 +909,8 @@ def __get_reflection__(): Sequence.register(List__binary) __all__.append('List__binary') + + class Set__binary(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -611,7 +951,10 @@ def __get_reflection__(): Set.register(Set__binary) + __all__.append('Set__binary') + + class List__AnEnum(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -653,6 +996,60 @@ def __get_reflection__(): Sequence.register(List__AnEnum) __all__.append('List__AnEnum') + + +class _std_unordered_map__Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, _std_unordered_map__Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = _std_unordered_map__Map__i32_i32._check_key_type_or_raise + check_val = _std_unordered_map__Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, _std_unordered_map__Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection___std_unordered_map__Map__i32_i32() + + +Mapping.register(_std_unordered_map__Map__i32_i32) +__all__.append('_std_unordered_map__Map__i32_i32') + + class _MyType__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -693,6 +1090,8 @@ def __get_reflection__(): Sequence.register(_MyType__List__i32) __all__.append('_MyType__List__i32') + + class _MyType__Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -731,7 +1130,166 @@ def __get_reflection__(): Set.register(_MyType__Set__i32) + __all__.append('_MyType__Set__i32') + + +class _MyType__Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, _MyType__Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = _MyType__Map__i32_i32._check_key_type_or_raise + check_val = _MyType__Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, _MyType__Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection___MyType__Map__i32_i32() + + +Mapping.register(_MyType__Map__i32_i32) +__all__.append('_MyType__Map__i32_i32') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + +class Map__i32_double(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_double): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_double._check_key_type_or_raise + check_val = Map__i32_double._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_double) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, (float, int)) + ): + raise TypeError(f"{item!r} is not of type float") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_double() + + +Mapping.register(Map__i32_double) +__all__.append('Map__i32_double') + + class List__Map__i32_double(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -776,3 +1334,58 @@ def __get_reflection__(): Sequence.register(List__Map__i32_double) __all__.append('List__Map__i32_double') + + +class Map__AnEnumRenamed_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__AnEnumRenamed_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__AnEnumRenamed_i32._check_key_type_or_raise + check_val = Map__AnEnumRenamed_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__AnEnumRenamed_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, _module_types.AnEnumRenamed) or + isinstance(key, thrift.py3.types.BadEnum) + ): + raise TypeError(f"{key!r} is not of type _module_types.AnEnumRenamed") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.AnEnumRenamed): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__AnEnumRenamed_i32() + + +Mapping.register(Map__AnEnumRenamed_i32) +__all__.append('Map__AnEnumRenamed_i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_empty/gen-py3/empty/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_empty/gen-py3/empty/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index fb938db00bfaf..314840088cd24 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_empty/gen-py3/empty/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_empty/gen-py3/empty/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module0/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module0/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 79af66ea0f254..d296f21fbf322 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module0/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module0/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -68,3 +68,5 @@ def __get_reflection__(): Sequence.register(List__Enum) __all__.append('List__Enum') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module1/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module1/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index a8478cda6e54a..84832e3000997 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module1/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module1/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -68,3 +68,5 @@ def __get_reflection__(): Sequence.register(List__Enum) __all__.append('List__Enum') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module2/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module2/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 31ab03147313d..531f08587c061 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module2/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/qualified/out/py3/gen-py3/module2/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/refs/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/refs/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index c67608771dac7..ab8928d4913f7 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/refs/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/refs/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,8 @@ def __get_reflection__(): Sequence.register(List__RecursiveStruct) __all__.append('List__RecursiveStruct') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -107,6 +109,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -145,7 +149,62 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + class List__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -186,3 +245,5 @@ def __get_reflection__(): Sequence.register(List__i64) __all__.append('List__i64') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/req-opt/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/req-opt/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 4e7bee45fd5b3..c4c30d1d59932 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/req-opt/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/req-opt/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -67,6 +67,8 @@ def __get_reflection__(): Sequence.register(List__bool) __all__.append('List__bool') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -107,3 +109,5 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/serialization_field_order/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/serialization_field_order/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 6bc70bfc61572..1584095892d94 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/serialization_field_order/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/serialization_field_order/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 1a58360ca8839..0b05c5c05dfcd 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3_module_structs/gen-py3/module_structs/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3_module_structs/gen-py3/module_structs/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 0d8db7dc2d054..dae65c62bc8ed 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3_module_structs/gen-py3/module_structs/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/single_file_service/out/py3_module_structs/gen-py3/module_structs/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/sink/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/sink/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 5e337a1c93250..cf1b3aec156b2 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/sink/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/sink/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index afe6d984c1021..c1d140ca22386 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/stream/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/templated-deserialize/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/templated-deserialize/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index f670d6317b8cf..1e322c7f41eba 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/templated-deserialize/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/templated-deserialize/out/py3/gen-py3/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -27,6 +27,58 @@ def get_types_reflection(): __all__ = [] +class Map__string_bool(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_bool): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_bool._check_key_type_or_raise + check_val = Map__string_bool._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_bool) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, bool) + ): + raise TypeError(f"{item!r} is not of type bool") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_bool() + + +Mapping.register(Map__string_bool) +__all__.append('Map__string_bool') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -65,7 +117,10 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -106,6 +161,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -150,6 +207,8 @@ def __get_reflection__(): Sequence.register(List__List__i32) __all__.append('List__List__i32') + + class List__List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -194,6 +253,164 @@ def __get_reflection__(): Sequence.register(List__List__List__i32) __all__.append('List__List__List__i32') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + +class Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, int]") + if not isinstance(item, _module_types.Map__string_i32): + item = _module_types.Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_i32') + + +class Map__string_Map__string_Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_Map__string_Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_Map__string_Map__string_i32._check_key_type_or_raise + check_val = Map__string_Map__string_Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_Map__string_Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[str, _typing.Mapping[str, int]]") + if not isinstance(item, _module_types.Map__string_Map__string_i32): + item = _module_types.Map__string_Map__string_i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_Map__string_Map__string_i32() + + +Mapping.register(Map__string_Map__string_Map__string_i32) +__all__.append('Map__string_Map__string_Map__string_i32') + + class List__Set__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -238,6 +455,60 @@ def __get_reflection__(): Sequence.register(List__Set__i32) __all__.append('List__Set__i32') + + +class Map__string_List__i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_List__i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_List__i32._check_key_type_or_raise + check_val = Map__string_List__i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_List__i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Sequence[int]") + if not isinstance(item, _module_types.List__i32): + item = _module_types.List__i32(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_List__i32() + + +Mapping.register(Map__string_List__i32) +__all__.append('Map__string_List__i32') + + class List__List__List__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -282,6 +553,8 @@ def __get_reflection__(): Sequence.register(List__List__List__List__i32) __all__.append('List__List__List__List__i32') + + class Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -320,7 +593,10 @@ def __get_reflection__(): Set.register(Set__bool) + __all__.append('Set__bool') + + class Set__Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -363,7 +639,10 @@ def __get_reflection__(): Set.register(Set__Set__bool) + __all__.append('Set__Set__bool') + + class Set__Set__Set__bool(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -406,7 +685,10 @@ def __get_reflection__(): Set.register(Set__Set__Set__bool) + __all__.append('Set__Set__Set__bool') + + class Set__List__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -449,7 +731,10 @@ def __get_reflection__(): Set.register(Set__List__i32) + __all__.append('Set__List__i32') + + class Set__string(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -490,7 +775,10 @@ def __get_reflection__(): Set.register(Set__string) + __all__.append('Set__string') + + class List__Set__string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -535,6 +823,120 @@ def __get_reflection__(): Sequence.register(List__Set__string) __all__.append('List__Set__string') + + +class Map__List__Set__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__List__Set__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__List__Set__string_string._check_key_type_or_raise + check_val = Map__List__Set__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__List__Set__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if key is None: + raise TypeError("None is not of the type _typing.Sequence[_typing.AbstractSet[str]]") + if not isinstance(key, _module_types.List__Set__string): + key = _module_types.List__Set__string(key) + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.List__Set__string): + return key + try: + return _module_types.List__Set__string(key) + except: + return None + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__List__Set__string_string() + + +Mapping.register(Map__List__Set__string_string) +__all__.append('Map__List__Set__string_string') + + +class Map__Set__List__i32_Map__List__Set__string_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__Set__List__i32_Map__List__Set__string_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__Set__List__i32_Map__List__Set__string_string._check_key_type_or_raise + check_val = Map__Set__List__i32_Map__List__Set__string_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__Set__List__i32_Map__List__Set__string_string) + + @staticmethod + def _check_key_type_or_raise(key): + if key is None: + raise TypeError("None is not of the type _typing.AbstractSet[_typing.Sequence[int]]") + if not isinstance(key, _module_types.Set__List__i32): + key = _module_types.Set__List__i32(key) + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, _module_types.Set__List__i32): + return key + try: + return _module_types.Set__List__i32(key) + except: + return None + + @staticmethod + def _check_val_type_or_raise(item): + if item is None: + raise TypeError("None is not of the type _typing.Mapping[_typing.Sequence[_typing.AbstractSet[str]], str]") + if not isinstance(item, _module_types.Map__List__Set__string_string): + item = _module_types.Map__List__Set__string_string(item) + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__Set__List__i32_Map__List__Set__string_string() + + +Mapping.register(Map__Set__List__i32_Map__List__Set__string_string) +__all__.append('Map__Set__List__i32_Map__List__Set__string_string') + + class List__Foo__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -575,6 +977,8 @@ def __get_reflection__(): Sequence.register(List__Foo__i64) __all__.append('List__Foo__i64') + + class List__Bar__double(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -615,6 +1019,8 @@ def __get_reflection__(): Sequence.register(List__Bar__double) __all__.append('List__Bar__double') + + class List__Baz__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -655,3 +1061,5 @@ def __get_reflection__(): Sequence.register(List__Baz__i32) __all__.append('List__Baz__i32') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/a/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/a/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index fc436db3adaf0..a7ac3f0e254b1 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/a/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/a/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -69,6 +69,8 @@ def __get_reflection__(): Sequence.register(List__c_C) __all__.append('List__c_C') + + class List__List__c_C(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -113,3 +115,5 @@ def __get_reflection__(): Sequence.register(List__List__c_C) __all__.append('List__List__c_C') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 3bddb0c5f81b2..fc5a3bdeea7db 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -68,3 +68,5 @@ def __get_reflection__(): Sequence.register(List__c_C) __all__.append('List__c_C') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b5cd8202e3e9d..373dd85ef2ecc 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_a/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 3bddb0c5f81b2..fc5a3bdeea7db 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/b/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -68,3 +68,5 @@ def __get_reflection__(): Sequence.register(List__c_C) __all__.append('List__c_C') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index b5cd8202e3e9d..373dd85ef2ecc 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/c/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/s/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/s/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 704fe93ccade8..888da2437df3f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/s/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/transitive-deps/out/py3_s/gen-py3/s/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/included/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/included/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index f755e8c8726c7..a80afc8d91d83 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/included/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/included/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -27,6 +27,58 @@ def get_types_reflection(): __all__ = [] +class std_unordered_map__Map__i32_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, std_unordered_map__Map__i32_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = std_unordered_map__Map__i32_string._check_key_type_or_raise + check_val = std_unordered_map__Map__i32_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, std_unordered_map__Map__i32_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__std_unordered_map__Map__i32_string() + + +Mapping.register(std_unordered_map__Map__i32_string) +__all__.append('std_unordered_map__Map__i32_string') + + class List__std_unordered_map__Map__i32_string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -71,3 +123,5 @@ def __get_reflection__(): Sequence.register(List__std_unordered_map__Map__i32_string) __all__.append('List__std_unordered_map__Map__i32_string') + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py index 73c2f3837075c..4374df3557917 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/types/out/py3/gen-py3/apache/thrift/fixtures/types/module/containers_FBTHRIFT_ONLY_DO_NOT_USE.py @@ -7,7 +7,7 @@ import thrift.py3.types import importlib -from collections.abc import Sequence, Set +from collections.abc import Mapping, Sequence, Set """ This is a helper module to define py3 container types. @@ -28,6 +28,58 @@ def get_types_reflection(): __all__ = [] +class std_unordered_map__Map__i32_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, std_unordered_map__Map__i32_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = std_unordered_map__Map__i32_string._check_key_type_or_raise + check_val = std_unordered_map__Map__i32_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, std_unordered_map__Map__i32_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__std_unordered_map__Map__i32_string() + + +Mapping.register(std_unordered_map__Map__i32_string) +__all__.append('std_unordered_map__Map__i32_string') + + class List__i64(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -68,6 +120,60 @@ def __get_reflection__(): Sequence.register(List__i64) __all__.append('List__i64') + + +class Map__binary_i64(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__binary_i64): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__binary_i64._check_key_type_or_raise + check_val = Map__binary_i64._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__binary_i64) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, bytes) + ): + raise TypeError(f"{key!r} is not of type bytes") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, bytes): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__binary_i64() + + +Mapping.register(Map__binary_i64) +__all__.append('Map__binary_i64') + + class List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -108,6 +214,8 @@ def __get_reflection__(): Sequence.register(List__i32) __all__.append('List__i32') + + class std_list__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -148,6 +256,8 @@ def __get_reflection__(): Sequence.register(std_list__List__i32) __all__.append('std_list__List__i32') + + class std_deque__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -188,6 +298,8 @@ def __get_reflection__(): Sequence.register(std_deque__List__i32) __all__.append('std_deque__List__i32') + + class folly_fbvector__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -228,6 +340,8 @@ def __get_reflection__(): Sequence.register(folly_fbvector__List__i32) __all__.append('folly_fbvector__List__i32') + + class folly_small_vector__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -268,6 +382,8 @@ def __get_reflection__(): Sequence.register(folly_small_vector__List__i32) __all__.append('folly_small_vector__List__i32') + + class folly_sorted_vector_set__Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -306,7 +422,62 @@ def __get_reflection__(): Set.register(folly_sorted_vector_set__Set__i32) + __all__.append('folly_sorted_vector_set__Set__i32') + + +class Map__i32_string(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_string): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_string._check_key_type_or_raise + check_val = Map__i32_string._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_string) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, str) + ): + raise TypeError(f"{item!r} is not of type str") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_string() + + +Mapping.register(Map__i32_string) +__all__.append('Map__i32_string') + + class std_list_int32_t__List__i32(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -347,6 +518,60 @@ def __get_reflection__(): Sequence.register(std_list_int32_t__List__i32) __all__.append('std_list_int32_t__List__i32') + + +class Map__string_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__string_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__string_i32._check_key_type_or_raise + check_val = Map__string_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__string_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, str) + ): + raise TypeError(f"{key!r} is not of type str") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, str): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__string_i32() + + +Mapping.register(Map__string_i32) +__all__.append('Map__string_i32') + + class List__std_unordered_map__Map__i32_string(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -391,6 +616,112 @@ def __get_reflection__(): Sequence.register(List__std_unordered_map__Map__i32_string) __all__.append('List__std_unordered_map__Map__i32_string') + + +class Map__i32_IncompleteMapDep(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_IncompleteMapDep): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_IncompleteMapDep._check_key_type_or_raise + check_val = Map__i32_IncompleteMapDep._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_IncompleteMapDep) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _apache_thrift_fixtures_types_module_types.IncompleteMapDep) + ): + raise TypeError(f"{item!r} is not of type _apache_thrift_fixtures_types_module_types.IncompleteMapDep") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_IncompleteMapDep() + + +Mapping.register(Map__i32_IncompleteMapDep) +__all__.append('Map__i32_IncompleteMapDep') + + +class std_unordered_map__Map__i32_CompleteMapDep(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = False + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, std_unordered_map__Map__i32_CompleteMapDep): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = std_unordered_map__Map__i32_CompleteMapDep._check_key_type_or_raise + check_val = std_unordered_map__Map__i32_CompleteMapDep._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, std_unordered_map__Map__i32_CompleteMapDep) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, _apache_thrift_fixtures_types_module_types.CompleteMapDep) + ): + raise TypeError(f"{item!r} is not of type _apache_thrift_fixtures_types_module_types.CompleteMapDep") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__std_unordered_map__Map__i32_CompleteMapDep() + + +Mapping.register(std_unordered_map__Map__i32_CompleteMapDep) +__all__.append('std_unordered_map__Map__i32_CompleteMapDep') + + class _std_list__List__IncompleteListDep(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -431,6 +762,8 @@ def __get_reflection__(): Sequence.register(_std_list__List__IncompleteListDep) __all__.append('_std_list__List__IncompleteListDep') + + class folly_small_vector__List__CompleteListDep(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -471,6 +804,8 @@ def __get_reflection__(): Sequence.register(folly_small_vector__List__CompleteListDep) __all__.append('folly_small_vector__List__CompleteListDep') + + class List__AdaptedListDep(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -511,6 +846,8 @@ def __get_reflection__(): Sequence.register(List__AdaptedListDep) __all__.append('List__AdaptedListDep') + + class List__DependentAdaptedListDep(thrift.py3.types.List): __module__ = _fbthrift__module_name__ __slots__ = () @@ -551,6 +888,8 @@ def __get_reflection__(): Sequence.register(List__DependentAdaptedListDep) __all__.append('List__DependentAdaptedListDep') + + class Set__i32(thrift.py3.types.Set): __module__ = _fbthrift__module_name__ __slots__ = () @@ -589,4 +928,59 @@ def __get_reflection__(): Set.register(Set__i32) + __all__.append('Set__i32') + + +class Map__i32_i32(thrift.py3.types.MapNew): + __module__ = _fbthrift__module_name__ + __slots__ = () + + _FBTHRIFT_USE_SORTED_REPR = True + + def __init__(self, items=None, private_ctor_token=None) -> None: + if private_ctor_token is thrift.py3.types._fbthrift_map_private_ctor: + _py_obj = items + elif isinstance(items, Map__i32_i32): + _py_obj = dict(items) + elif items is None: + _py_obj = dict() + else: + check_key = Map__i32_i32._check_key_type_or_raise + check_val = Map__i32_i32._check_val_type_or_raise + _py_obj = {check_key(k) : check_val(v) for k, v in items.items()} + + super().__init__(_py_obj, Map__i32_i32) + + @staticmethod + def _check_key_type_or_raise(key): + if not ( + isinstance(key, int) + ): + raise TypeError(f"{key!r} is not of type int") + return key + + @staticmethod + def _check_key_type_or_none(key): + if key is None: + return None + if isinstance(key, int): + return key + + @staticmethod + def _check_val_type_or_raise(item): + if not ( + isinstance(item, int) + ): + raise TypeError(f"{item!r} is not of type int") + return item + + @staticmethod + def __get_reflection__(): + return get_types_reflection().get_reflection__Map__i32_i32() + + +Mapping.register(Map__i32_i32) +__all__.append('Map__i32_i32') + + diff --git a/third-party/thrift/src/thrift/lib/py3/types.pxd b/third-party/thrift/src/thrift/lib/py3/types.pxd index 133cf8c488a8f..8caf60bebc2d9 100644 --- a/third-party/thrift/src/thrift/lib/py3/types.pxd +++ b/third-party/thrift/src/thrift/lib/py3/types.pxd @@ -123,6 +123,9 @@ cdef class Set(Container): cdef class Map(Container): pass +cdef class MapNew(Container): + cdef dict _py_obj + cdef object _child_cls cdef class StructFieldsSetter: cdef void set_field(StructFieldsSetter self, const char* name, object value) except * diff --git a/third-party/thrift/src/thrift/lib/py3/types.pyx b/third-party/thrift/src/thrift/lib/py3/types.pyx index 84ddf86a9684d..baaf5a5ffe110 100644 --- a/third-party/thrift/src/thrift/lib/py3/types.pyx +++ b/third-party/thrift/src/thrift/lib/py3/types.pyx @@ -579,6 +579,106 @@ cdef class Map(Container): except KeyError: return default + +cdef class _MapPrivateCtorToken: + pass + +_fbthrift_map_private_ctor = _MapPrivateCtorToken() + +@cython.auto_pickle(False) +cdef class MapNew(Container): + """ + Base class for pure python thrift maps + """ + def __init__(self, dict py_obj not None, child_cls not None): + self._py_obj = py_obj + self._child_cls = child_cls + + def __len__(MapNew self): + return len(self._py_obj) + + def __eq__(MapNew self, other): + if not isinstance(other, Mapping): + return False + if len(self._py_obj) != len(other): + return False + + for key in self._py_obj: + if key not in other: + return False + if other[key] != self._py_obj[key]: + return False + + return True + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + if not self._fbthrift_hash: + self._fbthrift_hash = hash(tuple(self.items())) + return self._fbthrift_hash + + def __repr__(self): + if not self: + return 'i{}' + # print in sorted order for backward compatibility + if self._child_cls._FBTHRIFT_USE_SORTED_REPR: + key_val = sorted(self.items(), key=lambda x: x[0]) + else: + key_val = self.items() + return f'i{{{", ".join(map(lambda i: f"{repr(i[0])}: {repr(i[1])}", key_val))}}}' + + def __reduce__(self): + return (type(self), (dict(self._py_obj), )) + + def __copy__(self): + return self._child_cls( + dict(self._py_obj), + private_ctor_token=_fbthrift_map_private_ctor + ) + + def __contains__(self, key): + key = self._child_cls._check_key_type_or_none(key) + if not self or key is None: + return False + return key in self._py_obj + + def __getitem__(self, key): + err = KeyError(f'{key}') + key = self._child_cls._check_key_type_or_none(key) + if key is None: + raise err + item = self._py_obj.get(key) + if item is None: + raise err + return item + + def get(self, key, default=None): + try: + return self._py_obj[key] + except KeyError: + return default + + def __iter__(self): + if not self: + return + yield from self._py_obj + + def keys(self): + return self.__iter__() + + def values(self): + if not self: + return + yield from self._py_obj.values() + + def items(self): + if not self: + return + yield from self._py_obj.items() + + CompiledEnum = _fbthrift_python_Enum Enum = _fbthrift_python_Enum # I wanted to call the base class Enum, but there is a cython bug