mirror of
https://github.com/craigerl/aprsd.git
synced 2026-08-28 14:55:37 -04:00
fix: remove dead-code Python version guard in utils/__init__.py (#270)
The guard:
if sys.version_info.major == 3 and sys.version_info.minor >= 3:
from collections.abc import MutableMapping
else:
from collections.abc import MutableMapping
has identical branches — both import from collections.abc (the correct
Python 3.3+ location). Remove the guard; keep the bare import.
Closes #251
This commit is contained in:
@@ -12,6 +12,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
- Enable ruff isort (I) ruleset in pyproject.toml [`a3801f6`](https://github.com/craigerl/aprsd/commit/a3801f6)
|
||||
|
||||
- Remove dead-code Python version guard in utils/__init__.py: both branches were identical [`aa43f60`](https://github.com/craigerl/aprsd/commit/aa43f60)
|
||||
|
||||
- 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)
|
||||
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
import update_checker
|
||||
|
||||
@@ -18,11 +19,6 @@ from .fuzzyclock import fuzzy # noqa: F401
|
||||
# aprsd.utils
|
||||
from .ring_buffer import RingBuffer # noqa: F401
|
||||
|
||||
if sys.version_info.major == 3 and sys.version_info.minor >= 3:
|
||||
from collections.abc import MutableMapping
|
||||
else:
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
|
||||
def singleton(cls):
|
||||
"""Make a class a Singleton class (only one instance).
|
||||
|
||||
@@ -323,3 +323,22 @@ class TestUtils(unittest.TestCase):
|
||||
level, msg = utils._check_version()
|
||||
self.assertEqual(level, 1)
|
||||
self.assertEqual(msg, 'New version available')
|
||||
|
||||
|
||||
class TestDeadCodeRemoval(unittest.TestCase):
|
||||
"""Regression tests for dead code that was removed."""
|
||||
|
||||
def test_mutable_mapping_importable(self):
|
||||
"""MutableMapping must be importable from aprsd.utils after dead-code removal.
|
||||
|
||||
The version guard
|
||||
if sys.version_info.major == 3 and sys.version_info.minor >= 3:
|
||||
from collections.abc import MutableMapping
|
||||
else:
|
||||
from collections.abc import MutableMapping
|
||||
had both branches do the same thing. After removing the guard the import
|
||||
must still succeed on all supported Python versions.
|
||||
"""
|
||||
from aprsd.utils import MutableMapping as MM # noqa: N814
|
||||
|
||||
self.assertTrue(issubclass(dict, MM))
|
||||
|
||||
Reference in New Issue
Block a user