Skip to content

Commit

Permalink
Include immutable or mutable modules correctly.
Browse files Browse the repository at this point in the history
Summary:
# What?
{D65709445} enables pyre type checks on all generated thrift python targets. With the changes in this diff,
```
buck2 test thrift/test/thrift-python:struct_test_thrift-python-types-type-checking
```
fails with
```
buck-out/v2/gen/fbcode/3cc3cae8ebb1ba74/thrift/test/thrift-python/__struct_test_thrift-python-struct_test.thrift__/out/gen-python/thrift/test/thrift_python/struct_test/thrift_mutable_types.pyi:661:31 Unbound name [10]: Name `_fbthrift__thrift__test__thrift_python__included__thrift_mutable_types` is used but not defined in the current scope.
```
# Why?
thrift_mutable_types.pyi files included the mangled files that ended in `thrift_types` rather than `thrift_mutable_types`.

# Fix
Correctly include `thrift_types` for immutable modules and `thrift_mutable_types` for mutable modules.

Reviewed By: yoney

Differential Revision: D66050015

fbshipit-source-id: b6ff7a5aa9de333f15a0b014f6d4ce7d4f884178
  • Loading branch information
Satish Kumar authored and facebook-github-bot committed Nov 18, 2024
1 parent 1c160be commit ed31676
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {{program:base_library_package}}.mutable_containers as _fbthrift_python_m
{{#program:include_namespaces}}
{{#has_types?}}

import {{included_module_path}}.thrift_types as {{included_module_mangle}}__thrift_types
import {{included_module_path}}.{{> types/types_import_path}} as {{included_module_mangle}}__{{> types/types_import_path}}
{{/has_types?}}
{{/program:include_namespaces}}
{{#program:adapter_type_hint_modules}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import includes.thrift_types as _fbthrift__includes__thrift_types
import includes.thrift_mutable_types as _fbthrift__includes__thrift_mutable_types


class _fbthrift_compatible_with_MyStruct:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import includes.thrift_types as _fbthrift__includes__thrift_types
import includes.thrift_mutable_types as _fbthrift__includes__thrift_mutable_types


class _fbthrift_compatible_with_MyStruct:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import foo.thrift_types as _fbthrift__foo__thrift_types
import foo.thrift_mutable_types as _fbthrift__foo__thrift_mutable_types


class _fbthrift_compatible_with_Fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import foo.thrift_types as _fbthrift__foo__thrift_types
import foo.thrift_mutable_types as _fbthrift__foo__thrift_mutable_types


class _fbthrift_compatible_with_Fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import test.fixtures.another_interactions.shared.thrift_types as _fbthrift__test__fixtures__another_interactions__shared__thrift_types
import test.fixtures.another_interactions.shared.thrift_mutable_types as _fbthrift__test__fixtures__another_interactions__shared__thrift_mutable_types


class _fbthrift_compatible_with_CustomException:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import test.fixtures.another_interactions.shared.thrift_types as _fbthrift__test__fixtures__another_interactions__shared__thrift_types
import test.fixtures.another_interactions.shared.thrift_mutable_types as _fbthrift__test__fixtures__another_interactions__shared__thrift_mutable_types


class _fbthrift_compatible_with_CustomException:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import apache.thrift.type.id.thrift_types as _fbthrift__apache__thrift__type__id__thrift_types
import apache.thrift.type.id.thrift_mutable_types as _fbthrift__apache__thrift__type__id__thrift_mutable_types

import apache.thrift.type.schema.thrift_types as _fbthrift__apache__thrift__type__schema__thrift_types
import apache.thrift.type.schema.thrift_mutable_types as _fbthrift__apache__thrift__type__schema__thrift_mutable_types

import test.fixtures.python_capi.serialized_dep.thrift_types as _fbthrift__test__fixtures__python_capi__serialized_dep__thrift_types
import test.fixtures.python_capi.serialized_dep.thrift_mutable_types as _fbthrift__test__fixtures__python_capi__serialized_dep__thrift_mutable_types

import test.fixtures.python_capi.thrift_dep.thrift_types as _fbthrift__test__fixtures__python_capi__thrift_dep__thrift_types
import test.fixtures.python_capi.thrift_dep.thrift_mutable_types as _fbthrift__test__fixtures__python_capi__thrift_dep__thrift_mutable_types

class _fbthrift_compatible_with_MyEnum:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import apache.thrift.type.id.thrift_types as _fbthrift__apache__thrift__type__id__thrift_types
import apache.thrift.type.id.thrift_mutable_types as _fbthrift__apache__thrift__type__id__thrift_mutable_types

import apache.thrift.type.schema.thrift_types as _fbthrift__apache__thrift__type__schema__thrift_types
import apache.thrift.type.schema.thrift_mutable_types as _fbthrift__apache__thrift__type__schema__thrift_mutable_types

import test.fixtures.python_capi.serialized_dep.thrift_types as _fbthrift__test__fixtures__python_capi__serialized_dep__thrift_types
import test.fixtures.python_capi.serialized_dep.thrift_mutable_types as _fbthrift__test__fixtures__python_capi__serialized_dep__thrift_mutable_types

import test.fixtures.python_capi.thrift_dep.thrift_types as _fbthrift__test__fixtures__python_capi__thrift_dep__thrift_types
import test.fixtures.python_capi.thrift_dep.thrift_mutable_types as _fbthrift__test__fixtures__python_capi__thrift_dep__thrift_mutable_types

class _fbthrift_compatible_with_MyEnum:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import include.thrift_types as _fbthrift__include__thrift_types
import include.thrift_mutable_types as _fbthrift__include__thrift_mutable_types

class _fbthrift_compatible_with_Result:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import apache.thrift.fixtures.types.included.thrift_types as _fbthrift__apache__thrift__fixtures__types__included__thrift_types
import apache.thrift.fixtures.types.included.thrift_mutable_types as _fbthrift__apache__thrift__fixtures__types__included__thrift_mutable_types

class _fbthrift_compatible_with_has_bitwise_ops:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers

import apache.thrift.fixtures.types.included.thrift_types as _fbthrift__apache__thrift__fixtures__types__included__thrift_types
import apache.thrift.fixtures.types.included.thrift_mutable_types as _fbthrift__apache__thrift__fixtures__types__included__thrift_mutable_types

class _fbthrift_compatible_with_has_bitwise_ops:
pass
Expand Down

0 comments on commit ed31676

Please sign in to comment.