Skip to content

Commit

Permalink
Import the module for included thrift file
Browse files Browse the repository at this point in the history
Summary: Import the module for included thrift file for mutable types

Differential Revision: D62720127

fbshipit-source-id: e7e19315437013239255aa6004b56c7f2f9c5141
  • Loading branch information
yoney authored and facebook-github-bot committed Sep 16, 2024
1 parent 1c11549 commit 0658b61
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ import {{program:base_library_package}}.mutable_exceptions as _fbthrift_python_m
import {{program:base_library_package}}.mutable_typeinfos as _fbthrift_python_mutable_typeinfos
{{/program:generate_mutable_types}}

{{^program:generate_mutable_types}}
{{#program:include_namespaces}}
{{#has_types?}}

import {{included_module_path}}.thrift_types
import {{included_module_path}}.{{> types/types_import_path}}
{{/has_types?}}
{{/program:include_namespaces}}
{{/program:generate_mutable_types}}
{{#program:adapter_modules}}
import {{module_path}}
{{/program:adapter_modules}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import includes.thrift_mutable_types


class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta):
_fbthrift_SPEC = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import foo.thrift_mutable_types


class Fields(metaclass=_fbthrift_python_mutable_types.MutableStructMeta):
_fbthrift_SPEC = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import test.fixtures.another_interactions.shared.thrift_mutable_types


class CustomException(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta):
_fbthrift_SPEC = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import apache.thrift.type.id.thrift_mutable_types

import apache.thrift.type.schema.thrift_mutable_types

import test.fixtures.python_capi.serialized_dep.thrift_mutable_types

import test.fixtures.python_capi.thrift_dep.thrift_mutable_types


class MyStruct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta):
_fbthrift_SPEC = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import include.thrift_mutable_types


class CustomException(metaclass=_fbthrift_python_mutable_exceptions.MutableGeneratedErrorMeta):
_fbthrift_SPEC = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import thrift.python.mutable_typeinfos as _fbthrift_python_mutable_typeinfos


import apache.thrift.fixtures.types.included.thrift_mutable_types


class empty_struct(metaclass=_fbthrift_python_mutable_types.MutableStructMeta):
_fbthrift_SPEC = (
Expand Down
22 changes: 22 additions & 0 deletions third-party/thrift/src/thrift/test/thrift-python/included.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

namespace py3 thrift.test.thrift_python

union TestUnion {
1: i32 i32_field;
2: string string_field;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

include "thrift/annotation/python.thrift"
include "thrift/test/thrift-python/included.thrift"

namespace py3 thrift.test.thrift_python

Expand Down Expand Up @@ -160,6 +161,7 @@ union TestUnion {
struct TestStructWithUnionField {
1: i32 i32_field;
2: TestUnion union_field;
3: included.TestUnion union_field_from_included;
}

exception TestExceptionAllThriftPrimitiveTypes {
Expand Down

0 comments on commit 0658b61

Please sign in to comment.