chore: update python packages + formatting + cleanup (#3221)

This commit is contained in:
dni ⚡
2025-07-08 10:17:27 +02:00
parent c4c03d96a3
commit a16078a6ba
53 changed files with 1159 additions and 576 deletions
+7 -7
View File
@@ -2,7 +2,7 @@ import base64
import hashlib
import json
import re
from typing import Dict, Tuple, Union
from typing import Union
from urllib.parse import urlparse
import secp256k1
@@ -13,7 +13,7 @@ from Cryptodome.Util.Padding import pad, unpad
from pynostr.key import PrivateKey
def generate_keypair() -> Tuple[str, str]:
def generate_keypair() -> tuple[str, str]:
private_key = PrivateKey()
public_key = private_key.public_key
return private_key.hex(), public_key.hex()
@@ -82,7 +82,7 @@ def decrypt_content(
return decrypted
def verify_event(event: Dict) -> bool:
def verify_event(event: dict) -> bool:
"""
Verify the event signature
@@ -115,8 +115,8 @@ def verify_event(event: Dict) -> bool:
def sign_event(
event: Dict, account_public_key_hex: str, account_private_key: secp256k1.PrivateKey
) -> Dict:
event: dict, account_public_key_hex: str, account_private_key: secp256k1.PrivateKey
) -> dict:
"""
Signs the event (in place) with the service secret
@@ -149,7 +149,7 @@ def sign_event(
return event
def json_dumps(data: Union[Dict, list]) -> str:
def json_dumps(data: Union[dict, list]) -> str:
"""
Converts a Python dictionary to a JSON string with compact encoding.
@@ -159,7 +159,7 @@ def json_dumps(data: Union[Dict, list]) -> str:
Returns:
str: The compact JSON string.
"""
if isinstance(data, Dict):
if isinstance(data, dict):
data = {k: v for k, v in data.items() if v is not None}
return json.dumps(data, separators=(",", ":"), ensure_ascii=False)