Skip to content

Commit 4b0706a

Browse files
committed
Merged PR posit-dev/positron-python#55: Env comm type_info
Merge pull request #55 from posit-dev/env-pane-type-info Env comm type_info -------------------- Commit message for posit-dev/positron-python@c0018fe: Env comm type_info Send the qualified type name for the optional env pane type_info field. Authored-by: Pete Farland <[email protected]> Signed-off-by: Pete Farland <[email protected]>
1 parent 300a08d commit 4b0706a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

extensions/positron-python/pythonFiles/positron_ipkernel.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self,
7171
display_value: Any,
7272
kind: EnvironmentVariableKind = EnvironmentVariableKind.OTHER,
7373
display_type: str = None,
74+
type_info: str = None,
7475
length: int = 0,
7576
size: int = None,
7677
has_children: bool = False,
@@ -80,6 +81,7 @@ def __init__(self,
8081
if kind is not None:
8182
self['kind'] = getattr(EnvironmentVariableKind, kind.upper())
8283
self['display_type'] = display_type
84+
self['type_info'] = type_info
8385
self['length'] = length
8486
self['size'] = size
8587
self['has_children'] = has_children
@@ -231,7 +233,9 @@ def get_child_info(self, value, child_name) -> (str, Any):
231233
return (display_type, values)
232234

233235
def get_display_value(self, value) -> str:
234-
return type(value).__name__
236+
type_name = type(value).__name__
237+
shape = value.shape
238+
return f'{type_name}: [{shape[0]} rows x {shape[1]} columns]'
235239

236240
def get_display_type(self, value) -> str:
237241

@@ -937,6 +941,7 @@ def summarize_any(self, key, value, kind) -> EnvironmentVariable:
937941
# Determine the short display type for the variable, including
938942
# the length, if applicable
939943
display_type = self.get_display_type(value, length)
944+
type_info = self.get_qualname(value)
940945

941946
# Apply type-specific formatting
942947
if kind == EnvironmentVariableKind.STRING:
@@ -972,7 +977,8 @@ def summarize_any(self, key, value, kind) -> EnvironmentVariable:
972977
display_value, is_truncated = self.summarize_value(value)
973978

974979
return EnvironmentVariable(display_name, display_value, kind,
975-
display_type, length, size, has_children, is_truncated)
980+
display_type, type_info, length, size,
981+
has_children, is_truncated)
976982
except Exception as err:
977983
logging.warning(err, exc_info=True)
978984
return EnvironmentVariable(display_name, self.get_qualname(value), kind)

0 commit comments

Comments
 (0)