1+ from __future__ import annotations
12import logging
23import weakref
34import networkx
45from functools import cached_property
5- from typing import TYPE_CHECKING , Dict , Set
6+ from typing import TYPE_CHECKING
67
78from binexport .utils import get_basic_block_addr
89from binexport .basic_block import BasicBlockBinExport
9- from binexport .types import FunctionType , Addr
10- from collections import abc
10+ from binexport .types import FunctionType
1111
1212if TYPE_CHECKING :
13- from .program import ProgramBinExport
14- from .binexport2_pb2 import BinExport2
13+ from collections import abc
14+ from binexport .program import ProgramBinExport
15+ from binexport .binexport2_pb2 import BinExport2
16+ from binexport .types import Addr
1517
1618
1719class FunctionBinExport :
@@ -22,9 +24,9 @@ class FunctionBinExport:
2224
2325 def __init__ (
2426 self ,
25- program : weakref .ref [" ProgramBinExport" ],
27+ program : weakref .ref [ProgramBinExport ],
2628 * ,
27- pb_fun : " BinExport2.FlowGraph | None" = None ,
29+ pb_fun : BinExport2 .FlowGraph | None = None ,
2830 is_import : bool = False ,
2931 addr : Addr | None = None ,
3032 ):
@@ -40,8 +42,8 @@ def __init__(
4042 super (FunctionBinExport , self ).__init__ ()
4143
4244 self .addr : Addr | None = addr #: address, None if imported function
43- self .parents : Set [ " FunctionBinExport" ] = set () #: set of function call this one
44- self .children : Set [ " FunctionBinExport" ] = set () #: set of functions called by this one
45+ self .parents : set [ FunctionBinExport ] = set () #: set of function call this one
46+ self .children : set [ FunctionBinExport ] = set () #: set of functions called by this one
4547
4648 # Private attributes
4749 self ._graph = None # CFG. Loaded inside self.blocks
@@ -95,7 +97,7 @@ def unload(self) -> None:
9597 if self ._enable_unloading :
9698 self ._basic_blocks = None
9799
98- def items (self ) -> abc .ItemsView [Addr , " BasicBlockBinExport" ]:
100+ def items (self ) -> abc .ItemsView [Addr , BasicBlockBinExport ]:
99101 """
100102 Each function is associated to a dictionary with key-value
101103 Addr->BasicBlockBinExport. This returns items of the dictionary.
@@ -109,14 +111,14 @@ def keys(self) -> abc.KeysView[Addr]:
109111 """
110112 return self .blocks .keys ()
111113
112- def values (self ) -> abc .ValuesView [" BasicBlockBinExport" ]:
114+ def values (self ) -> abc .ValuesView [BasicBlockBinExport ]:
113115 """
114116 Each function is associated to a dictionary with key-value : Addr, BasicBlockBinExport. This returns items
115117 of the dictionary.
116118 """
117119 return self .blocks .values ()
118120
119- def __getitem__ (self , item : Addr ) -> " BasicBlockBinExport" :
121+ def __getitem__ (self , item : Addr ) -> BasicBlockBinExport :
120122 """
121123 Get a basic block object from its address.
122124
@@ -135,14 +137,14 @@ def __contains__(self, item: Addr) -> bool:
135137 return item in self .blocks
136138
137139 @property
138- def program (self ) -> " ProgramBinExport" :
140+ def program (self ) -> ProgramBinExport :
139141 """
140142 :py:class:`ProgramBinExport` in which this function belongs to.
141143 """
142144 return self ._program ()
143145
144146 @property
145- def blocks (self ) -> Dict [Addr , BasicBlockBinExport ]:
147+ def blocks (self ) -> dict [Addr , BasicBlockBinExport ]:
146148 """
147149 Returns a dict which is used to reference all basic blocks by their address.
148150 Calling this function will also load the CFG.
0 commit comments