Skip to content

Commit d43ab24

Browse files
ahilgerfacebook-github-bot
authored andcommitted
update .pyi to reflect typing merger
Summary: Now that enums are merged at runtime, we should update the typing to reflect that. Reviewed By: prakashgayasen Differential Revision: D72901329 fbshipit-source-id: 4463ecf66fcaf4b20049f47190291a07050fa906
1 parent 6e147d3 commit d43ab24

File tree

81 files changed

+115
-666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+115
-666
lines changed

third-party/thrift/src/thrift/compiler/generate/templates/py3/types.pyi.mustache

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,9 @@ import {{> common/thrift_types_module_path}}
4242

4343

4444
{{#program:enums}}
45-
class {{enum:name}}(thrift.python.types.{{^enum:flags?}}Enum, int{{!
46-
}}{{/enum:flags?}}{{!
47-
}}{{#enum:flags?}}Flag{{/enum:flags?}}):
48-
{{#enum:values}}
49-
{{enum_value:py_name}}: {{enum:name}} = ...
50-
{{/enum:values}}
51-
{{!TODO: accommodate root_module_prefix}}
52-
def _to_python(self) -> {{> common/thrift_types_module_path}}.{{enum:name}}: ...
53-
def _to_py3(self) -> {{enum:name}}: ...
54-
def _to_py_deprecated(self) -> int: ...
55-
def __int__(self) -> int: ...
56-
def __index__(self) -> int: ...
57-
58-
45+
{{enum:name}} = {{> common/thrift_types_module_path}}.{{enum:name}}
5946
{{/program:enums}}
47+
6048
{{#program:filtered_structs}}
6149
{{#struct:union?}}
6250
_{{struct:name}}ValueType = _typing.Union[None, {{#struct:py3_fields}}{{^first?}}, {{/first?}}{{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/struct:py3_fields}}]

third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/py3/gen-py3/module/types.pyi

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ import itertools
1717
import module.thrift_types
1818

1919

20-
class MyEnum(thrift.python.types.Enum, int):
21-
MyValue1: MyEnum = ...
22-
MyValue2: MyEnum = ...
23-
DOMAIN: MyEnum = ...
24-
def _to_python(self) -> module.thrift_types.MyEnum: ...
25-
def _to_py3(self) -> MyEnum: ...
26-
def _to_py_deprecated(self) -> int: ...
27-
def __int__(self) -> int: ...
28-
def __index__(self) -> int: ...
29-
20+
MyEnum = module.thrift_types.MyEnum
3021

3122
class MyStructNestedAnnotation(thrift.py3.types.Struct, _typing.Hashable):
3223
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/basic-enum/out/py3/gen-py3/test/fixtures/enumstrict/module/types.pyi

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,10 @@ import itertools
1717
import test.fixtures.enumstrict.module.thrift_types
1818

1919

20-
class EmptyEnum(thrift.python.types.Enum, int):
21-
def _to_python(self) -> test.fixtures.enumstrict.module.thrift_types.EmptyEnum: ...
22-
def _to_py3(self) -> EmptyEnum: ...
23-
def _to_py_deprecated(self) -> int: ...
24-
def __int__(self) -> int: ...
25-
def __index__(self) -> int: ...
26-
27-
28-
class MyEnum(thrift.python.types.Enum, int):
29-
ONE: MyEnum = ...
30-
TWO: MyEnum = ...
31-
def _to_python(self) -> test.fixtures.enumstrict.module.thrift_types.MyEnum: ...
32-
def _to_py3(self) -> MyEnum: ...
33-
def _to_py_deprecated(self) -> int: ...
34-
def __int__(self) -> int: ...
35-
def __index__(self) -> int: ...
36-
37-
38-
class MyUseIntrinsicDefaultEnum(thrift.python.types.Enum, int):
39-
ZERO: MyUseIntrinsicDefaultEnum = ...
40-
ONE: MyUseIntrinsicDefaultEnum = ...
41-
TWO: MyUseIntrinsicDefaultEnum = ...
42-
def _to_python(self) -> test.fixtures.enumstrict.module.thrift_types.MyUseIntrinsicDefaultEnum: ...
43-
def _to_py3(self) -> MyUseIntrinsicDefaultEnum: ...
44-
def _to_py_deprecated(self) -> int: ...
45-
def __int__(self) -> int: ...
46-
def __index__(self) -> int: ...
47-
48-
49-
class MyBigEnum(thrift.python.types.Enum, int):
50-
UNKNOWN: MyBigEnum = ...
51-
ONE: MyBigEnum = ...
52-
TWO: MyBigEnum = ...
53-
THREE: MyBigEnum = ...
54-
FOUR: MyBigEnum = ...
55-
FIVE: MyBigEnum = ...
56-
SIX: MyBigEnum = ...
57-
SEVEN: MyBigEnum = ...
58-
EIGHT: MyBigEnum = ...
59-
NINE: MyBigEnum = ...
60-
TEN: MyBigEnum = ...
61-
ELEVEN: MyBigEnum = ...
62-
TWELVE: MyBigEnum = ...
63-
THIRTEEN: MyBigEnum = ...
64-
FOURTEEN: MyBigEnum = ...
65-
FIFTEEN: MyBigEnum = ...
66-
SIXTEEN: MyBigEnum = ...
67-
SEVENTEEN: MyBigEnum = ...
68-
EIGHTEEN: MyBigEnum = ...
69-
NINETEEN: MyBigEnum = ...
70-
def _to_python(self) -> test.fixtures.enumstrict.module.thrift_types.MyBigEnum: ...
71-
def _to_py3(self) -> MyBigEnum: ...
72-
def _to_py_deprecated(self) -> int: ...
73-
def __int__(self) -> int: ...
74-
def __index__(self) -> int: ...
75-
20+
EmptyEnum = test.fixtures.enumstrict.module.thrift_types.EmptyEnum
21+
MyEnum = test.fixtures.enumstrict.module.thrift_types.MyEnum
22+
MyUseIntrinsicDefaultEnum = test.fixtures.enumstrict.module.thrift_types.MyUseIntrinsicDefaultEnum
23+
MyBigEnum = test.fixtures.enumstrict.module.thrift_types.MyBigEnum
7624

7725
class MyStruct(thrift.py3.types.Struct, _typing.Hashable):
7826
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/basic-stack-arguments/out/py3/gen-py3/module/types.pyi

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ import itertools
1717
import module.thrift_types
1818

1919

20-
class MyEnum(thrift.python.types.Enum, int):
21-
MyValue1: MyEnum = ...
22-
MyValue2: MyEnum = ...
23-
def _to_python(self) -> module.thrift_types.MyEnum: ...
24-
def _to_py3(self) -> MyEnum: ...
25-
def _to_py_deprecated(self) -> int: ...
26-
def __int__(self) -> int: ...
27-
def __index__(self) -> int: ...
28-
20+
MyEnum = module.thrift_types.MyEnum
2921

3022
class MyStruct(thrift.py3.types.Struct, _typing.Hashable):
3123
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3/gen-py3/test/fixtures/basic/module/types.pyi

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,8 @@ import itertools
1717
import test.fixtures.basic.module.thrift_types
1818

1919

20-
class MyEnum(thrift.python.types.Enum, int):
21-
MyValue1: MyEnum = ...
22-
MyValue2: MyEnum = ...
23-
def _to_python(self) -> test.fixtures.basic.module.thrift_types.MyEnum: ...
24-
def _to_py3(self) -> MyEnum: ...
25-
def _to_py_deprecated(self) -> int: ...
26-
def __int__(self) -> int: ...
27-
def __index__(self) -> int: ...
28-
29-
30-
class HackEnum(thrift.python.types.Enum, int):
31-
Value1: HackEnum = ...
32-
Value2: HackEnum = ...
33-
def _to_python(self) -> test.fixtures.basic.module.thrift_types.HackEnum: ...
34-
def _to_py3(self) -> HackEnum: ...
35-
def _to_py_deprecated(self) -> int: ...
36-
def __int__(self) -> int: ...
37-
def __index__(self) -> int: ...
38-
20+
MyEnum = test.fixtures.basic.module.thrift_types.MyEnum
21+
HackEnum = test.fixtures.basic.module.thrift_types.HackEnum
3922

4023
class MyStruct(thrift.py3.types.Struct, _typing.Hashable):
4124
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/py3_inplace/gen-py3/test/fixtures/basic/module/types.pyi

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,8 @@ import itertools
1717
import test.fixtures.basic.module.thrift_types
1818

1919

20-
class MyEnum(thrift.python.types.Enum, int):
21-
MyValue1: MyEnum = ...
22-
MyValue2: MyEnum = ...
23-
def _to_python(self) -> test.fixtures.basic.module.thrift_types.MyEnum: ...
24-
def _to_py3(self) -> MyEnum: ...
25-
def _to_py_deprecated(self) -> int: ...
26-
def __int__(self) -> int: ...
27-
def __index__(self) -> int: ...
28-
29-
30-
class HackEnum(thrift.python.types.Enum, int):
31-
Value1: HackEnum = ...
32-
Value2: HackEnum = ...
33-
def _to_python(self) -> test.fixtures.basic.module.thrift_types.HackEnum: ...
34-
def _to_py3(self) -> HackEnum: ...
35-
def _to_py_deprecated(self) -> int: ...
36-
def __int__(self) -> int: ...
37-
def __index__(self) -> int: ...
38-
20+
MyEnum = test.fixtures.basic.module.thrift_types.MyEnum
21+
HackEnum = test.fixtures.basic.module.thrift_types.HackEnum
3922

4023
class MyStruct(thrift.py3.types.Struct, _typing.Hashable):
4124
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/py3/gen-py3/module/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import itertools
1717
import module.thrift_types
1818

1919

20+
2021
_ComplexUnionValueType = _typing.Union[None, int, str, _typing.Sequence[int], _typing.Sequence[str], _typing.Mapping[int, str], str]
2122

2223
class ComplexUnion(thrift.py3.types.Union, _typing.Hashable):

third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3/gen-py3/module/types.pyi

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,9 @@ import itertools
1717
import module.thrift_types
1818

1919

20-
class EmptyEnum(thrift.python.types.Enum, int):
21-
def _to_python(self) -> module.thrift_types.EmptyEnum: ...
22-
def _to_py3(self) -> EmptyEnum: ...
23-
def _to_py_deprecated(self) -> int: ...
24-
def __int__(self) -> int: ...
25-
def __index__(self) -> int: ...
26-
27-
28-
class City(thrift.python.types.Enum, int):
29-
NYC: City = ...
30-
MPK: City = ...
31-
SEA: City = ...
32-
LON: City = ...
33-
def _to_python(self) -> module.thrift_types.City: ...
34-
def _to_py3(self) -> City: ...
35-
def _to_py_deprecated(self) -> int: ...
36-
def __int__(self) -> int: ...
37-
def __index__(self) -> int: ...
38-
39-
40-
class Company(thrift.python.types.Enum, int):
41-
FACEBOOK: Company = ...
42-
WHATSAPP: Company = ...
43-
OCULUS: Company = ...
44-
INSTAGRAM: Company = ...
45-
__FRIEND__FEED: Company = ...
46-
def _to_python(self) -> module.thrift_types.Company: ...
47-
def _to_py3(self) -> Company: ...
48-
def _to_py_deprecated(self) -> int: ...
49-
def __int__(self) -> int: ...
50-
def __index__(self) -> int: ...
51-
20+
EmptyEnum = module.thrift_types.EmptyEnum
21+
City = module.thrift_types.City
22+
Company = module.thrift_types.Company
5223

5324
class Internship(thrift.py3.types.Struct, _typing.Hashable):
5425
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/constants/out/py3_inplace/gen-py3/module/types.pyi

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,9 @@ import itertools
1717
import module.thrift_types
1818

1919

20-
class EmptyEnum(thrift.python.types.Enum, int):
21-
def _to_python(self) -> module.thrift_types.EmptyEnum: ...
22-
def _to_py3(self) -> EmptyEnum: ...
23-
def _to_py_deprecated(self) -> int: ...
24-
def __int__(self) -> int: ...
25-
def __index__(self) -> int: ...
26-
27-
28-
class City(thrift.python.types.Enum, int):
29-
NYC: City = ...
30-
MPK: City = ...
31-
SEA: City = ...
32-
LON: City = ...
33-
def _to_python(self) -> module.thrift_types.City: ...
34-
def _to_py3(self) -> City: ...
35-
def _to_py_deprecated(self) -> int: ...
36-
def __int__(self) -> int: ...
37-
def __index__(self) -> int: ...
38-
39-
40-
class Company(thrift.python.types.Enum, int):
41-
FACEBOOK: Company = ...
42-
WHATSAPP: Company = ...
43-
OCULUS: Company = ...
44-
INSTAGRAM: Company = ...
45-
__FRIEND__FEED: Company = ...
46-
def _to_python(self) -> module.thrift_types.Company: ...
47-
def _to_py3(self) -> Company: ...
48-
def _to_py_deprecated(self) -> int: ...
49-
def __int__(self) -> int: ...
50-
def __index__(self) -> int: ...
51-
20+
EmptyEnum = module.thrift_types.EmptyEnum
21+
City = module.thrift_types.City
22+
Company = module.thrift_types.Company
5223

5324
class Internship(thrift.py3.types.Struct, _typing.Hashable):
5425
class __fbthrift_IsSet:

third-party/thrift/src/thrift/compiler/test/fixtures/empty-struct/out/py3/gen-py3/module/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import itertools
1717
import module.thrift_types
1818

1919

20+
2021
class Empty(thrift.py3.types.Struct, _typing.Hashable):
2122
class __fbthrift_IsSet:
2223
pass

0 commit comments

Comments
 (0)