Fix: Comprehensive codebase health check and cleanup#214
Merged
Conversation
This commit addresses multiple aspects of codebase health:
1. **Test Failures:**
* Resolved 3 failing tests in `tsercom/runtime_e2etest.py` related to out-of-process error propagation and handling. The fixes involved improving synchronization using `multiprocessing.Event` to ensure child process errors are reliably detected by the parent `RuntimeManager`. Affected tests:
* `test_out_of_process_error_check_for_exception`
* `test_out_of_process_error_run_until_exception`
* `test_out_of_process_initializer_create_error`
2. **Overload Docstrings:**
* Ensured all functions using `@typing.overload` (aliased as `@overload`) have complete Google-style docstrings for each individual overload signature and for the main implementation. This involved adding or verifying docstrings in files such as:
* `tsercom/api/runtime_handle.py`
* `tsercom/runtime/runtime_data_handler.py`
* `tsercom/runtime/runtime_data_handler_base.py`
* `tsercom/tensor/demuxer/stream_receiver.py`
* `tsercom/tensor/muxer/aggregate_tensor_multiplexer.py`
* Files like `tsercom/data/remote_data_aggregator.py`, `tsercom/data/remote_data_aggregator_impl.py`, `tsercom/discovery/discovery_host.py`, `tsercom/runtime/endpoint_data_processor.py`, and `tsercom/runtime/id_tracker.py`, `tsercom/runtime/runtime_config.py` were reviewed and found to already have compliant overload documentation.
3. **Ruff Issues:**
* Added `D418` (Function decorated with @overload is missing a docstring) to the ignore list in `pyproject.toml` as the main implementation docstrings are intentionally brief when overloads are fully documented.
* Ran `ruff check . --fix` to automatically correct applicable issues.
* Manually addressed remaining Ruff violations, including:
* `E501` (Line too long) by shortening docstrings, comments, and code lines.
* `D401` (First line of docstring should be in imperative mood).
* Other `D` series docstring convention errors (D100, D101, D102, D103, D105, D107, D203, D205, D210, D211, D212, D213, D404, D413, D417).
* `W293` (Blank line contains whitespace).
* Corrected syntax errors that were inadvertently introduced during manual E501 fixes by ensuring docstrings were properly formatted.
* The codebase now passes `ruff check .` cleanly.
4. **Static Analysis and Verification:**
* Ran `black .` to format the code.
* `mypy tsercom/` was run; identified errors were pre-existing and not introduced by these changes.
* The full test suite (`pytest --timeout=120`) was run twice successfully after all changes to ensure no regressions.
This work improves test reliability, documentation quality, and code style adherence across the `tsercom/` codebase.
This commit addresses multiple aspects of codebase health:
1. **Test Failures:**
* Resolved 3 failing tests in `tsercom/runtime_e2etest.py` related to out-of-process error propagation and handling. The fixes involved improving synchronization using `multiprocessing.Event` to ensure child process errors are reliably detected by the parent `RuntimeManager`. Affected tests:
* `test_out_of_process_error_check_for_exception`
* `test_out_of_process_error_run_until_exception`
* `test_out_of_process_initializer_create_error`
2. **Overload Docstrings:**
* Ensured all functions using `@typing.overload` (aliased as `@overload`) have complete Google-style docstrings for each individual overload signature and for the main implementation. This involved adding or verifying docstrings in files such as:
* `tsercom/api/runtime_handle.py`
* `tsercom/runtime/runtime_data_handler.py`
* `tsercom/runtime/runtime_data_handler_base.py`
* `tsercom/tensor/demuxer/stream_receiver.py`
* `tsercom/tensor/muxer/aggregate_tensor_multiplexer.py`
* Files like `tsercom/data/remote_data_aggregator.py`, `tsercom/data/remote_data_aggregator_impl.py`, `tsercom/discovery/discovery_host.py`, `tsercom/runtime/endpoint_data_processor.py`, and `tsercom/runtime/id_tracker.py`, `tsercom/runtime/runtime_config.py` were reviewed and found to already have compliant overload documentation.
3. **Ruff Issues:**
* Added `D418` (Function decorated with @overload is missing a docstring) to the ignore list in `pyproject.toml` as the main implementation docstrings are intentionally brief when overloads are fully documented.
* Ran `ruff check . --fix` to automatically correct applicable issues.
* Manually addressed remaining Ruff violations, including:
* `E501` (Line too long) by shortening docstrings, comments, and code lines.
* `D401` (First line of docstring should be in imperative mood).
* Other `D` series docstring convention errors (D100, D101, D102, D103, D105, D107, D203, D205, D210, D211, D212, D213, D404, D413, D417).
* `W293` (Blank line contains whitespace).
* Corrected syntax errors that were inadvertently introduced during manual E501 fixes by ensuring docstrings were properly formatted.
* The codebase now passes `ruff check .` cleanly.
4. **Static Analysis and Verification:**
* Ran `black .` to format the code.
* Configured `mypy` in `pyproject.toml` to ignore missing stubs for `grpc_health.v1._async`, `lz4.frame`, `lz4`, and `ntplib`. Removed corresponding `unused-ignore` comments. Added `no-untyped-call` ignores for `share_memory_()` calls. `mypy tsercom/` now passes without errors.
* The full test suite (`pytest --timeout=120`) was run twice successfully after all changes to ensure no regressions.
This work improves test reliability, documentation quality, and code style adherence across the `tsercom/` codebase.
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.
This commit addresses multiple aspects of codebase health:
Test Failures:
tsercom/runtime_e2etest.pyrelated to out-of-process error propagation and handling. The fixes involved improving synchronization usingmultiprocessing.Eventto ensure child process errors are reliably detected by the parentRuntimeManager. Affected tests:test_out_of_process_error_check_for_exceptiontest_out_of_process_error_run_until_exceptiontest_out_of_process_initializer_create_errorOverload Docstrings:
@typing.overload(aliased as@overload) have complete Google-style docstrings for each individual overload signature and for the main implementation. This involved adding or verifying docstrings in files such as:tsercom/api/runtime_handle.pytsercom/runtime/runtime_data_handler.pytsercom/runtime/runtime_data_handler_base.pytsercom/tensor/demuxer/stream_receiver.pytsercom/tensor/muxer/aggregate_tensor_multiplexer.pytsercom/data/remote_data_aggregator.py,tsercom/data/remote_data_aggregator_impl.py,tsercom/discovery/discovery_host.py,tsercom/runtime/endpoint_data_processor.py, andtsercom/runtime/id_tracker.py,tsercom/runtime/runtime_config.pywere reviewed and found to already have compliant overload documentation.Ruff Issues:
D418(Function decorated with @overload is missing a docstring) to the ignore list inpyproject.tomlas the main implementation docstrings are intentionally brief when overloads are fully documented.ruff check . --fixto automatically correct applicable issues.E501(Line too long) by shortening docstrings, comments, and code lines.D401(First line of docstring should be in imperative mood).Dseries docstring convention errors (D100, D101, D102, D103, D105, D107, D203, D205, D210, D211, D212, D213, D404, D413, D417).W293(Blank line contains whitespace).ruff check .cleanly.Static Analysis and Verification:
black .to format the code.mypy tsercom/was run; identified errors were pre-existing and not introduced by these changes.pytest --timeout=120) was run twice successfully after all changes to ensure no regressions.This work improves test reliability, documentation quality, and code style adherence across the
tsercom/codebase.