From 5c8ec399f57132b9d809b61bfb2436e01a73ca78 Mon Sep 17 00:00:00 2001 From: Jared Hance Date: Sat, 11 Jan 2025 08:15:25 -0800 Subject: [PATCH 1/2] Resolve a circular import error in obscure configuarations. Signed-off-by: Jared Hance --- src/memray/_metadata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/memray/_metadata.py b/src/memray/_metadata.py index 5d5913b498..96d6416b86 100644 --- a/src/memray/_metadata.py +++ b/src/memray/_metadata.py @@ -1,7 +1,11 @@ +from __future__ import annotations + +import typing from dataclasses import dataclass from datetime import datetime -from ._memray import FileFormat +if typing.TYPE_CHECKING: + from ._memray import FileFormat @dataclass From cd8bc8f675049a3a6f86472977cad1886c317a33 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sun, 12 Jan 2025 22:42:39 +0000 Subject: [PATCH 2/2] Fix mypy errors --- src/memray/_memray.pyi | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/memray/_memray.pyi b/src/memray/_memray.pyi index 90411c2a39..a1d386b9db 100644 --- a/src/memray/_memray.pyi +++ b/src/memray/_memray.pyi @@ -107,25 +107,25 @@ class TemporalAllocationRecord: intervals: List[Interval] class AllocatorType(enum.IntEnum): - MALLOC: int - FREE: int - CALLOC: int - REALLOC: int - POSIX_MEMALIGN: int - ALIGNED_ALLOC: int - MEMALIGN: int - VALLOC: int - PVALLOC: int - MMAP: int - MUNMAP: int - PYMALLOC_MALLOC: int - PYMALLOC_CALLOC: int - PYMALLOC_REALLOC: int - PYMALLOC_FREE: int + MALLOC = 1 + FREE = 2 + CALLOC = 3 + REALLOC = 4 + POSIX_MEMALIGN = 5 + ALIGNED_ALLOC = 6 + MEMALIGN = 7 + VALLOC = 8 + PVALLOC = 9 + MMAP = 10 + MUNMAP = 11 + PYMALLOC_MALLOC = 12 + PYMALLOC_CALLOC = 13 + PYMALLOC_REALLOC = 14 + PYMALLOC_FREE = 15 class FileFormat(enum.IntEnum): - ALL_ALLOCATIONS: int - AGGREGATED_ALLOCATIONS: int + ALL_ALLOCATIONS = 1 + AGGREGATED_ALLOCATIONS = 2 def start_thread_trace(frame: FrameType, event: str, arg: Any) -> None: ... @@ -235,16 +235,16 @@ class Tracker: def greenlet_trace(event: str, args: Any) -> None: ... class PymallocDomain(enum.IntEnum): - PYMALLOC_RAW: int - PYMALLOC_MEM: int - PYMALLOC_OBJECT: int + PYMALLOC_RAW = 1 + PYMALLOC_MEM = 2 + PYMALLOC_OBJECT = 3 def size_fmt(num: int, suffix: str = "B") -> str: ... class SymbolicSupport(enum.IntEnum): - NONE: int - FUNCTION_NAME_ONLY: int - TOTAL: int + NONE = 1 + FUNCTION_NAME_ONLY = 2 + TOTAL = 3 def get_symbolic_support() -> SymbolicSupport: ...