Skip to content

Commit b9bea4f

Browse files
committed
refacator: improve dependency handling
1 parent 7b5f27c commit b9bea4f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/a2a/compat/v0_3/conversions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import base64
22

3-
from typing import Any
3+
from typing import TYPE_CHECKING, Any
4+
5+
6+
if TYPE_CHECKING:
7+
from cryptography.fernet import Fernet
48

5-
from cryptography.fernet import (
6-
Fernet,
7-
)
89
from google.protobuf.json_format import MessageToDict, ParseDict
910

1011
from a2a.compat.v0_3 import types as types_v03
@@ -1415,7 +1416,7 @@ def core_to_compat_push_notification_config_model(
14151416
task_id: str,
14161417
config: pb2_v10.TaskPushNotificationConfig,
14171418
owner: str,
1418-
fernet: Fernet | None = None,
1419+
fernet: 'Fernet | None' = None,
14191420
) -> PushNotificationConfigModel:
14201421
"""Converts a 1.0 core TaskPushNotificationConfig to a PushNotificationConfigModel using v0.3 JSON structure."""
14211422
compat_config = to_compat_push_notification_config(config)

tests/compat/v0_3/test_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
from google.protobuf.json_format import ParseDict
6+
import json
67

78
from a2a.compat.v0_3 import types as types_v03
89
from a2a.compat.v0_3.conversions import (
@@ -2001,7 +2002,6 @@ def test_push_notification_config_persistence_conversion_with_encryption():
20012002

20022003
# Decrypt and verify
20032004
decrypted_data = fernet.decrypt(model.config_data)
2004-
import json
20052005

20062006
data = json.loads(decrypted_data.decode('utf-8'))
20072007
assert data['url'] == 'https://example.com/push'

0 commit comments

Comments
 (0)