From 771d0b72e1b6a49a5bd857a193448420428d8b69 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 15 May 2025 15:28:25 -0500 Subject: [PATCH] Broaden support for generated code --- line_profiler/line_profiler.py | 8 +++++--- line_profiler/line_profiler.pyi | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/line_profiler/line_profiler.py b/line_profiler/line_profiler.py index e2156d80..5c3e6f9d 100755 --- a/line_profiler/line_profiler.py +++ b/line_profiler/line_profiler.py @@ -153,12 +153,14 @@ def add_module(self, mod): # This could be in the ipython_extension submodule, # but it doesn't depend on the IPython module so it's easier to just let it stay here. -def is_ipython_kernel_cell(filename): - """ Return True if a filename corresponds to a Jupyter Notebook cell +def is_generated_code(filename): + """ Return True if a filename corresponds to generated code, such as a + Jupyter Notebook cell. """ filename = os.path.normcase(filename) temp_dir = os.path.normcase(tempfile.gettempdir()) return ( + filename.startswith('