From b57d1d81ff2ae4865af303174137a38735b20e91 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 2 Apr 2024 15:15:22 -0700 Subject: [PATCH] Fix up pylint from merged PR --- meshtastic/mesh_interface.py | 1 - meshtastic/node.py | 2 -- meshtastic/tests/test_util.py | 1 + meshtastic/util.py | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index 275376e..e7533cc 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -12,7 +12,6 @@ from datetime import datetime import google.protobuf.json_format import timeago # type: ignore[import-untyped] -from google.protobuf.json_format import MessageToJson from pubsub import pub # type: ignore[import-untyped] from tabulate import tabulate diff --git a/meshtastic/node.py b/meshtastic/node.py index e041294..cc42cc4 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -5,8 +5,6 @@ import base64 import logging import time -from google.protobuf.json_format import MessageToJson - from meshtastic import admin_pb2, apponly_pb2, channel_pb2, localonly_pb2, portnums_pb2 from meshtastic.util import ( Timeout, diff --git a/meshtastic/tests/test_util.py b/meshtastic/tests/test_util.py index 09f5d30..8209487 100644 --- a/meshtastic/tests/test_util.py +++ b/meshtastic/tests/test_util.py @@ -551,6 +551,7 @@ def test_active_ports_on_supported_devices_mac_duplicates_check(mock_platform, m @pytest.mark.unit def test_message_to_json_shows_all(): + """Test that message_to_json prints fields that aren't included in data passed in""" actual = json.loads(message_to_json(MyNodeInfo())) expected = { "myNodeNum": 0, "rebootCount": 0, "minAppVersion": 0 } assert actual == expected diff --git a/meshtastic/util.py b/meshtastic/util.py index 9ea60b1..cef3f3d 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -614,5 +614,5 @@ def check_if_newer_version(): return pypi_version def message_to_json(message): + "Return protobuf message as JSON. Always print all fields, even when not present in data." return stripnl(MessageToJson(message, always_print_fields_with_no_presence=True)) -