mirror of
https://github.com/meshtastic/python.git
synced 2026-01-01 20:38:03 -05:00
Fix assorted mypy-detected errors
This commit is contained in:
@@ -9,16 +9,15 @@ import platform
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pyqrcode
|
||||
import pyqrcode # type: ignore[import-untyped]
|
||||
import yaml
|
||||
from google.protobuf.json_format import MessageToDict
|
||||
from pubsub import pub
|
||||
from pubsub import pub # type: ignore[import-untyped]
|
||||
|
||||
import meshtastic.test
|
||||
import meshtastic.util
|
||||
from meshtastic import channel_pb2, config_pb2, portnums_pb2, remote_hardware
|
||||
from meshtastic import channel_pb2, config_pb2, portnums_pb2, remote_hardware, BROADCAST_ADDR
|
||||
from meshtastic.version import get_active_version
|
||||
from meshtastic.__init__ import BROADCAST_ADDR
|
||||
from meshtastic.ble_interface import BLEInterface
|
||||
from meshtastic.globals import Globals
|
||||
|
||||
@@ -147,7 +146,7 @@ def setPref(config, comp_name, valStr) -> bool:
|
||||
|
||||
objDesc = config.DESCRIPTOR
|
||||
config_type = objDesc.fields_by_name.get(name[0])
|
||||
pref = False
|
||||
pref = None
|
||||
if config_type and config_type.message_type is not None:
|
||||
pref = config_type.message_type.fields_by_name.get(snake_name)
|
||||
# Others like ChannelSettings are standalone
|
||||
|
||||
@@ -9,17 +9,18 @@ import sys
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import AnyStr
|
||||
|
||||
import google.protobuf.json_format
|
||||
import timeago
|
||||
import timeago # type: ignore[import-untyped]
|
||||
from google.protobuf.json_format import MessageToJson
|
||||
from pubsub import pub
|
||||
from pubsub import pub # type: ignore[import-untyped]
|
||||
from tabulate import tabulate
|
||||
|
||||
import meshtastic.node
|
||||
from meshtastic import mesh_pb2, portnums_pb2, telemetry_pb2
|
||||
from meshtastic.__init__ import (
|
||||
from meshtastic import (
|
||||
mesh_pb2,
|
||||
portnums_pb2,
|
||||
telemetry_pb2,
|
||||
BROADCAST_ADDR,
|
||||
BROADCAST_NUM,
|
||||
LOCAL_ADDR,
|
||||
@@ -239,7 +240,7 @@ class MeshInterface:
|
||||
|
||||
def sendText(
|
||||
self,
|
||||
text: AnyStr,
|
||||
text: str,
|
||||
destinationId=BROADCAST_ADDR,
|
||||
wantAck=False,
|
||||
wantResponse=False,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""
|
||||
import logging
|
||||
|
||||
from pubsub import pub
|
||||
from pubsub import pub # type: ignore[import-untyped]
|
||||
|
||||
from meshtastic import portnums_pb2, remote_hardware_pb2
|
||||
from meshtastic.util import our_exit
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
import platform
|
||||
import time
|
||||
|
||||
import serial
|
||||
import serial # type: ignore[import-untyped]
|
||||
|
||||
import meshtastic.util
|
||||
from meshtastic.stream_interface import StreamInterface
|
||||
|
||||
@@ -5,7 +5,7 @@ import threading
|
||||
import time
|
||||
import traceback
|
||||
|
||||
import serial
|
||||
import serial # type: ignore[import-untyped]
|
||||
|
||||
from meshtastic.mesh_interface import MeshInterface
|
||||
from meshtastic.util import is_windows11, stripnl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""
|
||||
import logging
|
||||
import socket
|
||||
from typing import AnyStr
|
||||
from typing import Optional
|
||||
|
||||
from meshtastic.stream_interface import StreamInterface
|
||||
|
||||
@@ -12,7 +12,7 @@ class TCPInterface(StreamInterface):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hostname: AnyStr,
|
||||
hostname: str,
|
||||
debugOut=None,
|
||||
noProto=False,
|
||||
connectNow=True,
|
||||
@@ -30,10 +30,10 @@ class TCPInterface(StreamInterface):
|
||||
self.portNumber = portNumber
|
||||
|
||||
if connectNow:
|
||||
logging.debug(f"Connecting to {hostname}")
|
||||
logging.debug(f"Connecting to {hostname}") # type: ignore[str-bytes-safe]
|
||||
server_address = (hostname, portNumber)
|
||||
sock = socket.create_connection(server_address)
|
||||
self.socket = sock
|
||||
self.socket: Optional[socket.socket] = sock
|
||||
else:
|
||||
self.socket = None
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from dotmap import DotMap
|
||||
from pubsub import pub
|
||||
from dotmap import DotMap # type: ignore[import-untyped]
|
||||
from pubsub import pub # type: ignore[import-untyped]
|
||||
|
||||
import meshtastic.util
|
||||
from meshtastic.__init__ import BROADCAST_NUM
|
||||
from meshtastic import BROADCAST_NUM
|
||||
from meshtastic.serial_interface import SerialInterface
|
||||
from meshtastic.tcp_interface import TCPInterface
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from meshtastic.__init__ import _onNodeInfoReceive, _onPositionReceive, _onTextReceive
|
||||
from meshtastic import _onNodeInfoReceive, _onPositionReceive, _onTextReceive
|
||||
|
||||
from ..globals import Globals
|
||||
from ..serial_interface import SerialInterface
|
||||
|
||||
@@ -6,8 +6,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from .. import mesh_pb2
|
||||
from ..__init__ import BROADCAST_ADDR, LOCAL_ADDR
|
||||
from .. import mesh_pb2, BROADCAST_ADDR, LOCAL_ADDR
|
||||
from ..mesh_interface import MeshInterface
|
||||
from ..node import Node
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import logging
|
||||
import platform
|
||||
import threading
|
||||
|
||||
from pubsub import pub
|
||||
from pubsub import pub # type: ignore[import-untyped]
|
||||
from pytap2 import TapDevice
|
||||
|
||||
from meshtastic import portnums_pb2
|
||||
|
||||
@@ -26,3 +26,4 @@ types-protobuf
|
||||
types-tabulate
|
||||
types-requests
|
||||
types-setuptools
|
||||
types-PyYAML
|
||||
|
||||
Reference in New Issue
Block a user