Skip to content

Commit

Permalink
little bit of clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle committed Dec 11, 2024
1 parent 2629dcb commit 02b47f5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/prefect/blocks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,6 @@ async def _aget_block_document(
name: str,
client: "PrefectClient",
) -> tuple[BlockDocument, str]:
if TYPE_CHECKING:
assert isinstance(client, PrefectClient)
if cls.__name__ == "Block":
block_type_slug, block_document_name = name.split("/", 1)
else:
Expand All @@ -809,8 +807,6 @@ def _get_block_document(
name: str,
client: "SyncPrefectClient",
) -> tuple[BlockDocument, str]:
if TYPE_CHECKING:
assert isinstance(client, PrefectClient)
if cls.__name__ == "Block":
block_type_slug, block_document_name = name.split("/", 1)
else:
Expand Down Expand Up @@ -1034,9 +1030,10 @@ class Custom(Block):
# If a client wasn't provided, we get to use a sync client
from prefect.client.orchestration import get_client

sync_client = get_client(sync_client=True)
block_document, _ = cls._get_block_document(name, client=sync_client)
with get_client(sync_client=True) as sync_client:
block_document, _ = cls._get_block_document(name, client=sync_client)
else:
# If a client was provided, reuse it, even though it's async, to avoid excessive client creation
block_document, _ = run_coro_as_sync(
cls._aget_block_document(name, client=client)
)
Expand Down

0 comments on commit 02b47f5

Please sign in to comment.