From 727f9a1e43cbb9be74d0f1b8b7cb8b3a92da9c9e Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Thu, 6 Jun 2024 18:58:52 -0400 Subject: [PATCH] fix rendering of None --- CHANGELOG.md | 1 + memory-viz/src/memory_model.ts | 2 ++ memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11991ab4..b226e221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### 🐛 Bug fixes - Fixed a bug where box fill colours would cover box text, and changed the implementation of `hide` style option. +- Removed double quotes when rendering objects of type `None`. ### 📚 Documentation and demo website changes diff --git a/memory-viz/src/memory_model.ts b/memory-viz/src/memory_model.ts index 8060909f..d12a8dda 100644 --- a/memory-viz/src/memory_model.ts +++ b/memory-viz/src/memory_model.ts @@ -222,6 +222,8 @@ export class MemoryModel { let display_text; if (type === "bool") { display_text = value ? "True" : "False"; + } else if (type === "None") { + display_text = "None"; } else { display_text = JSON.stringify(value); } diff --git a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap index 424bfbff..7cec23a0 100644 --- a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap +++ b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`draw function formats a mix of stack frame/non-stack frame objects in automatic layout 1`] = `"aid7__main__xid1yid17funcid170id81id84list"None"id10None"`; +exports[`draw function formats a mix of stack frame/non-stack frame objects in automatic layout 1`] = `"aid7__main__xid1yid17funcid170id81id84listNoneid10None"`; exports[`draw function formats non-stack frame objects in automatic layout 1`] = `"42id98intnameid12id23fruitid19id42id22id63id54list"banana"id12str"`; @@ -58,7 +58,7 @@ exports[`draw function renders an empty tuple 1`] = `"7id32int"`; -exports[`draw function renders an object with no type and no value 1`] = `""None"id13None"`; +exports[`draw function renders an object with no type and no value 1`] = `"Noneid13None"`; exports[`draw function renders blank spaces in automatic layout 1`] = `"42id98int"life"id99str"`;