{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!
Generated Python typestubs for Thrift types
}}
{{> common/auto_generated_py}}

import typing as _typing

{{#program:unions?}}
import enum

{{/program:unions?}}
import folly.iobuf as _fbthrift_iobuf
{{#program:generate_unified_thrift_python_type_hints?}}
import {{program:module_path}}.thrift_abstract_types
{{/program:generate_unified_thrift_python_type_hints?}}
import {{program:base_library_package}}.types as _fbthrift_python_types
{{#program:generate_immutable_types}}
import {{program:base_library_package}}.exceptions as _fbthrift_python_exceptions
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
import {{program:base_library_package}}.mutable_types as _fbthrift_python_mutable_types
import {{program:base_library_package}}.mutable_exceptions as _fbthrift_python_mutable_exceptions
import {{program:base_library_package}}.mutable_containers as _fbthrift_python_mutable_containers
{{/program:generate_mutable_types}}
{{#program:include_namespaces}}
{{#has_types?}}

import {{included_module_path}}.thrift_types
{{/has_types?}}
{{/program:include_namespaces}}
{{#program:adapter_type_hint_modules}}
import {{module_path}}
{{/program:adapter_type_hint_modules}}
{{#program:enums}}

class _fbthrift_compatible_with_{{enum:name}}:
    pass


class {{enum:name}}(_fbthrift_python_types.{{!
        }}{{#enum:flags?}}Flag{{/enum:flags?}}{{!
        }}{{^enum:flags?}}Enum, int{{/enum:flags?}}{{!
        }}{{#program:generate_unified_thrift_python_type_hints?}}{{!
        }}, {{program:module_path}}.thrift_abstract_types.{{enum:name}}{{!
        }}{{/program:generate_unified_thrift_python_type_hints?}}{{!
        }}, _fbthrift_compatible_with_{{enum:name}}):
    {{#enum:values}}
    {{enum_value:py_name}}: {{enum:name}} = ...
    {{/enum:values}}
    {{#enum:legacy_api?}}
    def _to_python(self) -> {{enum:name}}: ...
    def _to_py3(self) -> "{{program:module_path}}.types.{{enum:name}}": ...  # type: ignore
    def _to_py_deprecated(self) -> int: ...
    {{/enum:legacy_api?}}
{{/program:enums}}
{{#program:structs}}


class _fbthrift_compatible_with_{{> structs/unadapted_name}}:
    pass


class {{> structs/unadapted_name}}({{!
        }}{{#struct:union?}}{{> types/union_base }}{{/struct:union?}}{{!
        }}{{^struct:union?}}{{!
        }}{{#struct:exception?}}{{> types/exception_base }}{{/struct:exception?}}{{!
        }}{{^struct:exception?}}{{> types/struct_base }}{{/struct:exception?}}{{!
        }}{{/struct:union?}}{{!
        }}, _fbthrift_compatible_with_{{> structs/unadapted_name}}{{!
        }}{{#program:generate_unified_thrift_python_type_hints?}}{{!
        }}, {{program:module_path}}.thrift_abstract_types.{{struct:py_name}}{{!
        }}{{/program:generate_unified_thrift_python_type_hints?}}{{!
        }}):
    {{#program:generate_immutable_types}}{{!
    }}{{#struct:fields_ordered_by_id}}
    {{field:py_name}}: _typing.Final[{{> fields/field_type_pyi}}] = ...
    {{/struct:fields_ordered_by_id}}{{!
    }}{{/program:generate_immutable_types}}{{!
    }}{{#program:generate_mutable_types}}{{!
    }}{{#struct:fields_ordered_by_id}}{{!
    }}{{^field:is_container_type}}
    {{field:py_name}}: {{> fields/field_type_pyi}} = ...
    {{/field:is_container_type}}{{!
    }}{{#field:is_container_type}}

    @property
    def {{field:py_name}}(self) -> {{> fields/field_type_pyi}}: ...
    @{{field:py_name}}.setter
    def {{field:py_name}}(self, value: {{> fields/field_type_pyi}} | {{> types/thrift_container_wrapper}}): ...

    {{/field:is_container_type}}{{!
    }}{{/struct:fields_ordered_by_id}}{{!
    }}{{/program:generate_mutable_types}}
    def __init__(
        self,{{#struct:fields?}} *{{/struct:fields?}}{{!
        }}{{> types/init_and_call_arg_types}}
    ) -> None: ...

    {{#struct:plain?}}
    def __call__(
        self,{{#struct:fields?}} *{{/struct:fields?}}{{!
        }}{{> types/init_and_call_arg_types}}
    ) -> _typing.Self: ...
    {{/struct:plain?}}
    {{#struct:union?}}

{{^program:generate_unified_thrift_python_type_hints?}}
{{#program:generate_immutable_types}}
    class Type(enum.Enum):
        EMPTY: {{> structs/unadapted_name}}.Type = ...
    {{#struct:fields_ordered_by_id}}
        {{field:py_name}}: {{> structs/unadapted_name}}.Type = ...
    {{/struct:fields_ordered_by_id}}
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
    class FbThriftUnionFieldEnum(enum.Enum):
        EMPTY: {{> structs/unadapted_name}}.FbThriftUnionFieldEnum = ...
    {{#struct:fields_ordered_by_id}}
        {{field:py_name}}: {{> structs/unadapted_name}}.FbThriftUnionFieldEnum = ...
    {{/struct:fields_ordered_by_id}}
{{/program:generate_mutable_types}}

{{#program:generate_immutable_types}}
    FbThriftUnionFieldEnum = Type
{{/program:generate_immutable_types}}
{{/program:generate_unified_thrift_python_type_hints?}}
{{#program:generate_unified_thrift_python_type_hints?}}
{{#program:generate_immutable_types}}
    Type = FbThriftUnionFieldEnum
{{/program:generate_immutable_types}}
{{/program:generate_unified_thrift_python_type_hints?}}

{{#program:generate_immutable_types}}
    @classmethod
    def fromValue(cls, value: {{ > types/field_value_pep484_union_type}}) -> {{> structs/unadapted_name}}: ...
    value: _typing.Final[{{ > types/field_value_pep484_union_type}}]
    type: _typing.Final[Type]
    def get_type(self) -> Type:...
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
    fbthrift_current_value: _typing.Final[{{ > types/field_value_pep484_union_type}}]
    fbthrift_current_field: _typing.Final[FbThriftUnionFieldEnum]
    def get_type(self) -> FbThriftUnionFieldEnum:...
{{/program:generate_mutable_types}}
    {{/struct:union?}}
    {{^struct:union?}}
    def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Union[{{^struct:fields_ordered_by_id}}None{{/struct:fields_ordered_by_id}}{{!
        }}{{#struct:fields_ordered_by_id}}{{^first?}}, {{/first?}}{{> fields/adapted_type}}{{!
        }}{{/struct:fields_ordered_by_id}}]]]: ...
    {{/struct:union?}}
    {{#struct:legacy_api?}}
{{#program:generate_immutable_types}}
    def _to_python(self) -> _typing.Self: ...
{{#program:generate_to_mutable_python_conversion_methods?}}
    def _to_mutable_python(self) -> "{{program:module_path}}.thrift_mutable_types.{{> structs/unadapted_name}}": ...  # type: ignore
{{/program:generate_to_mutable_python_conversion_methods?}}
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
    def _to_python(self) -> "{{program:module_path}}.thrift_types.{{> structs/unadapted_name}}": ...  # type: ignore
    def _to_mutable_python(self) -> _typing.Self: ...
{{/program:generate_mutable_types}}
    def _to_py3(self) -> "{{program:module_path}}.types.{{> structs/unadapted_name}}": ...  # type: ignore
    def _to_py_deprecated(self) -> "{{program:py_deprecated_module_path}}.ttypes.{{> structs/unadapted_name}}": ...  # type: ignore
    {{/struct:legacy_api?}}
{{#struct:has_adapter?}}
{{struct:py_name}} = {{adapter:type_hint}}{{#adapter:is_generic?}}[{{> structs/unadapted_name}}]{{/adapter:is_generic?}}
{{/struct:has_adapter?}}{{!
}}{{/program:structs}}
{{#program:constants?}}

{{#program:constants}}

{{#constant:has_adapter?}}_fbthrift_unadapted_{{/constant:has_adapter?}}{{constant:name}}: {{#constant:type}}{{!
    }}{{> types/typedef_const_pep484_type}}{{!
}}{{/constant:type}} = ...
{{#constant:has_adapter?}}
{{constant:name}}: {{constant:adapter_type_hint}} = ...
{{/constant:has_adapter?}}
{{/program:constants}}
{{/program:constants?}}
{{#program:typedefs?}}

{{#program:typedefs}}
{{typedef:name}} = {{#typedef:has_adapter?}}{{!
    }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#typedef:type}}{{> types/typedef_const_pep484_type}}{{/typedef:type}}]{{/adapter:is_generic?}}{{!
}}{{/typedef:has_adapter?}}{{!
}}{{^typedef:has_adapter?}}{{!
    }}{{#typedef:type}}{{> types/typedef_const_pep484_type}}{{/typedef:type}}{{!
}}{{/typedef:has_adapter?}}
{{/program:typedefs}}
{{/program:typedefs?}}
{{#program:services?}}
{{#program:services}}
{{> types/service_arg_types_pyi}}
{{#service:interactions}}
{{> types/service_arg_types_pyi}}
{{/service:interactions}}
{{/program:services}}
{{/program:services?}}
