Repository: mandiant/capa
File: capa/render/proto/__init__.py (Python)

Code before:
    elif type_ == "property_":
        ff = f.property_
        return frzf.PropertyFeature(property=ff.property_, access=ff.access or None, description=ff.description or None)
    elif type_ == "number":
        ff = f.number
        return frzf.NumberFeature(number=number_from_pb2(ff.number), description=ff.description or None)
    elif type_ == "bytes":
        ff = f.bytes
        return frzf.BytesFeature(bytes=ff.bytes, description=ff.description or None)
    elif type_ == "offset":
        ff = f.offset
        return frzf.OffsetFeature(offset=int_from_pb2(ff.offset), description=ff.description or None)
    elif type_ == "mnemonic":
        ff = f.mnemonic
        return frzf.MnemonicFeature(mnemonic=ff.mnemonic, description=ff.description or None)
    elif type_ == "operand_number":
        ff = f.operand_number
        return frzf.OperandNumberFeature(
            index=ff.index, operand_number=number_from_pb2(ff.operand_number), description=ff.description or None
        )  # type: ignore
    elif type_ == "operand_offset":
        ff = f.operand_offset
        return frzf.OperandOffsetFeature(
            index=ff.index, operand_offset=int_from_pb2(ff.operand_offset), description=ff.description or None
        )  # type: ignore
    elif type_ == "basic_block":
        ff = f.basic_block
        return frzf.BasicBlockFeature(description=ff.description or None)
    else:
        assert_never(type_)


def match_from_pb2(match: capa_pb2.Match) -> rd.Match:
    children = list(map(match_from_pb2, match.children))
    locations = list(map(addr_from_pb2, match.locations))

    node_type = match.WhichOneof("node")
    if node_type == "statement":
        return rd.Match(
            success=match.success,
            node=rd.StatementNode(statement=statement_from_pb2(match.statement)),
            children=tuple(children),
            locations=tuple(locations),
            captures={},
        )
    elif node_type == "feature":
        return rd.Match(
            success=match.success,
            node=rd.FeatureNode(feature=feature_from_pb2(match.feature)),
            children=tuple(children),
            locations=tuple(locations),

Review comment (suggestion):
```suggestion
        )  # type: ignore
        # Mypy is unable to recognize `operand_offset` as an argument due to aliasing
```

Code after:
        return frzf.APIFeature(api=ff.api, description=ff.description or None)
    elif type_ == "property_":
        ff = f.property_
        return frzf.PropertyFeature(property=ff.property_, access=ff.access or None, description=ff.description or None)
    elif type_ == "number":
        ff = f.number
        return frzf.NumberFeature(number=number_from_pb2(ff.number), description=ff.description or None)
    elif type_ == "bytes":
        ff = f.bytes
        return frzf.BytesFeature(bytes=ff.bytes, description=ff.description or None)
    elif type_ == "offset":
        ff = f.offset
        return frzf.OffsetFeature(offset=int_from_pb2(ff.offset), description=ff.description or None)
    elif type_ == "mnemonic":
        ff = f.mnemonic
        return frzf.MnemonicFeature(mnemonic=ff.mnemonic, description=ff.description or None)
    elif type_ == "operand_number":
        ff = f.operand_number
        return frzf.OperandNumberFeature(
            index=ff.index, operand_number=number_from_pb2(ff.operand_number), description=ff.description or None
        )  # type: ignore
    elif type_ == "operand_offset":
        ff = f.operand_offset
        return frzf.OperandOffsetFeature(
            index=ff.index, operand_offset=int_from_pb2(ff.operand_offset), description=ff.description or None
        )  # type: ignore
        # Mypy is unable to recognize `operand_offset` as an argument due to aliasing
    elif type_ == "basic_block":
        ff = f.basic_block
        return frzf.BasicBlockFeature(description=ff.description or None)
    else:
        assert_never(type_)


def match_from_pb2(match: capa_pb2.Match) -> rd.Match:
    children = list(map(match_from_pb2, match.children))
    locations = list(map(addr_from_pb2, match.locations))

    node_type = match.WhichOneof("node")
    if node_type == "statement":
        return rd.Match(
            success=match.success,
            node=rd.StatementNode(statement=statement_from_pb2(match.statement)),
            children=tuple(children),
            locations=tuple(locations),
            captures={},
        )
    elif node_type == "feature":
        return rd.Match(
            success=match.success,
            node=rd.FeatureNode(feature=feature_from_pb2(match.feature)),