Skip to content

Commit a587136

Browse files
authored
Fix heuristics in get_app_caller_source_code_location (#862)
1 parent 2370b1d commit a587136

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mesop/utils/caller.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ def get_app_caller_source_code_location() -> pb.SourceCodeLocation | None:
1111
caller_info = inspect.getframeinfo(current_frame)
1212
filename = caller_info.filename
1313
# "mesop/mesop" is the file path of the core Mesop framework when running under bazel.
14+
# The exception is the examples subdir, which are Mesop apps and not actually part of
15+
# the core Mesop framework.
16+
#
1417
# "site-packages" is the file path of the Mesop framework when running under pip CLI.
1518
# If the file is neither of those paths, then we assume it is an app file.
16-
if "mesop/mesop" not in filename and "site-packages" not in filename:
19+
if (
20+
"mesop/mesop" not in filename or "mesop/mesop/examples" in filename
21+
) and "site-packages" not in filename:
1722
# Get module from filepath
1823
splitted_file = filename.split("runfiles/")
1924
if len(splitted_file) < 2:

0 commit comments

Comments
 (0)