diff --git a/thirdparty/defer/sugar/_parse.py b/thirdparty/defer/sugar/_parse.py index 3ff8582..c581a35 100644 --- a/thirdparty/defer/sugar/_parse.py +++ b/thirdparty/defer/sugar/_parse.py @@ -1,10 +1,10 @@ import sys +import os from ast import ( AsyncFunctionDef, FunctionDef, ) from collections import deque -from os.path import isabs from types import FrameType from typing import Any, Callable, Optional, cast @@ -16,21 +16,19 @@ def _is_dunder(name: str) -> bool: return name.startswith("__") and name.endswith("__") -def _is_excluded_path(filename: str) -> bool: +_SITE_PACKAGES = "site-packages" +_VENV = ".venv" +_THIRDPARTY = "thirdparty" +_SRC_WIN = "\\src\\" +_SRC_UNIX = "/src/" + + +def _is_our_code(filename: str) -> bool: if not filename: + return False + if _SRC_WIN in filename or _SRC_UNIX in filename: return True - return ( - filename.startswith(sys.base_exec_prefix) - or filename.startswith(sys.base_prefix) - or filename.startswith(sys.exec_prefix) - or filename.startswith(sys.prefix) - or ".venv" in filename - or filename.startswith("") - or filename.startswith("