Skip to content

Wrong python type annotation for TypeParserResult #6833

@waskyo

Description

@waskyo

Version and Platform (required):

  • Binary Ninja Version: 5.1.7422-dev Ultimate (84083554)
  • OS: Debian Linux
  • OS Version: unstable
  • CPU Architecture: x86_64

Bug Description:
The type annotations for TypeParserResult do not match what I get at runtime. According to:

variables: List[ParsedType]

types, variables, and functions are lists, but in reality they're dicts. The annotations for BasicTypeParserResult at
class BasicTypeParserResult:
do match reality.

This causes mypy and pyright to issue complains when I try to access the TypeParserResult fields:

error: "List[ParsedType]" has no attribute "keys"

Steps To Reproduce:

I don't have a small enough script to repro, but you can see the mismtach in the UI python console:

>>> t = bv.parse_types_from_string("static const uint32_t test;", options=["-x", "c", "--std", "c99"])
>>> type(t)
<class 'binaryninja.typeparser.TypeParserResult'>
>>> type(t.types)
<class 'dict'>
>>> type(t.variables)
<class 'dict'>
>>> type(t.functions)
<class 'dict'>

I can put together a script if that would be useful.

Expected Behavior:

No complains from mypy/pyright with code such as:

t = bv.parse_types_from_string("static const uint32_t test;", options=["-x", "c", "--std", "c99"])
if 'test' in t.keys():
   print("it works")

Screenshots/Video Recording:
N/A

Binary:
N/A

Additional Information:
N/A

Metadata

Metadata

Assignees

Labels

Component: Python APIIssue needs changes to the python APIEffort: TrivialIssue should take < 1 dayImpact: LowIssue is a papercut or has a good, supported workaround

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions