Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Commit 2a6bd5c

Browse files
author
anna-charlotte
committed
fix: put console at module level
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
1 parent a70142a commit 2a6bd5c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎docarray/base_document/document.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
from typing import Type
33

44
import orjson
5-
import rich
65
from pydantic import BaseModel, Field, parse_obj_as
6+
from rich.console import Console
77

88
from docarray.base_document.abstract_document import AbstractDocument
99
from docarray.base_document.base_node import BaseNode
1010
from docarray.base_document.io.json import orjson_dumps, orjson_dumps_and_decode
1111
from docarray.base_document.mixins import PlotMixin, ProtoMixin
1212
from docarray.typing import ID
1313

14+
_console: Console = Console()
15+
1416

1517
class BaseDocument(BaseModel, PlotMixin, ProtoMixin, AbstractDocument, BaseNode):
1618
"""
1719
The base class for Document
1820
"""
1921

2022
id: ID = Field(default_factory=lambda: parse_obj_as(ID, os.urandom(16).hex()))
21-
_console: rich.console.Console = rich.console.Console()
2223

2324
class Config:
2425
json_loads = orjson.loads
@@ -38,7 +39,7 @@ def _get_field_type(cls, field: str) -> Type['BaseDocument']:
3839
return cls.__fields__[field].outer_type_
3940

4041
def __str__(self):
41-
with self._console.capture() as capture:
42-
self._console.print(self)
42+
with _console.capture() as capture:
43+
_console.print(self)
4344

4445
return capture.get().strip()

0 commit comments

Comments
 (0)