Skip to content

Commit 2a58d40

Browse files
Flameeyesfacebook-github-bot
authored andcommitted
Don't define properties and proprety setters for fields in Thrift Unions.
Summary: Thrift Unions do not provide field-level attributes, and rather require using the explicit getter and setter methods, unlike structures. This can generate confusion in the users as perfectly valid types lead to runtime failures. Reviewed By: joshkehn Differential Revision: D52565429 fbshipit-source-id: 7a33047527ec36f33ca24a879e22902acdd038c5
1 parent 2bda5b8 commit 2a58d40

File tree

5 files changed

+2
-76
lines changed

5 files changed

+2
-76
lines changed

thrift/compiler/generate/templates/pyi/ttypes.pyi.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class {{struct:name}}{{#struct:exception?}}(Thrift.TException){{/struct:exceptio
6060
) -> None:
6161
...
6262

63+
{{^struct:union?}}
6364
{{#struct:fields}}
6465
{{#field:type}}
6566
@__property__
@@ -69,6 +70,7 @@ class {{struct:name}}{{#struct:exception?}}(Thrift.TException){{/struct:exceptio
6970
def {{field:py_name}}(self, value: {{> common/OptionalFieldType}}) -> None: ...
7071
{{/field:type}}
7172
{{/struct:fields}}
73+
{{/struct:union?}}
7274

7375
{{#struct:union?}}
7476
def getType(self) -> int: ...

thrift/compiler/test/fixtures/adapter/gen-py/module/ttypes.pyi

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

thrift/compiler/test/fixtures/constants/gen-py/module/ttypes.pyi

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

thrift/compiler/test/fixtures/pyi/gen-py/simple/example/ttypes.pyi

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

thrift/compiler/test/fixtures/pyi/gen-py/simple/example_asyncio/ttypes.pyi

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)