Skip to content

Commit

Permalink
Improve heuristic for detecting app code in format_traceback.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Nov 23, 2023
1 parent 4b8a6f9 commit 1b235a0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions optic/exceptions/format_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ def format_filename(filename: str) -> str:
return filename


# TODO: make this a better heuristic
def is_app_code(filename: str) -> bool:
if "examples" in filename:
return True
if "testing" in filename:
return True
"""Use a naive but effective heuristic for whether this is 'application' code."""
for i in range(1, len(linecache.getlines(filename)) + 1):
if "import optic as op" in linecache.getline(filename, i):
return True
return False

0 comments on commit 1b235a0

Please sign in to comment.