@@ -3661,44 +3661,46 @@ def item_context(
36613661 **Examples:**
36623662
36633663 Create an `ItemContext` using a string path and item name:
3664- ```python
3665- with client.item_context("project_name/folder_name", "item_name") as item_context:
3666- metadata = item_context.get_metadata()
3667- value = item_context.get_component_value("prompts")
3668- item_context.set_component_value("prompts", value)
3669- ```
3664+
3665+ .. code-block:: python
3666+
3667+ with client.item_context("project_name/folder_name", "item_name") as item_context:
3668+ metadata = item_context.get_metadata()
3669+ value = item_context.get_component_value("prompts")
3670+ item_context.set_component_value("prompts", value)
36703671
36713672 Create an `ItemContext` using a tuple of strings and an item ID:
3672- ```python
3673- with client.item_context(("project_name", "folder_name"), 12345) as context:
3674- metadata = context.get_metadata()
3675- print(metadata)
3676- ```
3673+
3674+ .. code-block:: python
3675+
3676+ with client.item_context(("project_name", "folder_name"), 12345) as context:
3677+ metadata = context.get_metadata()
3678+ print(metadata)
36773679
36783680 Create an `ItemContext` using a tuple of IDs and an item name:
3679- ```python
3680- with client.item_context((101, 202), "item_name") as context:
3681- value = context.get_component_value("component_id")
3682- print( value)
3683- ```
3681+
3682+ .. code-block:: python
3683+ with client.item_context((101, 202), "item_name") as context:
3684+ value = context.get_component_value("component_id" )
3685+ print(value)
36843686
36853687 Save annotations automatically after modifying component values:
3686- ```python
3687- with client.item_context("project_name/folder_name", "item_name", overwrite=True) as context:
3688- context.set_component_value("component_id ", "new_value")
3689- # No need to call .save(), changes are saved automatically on context exit.
3690- ```
3688+
3689+ .. code-block:: python
3690+ with client.item_context("project_name/folder_name ", "item_name", overwrite=True) as context:
3691+ context.set_component_value("component_id", "new_value")
3692+ # No need to call .save(), changes are saved automatically on context exit.
36913693
36923694 Handle exceptions during context execution:
3693- ```python
3694- from superannotate import FileChangedError
36953695
3696- try:
3697- with client.item_context((101, 202), "item_name") as context:
3698- context.set_component_value("component_id", "new_value")
3699- except FileChangedError as e:
3700- print(f"An error occurred: {e}")
3701- ```
3696+ .. code-block:: python
3697+ from superannotate import FileChangedError
3698+
3699+ try:
3700+ with client.item_context((101, 202), "item_name") as context:
3701+ context.set_component_value("component_id", "new_value")
3702+ except FileChangedError as e:
3703+ print(f"An error occurred: {e}")
37023704 """
37033705 if isinstance (path , str ):
37043706 project , folder = self .controller .get_project_folder_by_path (path )
0 commit comments