Skip to content

Commit

Permalink
Use non-string type annotations
Browse files Browse the repository at this point in the history
Python 3.7 and newer don't need strings for type annotations anymore.
This makes type annotations more readable in most editors.
  • Loading branch information
agners committed Sep 16, 2024
1 parent 56bbe1f commit 71f6f85
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/controller/python/templates/python-cluster-Objects-py.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Users are not expected to import this file, instead, users can use import chip.clusters,
# which will import all symbols from this file and can get a readable, pretty naming like
# clusters.OnOff.commands.OnCommand
from __future__ import annotations

import typing
from dataclasses import dataclass, field
Expand Down Expand Up @@ -76,9 +77,9 @@ class {{asUpperCamelCase name}}(Cluster):

{{#zcl_attributes_server}}
{{#if entryType}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}}
{{ asLowerCamelCase label }}: {{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}} = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}}
{{else}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}}
{{ asLowerCamelCase label }}: {{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}} = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}}
{{/if}}
{{/zcl_attributes_server}}

Expand Down Expand Up @@ -142,7 +143,7 @@ class {{asUpperCamelCase name}}(Cluster):
{{#first}}

{{/first}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{ asLowerCamelCase label }}: {{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}} = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{/zcl_command_arguments}}

{{/zcl_commands}}
Expand Down Expand Up @@ -175,9 +176,9 @@ class {{asUpperCamelCase name}}(Cluster):
{{/if}}

{{#if entryType}}
value: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}}
value: {{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}} = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}}
{{else}}
value: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}}
value: {{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}} = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}}
{{/if}}

{{/zcl_attributes_server}}
Expand Down Expand Up @@ -207,7 +208,7 @@ class {{asUpperCamelCase name}}(Cluster):
{{#first}}

{{/first}}
{{ asLowerCamelCase name }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{ asLowerCamelCase name }}: {{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}} = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{/zcl_event_fields}}

{{/zcl_events}}
Expand Down

0 comments on commit 71f6f85

Please sign in to comment.