зеркало из https://github.com/mozilla/uniffi-rs.git
python: add type hints for enum sub-classes and sub-class `__init__`
methods.
This commit is contained in:
Родитель
2e5021df23
Коммит
e7a6808398
|
@ -19,7 +19,11 @@ class {{ type_name }}:
|
|||
# Each enum variant is a nested class of the enum itself.
|
||||
{% for variant in e.variants() -%}
|
||||
class {{ variant.name()|enum_variant_py }}:
|
||||
def __init__(self,{% for field in variant.fields() %}{{ field.name()|var_name }}{% if loop.last %}{% else %}, {% endif %}{% endfor %}):
|
||||
{% for field in variant.fields() %}
|
||||
{{- field.name()|var_name }}: "{{- field|type_name }}";
|
||||
{%- endfor %}
|
||||
|
||||
def __init__(self,{% for field in variant.fields() %}{{ field.name()|var_name }}: "{{- field|type_name }}"{% if loop.last %}{% else %}, {% endif %}{% endfor %}):
|
||||
{% if variant.has_fields() %}
|
||||
{%- for field in variant.fields() %}
|
||||
self.{{ field.name()|var_name }} = {{ field.name()|var_name }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче