Skip to content

Commit

Permalink
Fix py matter idl types (#27897)
Browse files Browse the repository at this point in the history
* Fix strict python typing errors in py_matter_idl

* Restyle

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Nov 8, 2023
1 parent a8f53eb commit 235d071
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def GenerateTables(self) -> Generator[Table, None, None]:
code="ConstantValueTag(0x%X)" % entry.code,
name=entry.name,
reference=None,
real_type="%s::%s::%s" % (self.cluster.name, e.name, entry.name)
real_type="%s::%s::%s" % (
self.cluster.name, e.name, entry.name)
)
for entry in e.entries
]
Expand All @@ -214,7 +215,8 @@ def GenerateTables(self) -> Generator[Table, None, None]:
code="ConstantValueTag(0x%X)" % entry.code,
name=entry.name,
reference=None,
real_type="%s::%s::%s" % (self.cluster.name, e.name, entry.name)
real_type="%s::%s::%s" % (
self.cluster.name, e.name, entry.name)
)
for entry in e.entries
]
Expand Down Expand Up @@ -245,7 +247,7 @@ def IndexInTable(name: Optional[str], table: List[Table]) -> str:
for idx, t in enumerate(table):
if t.full_name == name:
# Index skipping hard-coded items
return idx + 2
return "%d" % (idx + 2)

raise Exception("Name %r not found in table" % name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def GlobalEncodableValueFrom(typeName: str, context: TypeLookupContext) -> Encod
"""
Filter to convert a global type name to an encodable value
"""
return EncodableValue(context, DataType(name=typeName), {})
return EncodableValue(context, DataType(name=typeName), set())


def EncodableValueFrom(field: Field, context: TypeLookupContext) -> EncodableValue:
Expand Down
4 changes: 3 additions & 1 deletion scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional

from matter_idl.generators.types import GetDataTypeSizeInBits, IsSignedDataType
from matter_idl.matter_idl_types import AccessPrivilege, Attribute, AttributeQuality, DataType, Field, FieldQuality


def ParseInt(value: str, data_type: DataType = None) -> int:
def ParseInt(value: str, data_type: Optional[DataType] = None) -> int:
"""
Convert a string that is a known integer into an actual number.
Expand Down

0 comments on commit 235d071

Please sign in to comment.