-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align warning frame with user input.
- Loading branch information
1 parent
2fe6272
commit 5995eed
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import sys | ||
|
||
|
||
def get_spec_classes_depth(): | ||
""" | ||
The recursion depth of the caller into spec-classes from first | ||
non-spec-classes frame. | ||
Args: | ||
offset: An offset to apply the calculated depth. An `offset` of 1 aligns | ||
the depth with that of the caller. | ||
""" | ||
stacklevel = 0 | ||
f = sys._getframe() | ||
while f.f_back and ( | ||
"spec_classes" in f.f_code.co_filename or f.f_code.co_filename == "<string>" | ||
): | ||
f = f.f_back | ||
stacklevel += 1 | ||
return stacklevel |