fix: remove no-op self-assignment 'fromcall = fromcall' in USMetarPlugin (#272)

In the else-branch of USMetarPlugin.process(), 'fromcall = fromcall'
is a self-assignment that does nothing.  It was likely a leftover from
an edit that intended to reassign fromcall but forgot to write the RHS.
Remove the dead line.  The variable is still used correctly on the next
line (get_aprs_fi call).

Closes #253
This commit is contained in:
2026-08-28 14:13:05 -04:00
committed by GitHub
parent aa43f60728
commit f83154b6e9
3 changed files with 25 additions and 2 deletions
+2
View File
@@ -8,6 +8,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
##### Bug Fixes
- Fix USMetarPlugin.process() self-assignment no-op 'fromcall = fromcall' [`44ff252`](https://github.com/craigerl/aprsd/commit/44ff252)
- Add reset() to @singleton decorator; update tests to use ClassName.reset() instead of ClassName.instance = None [`ef19aaa`](https://github.com/craigerl/aprsd/commit/ef19aaa)
- Fix PacketTrack.keys/items/values — return list snapshots instead of live dict views outside the lock [`088436e`](https://github.com/craigerl/aprsd/commit/088436e)
-2
View File
@@ -121,8 +121,6 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin):
return reply
else:
# if no second argument, search for calling station
fromcall = fromcall
api_key = CONF.aprs_fi.apiKey
try:
+23
View File
@@ -202,3 +202,26 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
packet = fake.fake_packet(message='metar')
actual = wx.filter(packet)
self.assertEqual(expected, actual)
@mock.patch('aprsd.plugins.weather.plugin_utils.get_aprs_fi')
def test_process_no_station_arg_uses_fromcall(self, mock_aprs_fi):
"""USMetarPlugin.process() must use packet.from_call when no station arg given.
Previously the else-branch contained the no-op 'fromcall = fromcall' which
was dead code. This test verifies that fromcall is still passed correctly
to get_aprs_fi after that line was removed.
"""
mock_aprs_fi.side_effect = Exception('aprs.fi down')
CONF.aprs_fi.apiKey = 'abc123'
CONF.callsign = fake.FAKE_TO_CALLSIGN
wx = weather_plugin.USMetarPlugin()
wx.enabled = True
# A message with no second word: regex will not match → else-branch
packet = fake.fake_packet(message='metar')
result = wx.filter(packet)
# Should call get_aprs_fi with the packet's from_call
mock_aprs_fi.assert_called_once_with('abc123', fake.FAKE_FROM_CALLSIGN)
self.assertIn('Failed', result)