daemon: updated core.scripts and core.xml to avoid using deprecated type hinting
This commit is contained in:
parent
7ea950f8ec
commit
f9505b3173
5 changed files with 26 additions and 27 deletions
|
@ -8,7 +8,7 @@ from argparse import (
|
|||
)
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
from typing import Any, Optional
|
||||
|
||||
import grpc
|
||||
import netaddr
|
||||
|
@ -30,7 +30,7 @@ from core.api.grpc.wrappers import (
|
|||
NODE_TYPES = [x.name for x in NodeType if x != NodeType.PEER_TO_PEER]
|
||||
|
||||
|
||||
def protobuf_to_json(message: Any) -> Dict[str, Any]:
|
||||
def protobuf_to_json(message: Any) -> dict[str, Any]:
|
||||
return MessageToDict(
|
||||
message, including_default_value_fields=True, preserving_proto_field_name=True
|
||||
)
|
||||
|
@ -82,7 +82,7 @@ def ip6_type(value: str) -> IPNetwork:
|
|||
raise ArgumentTypeError(f"invalid ip6 address: {value}")
|
||||
|
||||
|
||||
def position_type(value: str) -> Tuple[float, float]:
|
||||
def position_type(value: str) -> tuple[float, float]:
|
||||
error = "invalid position, must be in the format: float,float"
|
||||
try:
|
||||
values = [float(x) for x in value.split(",")]
|
||||
|
@ -94,7 +94,7 @@ def position_type(value: str) -> Tuple[float, float]:
|
|||
return x, y
|
||||
|
||||
|
||||
def geo_type(value: str) -> Tuple[float, float, float]:
|
||||
def geo_type(value: str) -> tuple[float, float, float]:
|
||||
error = "invalid geo, must be in the format: float,float,float"
|
||||
try:
|
||||
values = [float(x) for x in value.split(",")]
|
||||
|
|
|
@ -9,7 +9,6 @@ from argparse import ArgumentDefaultsHelpFormatter
|
|||
from functools import cmp_to_key
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
from typing import Dict, Tuple
|
||||
|
||||
import grpc
|
||||
|
||||
|
@ -31,7 +30,7 @@ class RouteEnum(enum.Enum):
|
|||
|
||||
|
||||
class SdtClient:
|
||||
def __init__(self, address: Tuple[str, int]) -> None:
|
||||
def __init__(self, address: tuple[str, int]) -> None:
|
||||
self.sock = socket.create_connection(address)
|
||||
self.links = []
|
||||
self.send(f'layer "{ROUTE_LAYER}"')
|
||||
|
@ -85,7 +84,7 @@ class RouterMonitor:
|
|||
self.sdt = SdtClient((sdt_host, sdt_port))
|
||||
self.nodes = self.get_nodes()
|
||||
|
||||
def get_nodes(self) -> Dict[int, str]:
|
||||
def get_nodes(self) -> dict[int, str]:
|
||||
with self.core.context_connect():
|
||||
if self.session is None:
|
||||
self.session = self.get_session()
|
||||
|
@ -146,7 +145,7 @@ class RouterMonitor:
|
|||
self.manage_routes()
|
||||
self.route_time = time.monotonic()
|
||||
|
||||
def route_sort(self, x: Tuple[str, int], y: Tuple[str, int]) -> int:
|
||||
def route_sort(self, x: tuple[str, int], y: tuple[str, int]) -> int:
|
||||
x_node = x[0]
|
||||
y_node = y[0]
|
||||
if x_node == self.src_id:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue