Skip to content

Commit

Permalink
Make mypy happy even on an edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Oct 26, 2023
1 parent f7507e4 commit fef1f28
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/py_matter_idl/matter_idl/generators/idl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ def human_text_string(value: Union[ClusterSide, StructTag, StructQuality, EventP
if value == StructTag.RESPONSE:
return "response"
elif type(value) is FieldQuality:
# mypy seems confused if using `FieldQuality.OPTIONAL in value`
# directly, so do a useless cast here
quality: FieldQuality = value

result = ""
if FieldQuality.OPTIONAL in value:
if FieldQuality.OPTIONAL in quality:
result += "optional "
if FieldQuality.NULLABLE in value:
if FieldQuality.NULLABLE in quality:
result += "nullable "
if FieldQuality.FABRIC_SENSITIVE in value:
if FieldQuality.FABRIC_SENSITIVE in quality:
result += "fabric_sensitive "
return result.strip()
elif type(value) is StructQuality:
Expand Down

0 comments on commit fef1f28

Please sign in to comment.