Skip to content

Commit

Permalink
[matter_yamltests] Replace python 3.9 list syntax with typing.List
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed May 26, 2023
1 parent ad5253a commit 52ea08c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scripts/py_matter_yamltests/matter_yamltests/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import re
import string
from abc import ABC, abstractmethod
from typing import List

from .errors import TestStepError

Expand Down Expand Up @@ -759,7 +760,7 @@ def get_reason(self, value, value_type_name) -> str:
return f'The response value "{value}" is not a value from {self._any_of}.'


def get_constraints(constraints: dict) -> list[BaseConstraint]:
def get_constraints(constraints: dict) -> List[BaseConstraint]:
_constraints = []
context = constraints

Expand Down
6 changes: 3 additions & 3 deletions scripts/py_matter_yamltests/matter_yamltests/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ def get_type_by_name(self, cluster_name: str, target_name: str):

return None

def get_command_names(self, cluster_name: str) -> list[str]:
def get_command_names(self, cluster_name: str) -> List[str]:
targets = self.__get_targets_by_cluster_name(
cluster_name, _ItemType.Request)
return [] if targets is None else [name for name in targets]

def get_event_names(self, cluster_name: str) -> list[str]:
def get_event_names(self, cluster_name: str) -> List[str]:
targets = self.__get_targets_by_cluster_name(
cluster_name, _ItemType.Event)
return [] if targets is None else [name for name in targets]

def get_attribute_names(self, cluster_name: str) -> list[str]:
def get_attribute_names(self, cluster_name: str) -> List[str]:
targets = self.__get_targets_by_cluster_name(
cluster_name, _ItemType.Attribute)
return [] if targets is None else [name for name in targets]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import copy
import time
from dataclasses import dataclass, field
from typing import List

from .hooks import TestParserHooks
from .parser import TestParser, TestParserConfig
Expand Down Expand Up @@ -50,7 +51,7 @@ class TestParserBuilderConfig:
parsing. It may may allow the callers to gain insights about the
current parsing state.
"""
tests: list[str] = field(default_factory=list)
tests: List[str] = field(default_factory=list)
parser_config: TestParserConfig = field(default_factory=TestParserConfig)
hooks: TestParserHooks = TestParserHooks()
options: TestParserBuilderOptions = field(
Expand Down
6 changes: 4 additions & 2 deletions scripts/py_matter_yamltests/matter_yamltests/pics_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import unicodedata

from typing import List

_COMMENT_CHARACTER = '#'
_VALUE_SEPARATOR = '='
_VALUE_DISABLED = '0'
Expand Down Expand Up @@ -78,7 +80,7 @@ def __parse(self, pics_file: str):
line = f.readline()
return pics

def __evaluate_expression(self, tokens: list[str], pics: dict):
def __evaluate_expression(self, tokens: List[str], pics: dict):
leftExpr = self.__evaluate_sub_expression(tokens, pics)
if self.__expression_index >= len(tokens):
return leftExpr
Expand All @@ -102,7 +104,7 @@ def __evaluate_expression(self, tokens: list[str], pics: dict):

raise InvalidPICSParsingError(f'Unknown token: {token}')

def __evaluate_sub_expression(self, tokens: list[str], pics: dict):
def __evaluate_sub_expression(self, tokens: List[str], pics: dict):
token = tokens[self.__expression_index]
if token == '(':
self.__expression_index += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
from .clusters.system_commands import SystemCommands
from .pseudo_cluster import PseudoCluster

from typing import List


class PseudoClusters:
def __init__(self, clusters: list[PseudoCluster]):
def __init__(self, clusters: List[PseudoCluster]):
self.clusters = clusters

def supports(self, request) -> bool:
Expand Down

0 comments on commit 52ea08c

Please sign in to comment.