Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python type checks #29917

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# limitations under the License.

import logging
from typing import Optional

from matter_idl.matter_idl_types import (Attribute, AttributeQuality, Bitmap, Cluster, ClusterSide, CommandQuality, ConstantEntry,
DataType, Enum, Field, FieldQuality, Idl, Struct, StructTag)
from matter_idl.matter_idl_types import (Attribute, AttributeQuality, Bitmap, Cluster, ClusterSide, Command, CommandQuality,
ConstantEntry, DataType, Enum, Field, FieldQuality, Idl, Struct, StructTag)

from .base import BaseHandler, HandledDepth
from .context import Context
Expand Down Expand Up @@ -350,6 +351,7 @@ class CommandHandler(BaseHandler):
def __init__(self, context: Context, cluster: Cluster, attrs):
super().__init__(context, handled=HandledDepth.SINGLE_TAG)
self._cluster = cluster
self._command: Optional[Command] = None

# Command information layout:
# "response":
Expand Down Expand Up @@ -388,7 +390,6 @@ def __init__(self, context: Context, cluster: Cluster, attrs):
tag=StructTag.REQUEST,
)
else:
self._command = None
self._struct = Struct(
name=NormalizeName(attrs["name"]),
fields=[],
Expand Down Expand Up @@ -422,11 +423,12 @@ def GetNextProcessor(self, name: str, attrs):
LOGGER.warn(
f"Ignoring invoke privilege for {self._struct.name}")

if "timed" in attrs and attrs["timed"] != "false":
self._command.qualities |= CommandQuality.TIMED_INVOKE
if self._command:
if "timed" in attrs and attrs["timed"] != "false":
self._command.qualities |= CommandQuality.TIMED_INVOKE

if "fabricScoped" in attrs and attrs["fabricScoped"] != "false":
self._command.qualities |= CommandQuality.FABRIC_SCOPED
if "fabricScoped" in attrs and attrs["fabricScoped"] != "false":
self._command.qualities |= CommandQuality.FABRIC_SCOPED

return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name == "field":
Expand Down
2 changes: 1 addition & 1 deletion scripts/py_matter_idl/matter_idl/test_data_model_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
os.path.join(os.path.dirname(__file__), '..')))
from matter_idl.data_model_xml import ParseSource, ParseXmls

from matter_idl.matter_idl_parser import CreateParser
from matter_idl.matter_idl_types import Idl
from matter_idl_parser import CreateParser


def XmlToIdl(what: Union[str, List[str]]) -> Idl:
Expand Down
Loading