Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10ec1e0

Browse files
committed
Python: CG trace: Better type hints
1 parent 8b6de17 commit 10ec1e0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • python/tools/recorded-call-graph-metrics/src/cg_trace

python/tools/recorded-call-graph-metrics/src/cg_trace/tracer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import sys
6+
from types import FrameType
67
from typing import Optional
78

89
LOGGER = logging.getLogger(__name__)
@@ -43,7 +44,7 @@ class Call:
4344
inst_index: int
4445

4546
@classmethod
46-
def from_frame(cls, frame):
47+
def from_frame(cls, frame: FrameType):
4748
code = frame.f_code
4849

4950
b = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
@@ -119,7 +120,7 @@ class PythonCallee(Callee):
119120
funcname: str
120121

121122
@classmethod
122-
def from_frame(cls, frame):
123+
def from_frame(cls, frame: FrameType):
123124
code = frame.f_code
124125
return cls(
125126
filename=canonic_filename(code.co_filename),
@@ -167,7 +168,7 @@ def run(self, code, globals, locals):
167168
finally:
168169
sys.setprofile(None)
169170

170-
def profilefunc(self, frame, event, arg):
171+
def profilefunc(self, frame: FrameType, event: str, arg):
171172
# ignore everything until the first call, since that is `exec` from the `run`
172173
# method above
173174
if not self.exec_call_seen:

0 commit comments

Comments
 (0)