mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: CG trace: Better type hints
This commit is contained in:
@@ -3,6 +3,7 @@ import dis
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from types import FrameType
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
@@ -43,7 +44,7 @@ class Call:
|
|||||||
inst_index: int
|
inst_index: int
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_frame(cls, frame):
|
def from_frame(cls, frame: FrameType):
|
||||||
code = frame.f_code
|
code = frame.f_code
|
||||||
|
|
||||||
b = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
|
b = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
|
||||||
@@ -119,7 +120,7 @@ class PythonCallee(Callee):
|
|||||||
funcname: str
|
funcname: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_frame(cls, frame):
|
def from_frame(cls, frame: FrameType):
|
||||||
code = frame.f_code
|
code = frame.f_code
|
||||||
return cls(
|
return cls(
|
||||||
filename=canonic_filename(code.co_filename),
|
filename=canonic_filename(code.co_filename),
|
||||||
@@ -167,7 +168,7 @@ class CallGraphTracer:
|
|||||||
finally:
|
finally:
|
||||||
sys.setprofile(None)
|
sys.setprofile(None)
|
||||||
|
|
||||||
def profilefunc(self, frame, event, arg):
|
def profilefunc(self, frame: FrameType, event: str, arg):
|
||||||
# ignore everything until the first call, since that is `exec` from the `run`
|
# ignore everything until the first call, since that is `exec` from the `run`
|
||||||
# method above
|
# method above
|
||||||
if not self.exec_call_seen:
|
if not self.exec_call_seen:
|
||||||
|
|||||||
Reference in New Issue
Block a user