Repository navigation
fix: Python 3.14 compatibility and test suite correctness - #2
Merged
Merged
Conversation
Python 3.14 changed dataclasses._is_type to require cls.__module__ to exist in sys.modules when exec_module is called. Three packages load legacy .py files alongside same-named packages via importlib without registering the module in sys.modules first, breaking @DataClass. Fix all three by inserting sys.modules[_spec.name] = _legacy before exec_module in chemical_rf/__init__.py, forensics/__init__.py and lab/__init__.py. Additional fixes uncovered during testing: materials.py: absorption_coefficient referenced an undefined reflection_coefficient function; add reflection_coefficient as the canonical Γ = (Z_L - Z_0)/(Z_L + Z_0) formula and rewrite absorption_coefficient to use it. __init__.py (chemical_rf): also export absorption_coefficient which was already used in tests. cli.py: wire lab_cli sub-command that was imported but never added. physics_laboratory.py: calculate_link_budget returned 'margin_db' but callers (and tests) expected 'link_margin_db'; rename the key. Remove three dead instance methods on RadarSimulator that shadowed the correct @staticmethod implementations and contained unreachable code after early return statements. fingerprint.py: np.fft.rfft rejects complex64 input; switch to np.fft.fft / np.fft.fftfreq. Remove two dead lines in similarity() that tried to cast hex SHA-256 digest strings to np.uint8. timeseries_engine.py: add_data set position=0 after a full-buffer write (n >= buffer_size), causing subsequent reads via buffer[:position] to return an empty slice. Set position=buffer_size instead so the buffer is correctly reported as full. Also handle the previously-missing case where n >= buffer_size (overflow without wrap) with an explicit branch. pytest.ini: replace Python docstring (which pytest silently ignores) with a valid [pytest] INI section. tests/conftest.py: merge fixtures from conftest_enterprise.py which pytest never auto-loaded; extend base fixtures to sizes required by the enterprise test suite (1 M-sample signals, richer iq_data). Tested: 63 passed, 2 skipped on Python 3.14.7. SPDX-License-Identifier: AGPL-3.0-only
black-88888
reviewed
Sep 21, 2026
black-88888
left a comment
Collaborator
There was a problem hiding this comment.
I might accept, but I'm not sure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes 8 bugs that make VULTURE fail on Python 3.14 and break the test suite on all Python versions. Every issue was found during packaging for the Pentoo Linux overlay and tested deeply — the full suite runs 63 passed, 2 skipped on Python 3.14.7 after these changes.
1. Python 3.14 —
sys.modulesregistration missing beforeexec_module(3 files)chemical_rf/__init__.py,forensics/__init__.py,lab/__init__.pyall load a legacy.pysibling viaimportlibwithout registering the module insys.modulesfirst. Python 3.14 changeddataclasses._is_typeto look upcls.__module__insys.modules; without the registration every@dataclassin those modules raisesTypeError.Fix:
sys.modules[_spec.name] = _legacybeforeexec_module.2.
materials.py—reflection_coefficientundefined,absorption_coefficientbrokenabsorption_coefficientcallsreflection_coefficientwhich doesn't exist in the file →NameErroron import.__init__.pyandpipeline.pyalso importreflection_coefficientby name.Fix: add
reflection_coefficientas(Z_L - Z_0) / (Z_L + Z_0)and rewriteabsorption_coefficientas1 - abs(gamma)**2.3.
cli.py—lab_cliimported but never registeredfrom vulture.lab_cli import lab_cliis present butcli.add_command(lab_cli, name="lab")is missing →vulture labsilently unavailable.4.
physics_laboratory.py— wrong dict key; dead instance methods cause infinite recursioncalculate_link_budgetreturns'margin_db'but all callers expect'link_margin_db'.RadarSimulatorare defined after the correct@staticmethodimplementations. Each returns a lambda immediately (unreachable code below), and the final duplicatecalculate_radar_rangeshadows the static version and recurses infinitely.5.
fingerprint.py—rfftrejects complex input; dead code raisesValueErrornp.fft.rffton complex64 IQ data raisesTypeError— should benp.fft.fft/np.fft.fftfreq.similarity()cast hex SHA-256 strings tonp.uint8→ValueError; variabledis never used.6.
timeseries_engine.py— circular buffer returns empty slice after full writeadd_datawas missing then >= buffer_sizecase. After filling the buffer it setposition = 0, sobuffer[:position]returned an empty array. Fix: setposition = buffer_sizeand add an explicit branch for the overflow case.7.
pytest.ini— contains a Python docstring, not an INI sectionThe file held
"""Pytest markers…"""— a string literal pytest silently ignores. Replaced with[pytest].8.
tests/conftest.py—conftest_enterprise.pynever auto-loadedpytest only discovers files named
conftest.py. All fixtures inconftest_enterprise.py(bpsk_signal,qpsk_signal,chirp_signal,burst_signal,multipath_signal) were invisible to the test runner. Merged intoconftest.pyand extended base fixtures to the sizes the enterprise suite requires.Test result:
63 passed, 2 skippedon Python 3.14.7 (was: import errors + multiple test failures before this patch).SPDX-License-Identifier: AGPL-3.0-only