Repository: unmade/thrift-pyi (language: python)

Issue:
Empty exceptions generate invalid python
In thrift, it's legal to declare exceptions with no members, e.g.

```thrift
exception Foo {}
```

thrift-pyi doesn't handle this well, leaving nothing where the fields would have gone. Without a nested `pass`, this leads to unparseable python:

```py
class Foo(Exception):

class SomeOtherClass(Exception):
    message: Optional[str] = "This one is OK"
```



Discussion / hints:

Fix patch:
diff --git a/example/interfaces/shared.thrift b/example/interfaces/shared.thrift
index 52d01b5..a01de12 100644
--- a/example/interfaces/shared.thrift
+++ b/example/interfaces/shared.thrift
@@ -2,6 +2,8 @@ exception NotFound {
     1: optional string message = "Not Found"
 }
 
+exception EmptyException {}
+
 
 struct LimitOffset {
     1: optional i32 limit
diff --git a/src/thriftpyi/templates/stub.html b/src/thriftpyi/templates/stub.html
index 266c6b0..1d12f12 100644
--- a/src/thriftpyi/templates/stub.html
+++ b/src/thriftpyi/templates/stub.html
@@ -12,6 +12,8 @@
 class {{ error.name }}(Exception):
 {%- for field in error.fields %}
     {{ field.name }}: {{ field.type }}{% if field.value is not none %} = {{ field.value }}{% endif %}
+{% else -%}
+    pass
 {%- endfor %}
 {% endfor %}
 


Test patch:
diff --git a/tests/stubs/expected/async/shared.pyi b/tests/stubs/expected/async/shared.pyi
index 3c6e6b5..3ca8b42 100644
--- a/tests/stubs/expected/async/shared.pyi
+++ b/tests/stubs/expected/async/shared.pyi
@@ -4,6 +4,9 @@ from typing import *
 class NotFound(Exception):
     message: Optional[str] = "Not Found"
 
+class EmptyException(Exception):
+    pass
+
 @dataclass
 class LimitOffset:
     limit: Optional[int] = None
diff --git a/tests/stubs/expected/optional/shared.pyi b/tests/stubs/expected/optional/shared.pyi
index d836414..b7e3353 100644
--- a/tests/stubs/expected/optional/shared.pyi
+++ b/tests/stubs/expected/optional/shared.pyi
@@ -4,6 +4,9 @@ from typing import *
 class NotFound(Exception):
     message: Optional[str] = "Not Found"
 
+class EmptyException(Exception):
+    pass
+
 @dataclass
 class LimitOffset:
     limit: Optional[int] = None
diff --git a/tests/stubs/expected/sync/shared.pyi b/tests/stubs/expected/sync/shared.pyi
index d836414..b7e3353 100644
--- a/tests/stubs/expected/sync/shared.pyi
+++ b/tests/stubs/expected/sync/shared.pyi
@@ -4,6 +4,9 @@ from typing import *
 class NotFound(Exception):
     message: Optional[str] = "Not Found"
 
+class EmptyException(Exception):
+    pass
+
 @dataclass
 class LimitOffset:
     limit: Optional[int] = None