File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -87,18 +87,19 @@ def _(cand: None) -> types.ModuleType:
87
87
return resolve (_infer_caller ().f_globals ['__name__' ])
88
88
89
89
90
+ @functools .lru_cache
91
+ def _this_filename ():
92
+ frame = inspect .currentframe ()
93
+ return __file__ if frame is None else inspect .getframeinfo (frame ).filename
94
+
95
+
90
96
def _infer_caller ():
91
97
"""
92
98
Walk the stack and find the frame of the first caller not in this module.
93
99
"""
94
- this_frame = inspect .currentframe ()
95
- if this_frame is None :
96
- this_file = __file__
97
- else :
98
- this_file = inspect .getframeinfo (this_frame ).filename
99
100
100
101
def is_this_file (frame_info ):
101
- return frame_info .filename == this_file
102
+ return frame_info .filename == _this_filename ()
102
103
103
104
def is_wrapper (frame_info ):
104
105
return frame_info .function == 'wrapper'
You can’t perform that action at this time.
0 commit comments