Skip to content

Commit

Permalink
Fix python type checks (#29917)
Browse files Browse the repository at this point in the history
* Fix mypy type complaint

* Also fix wrong include

* Restyle
  • Loading branch information
andy31415 authored and pull[bot] committed Feb 16, 2024
1 parent b2f0ce2 commit 4801234
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
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

0 comments on commit 4801234

Please sign in to comment.