fix: replace input-validation asserts with explicit raises for PYTHONOPTIMIZE=1 compatibility#106
Draft
janickm wants to merge 1 commit into
Draft
fix: replace input-validation asserts with explicit raises for PYTHONOPTIMIZE=1 compatibility#106janickm wants to merge 1 commit into
janickm wants to merge 1 commit into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
…OPTIMIZE=1 compatibility Convert ~160 assert statements used for input validation to explicit if/raise ValueError/TypeError/FileNotFoundError across 16 files. This ensures validation is not silently stripped when running with python -O (PYTHONOPTIMIZE=1). True invariants (internal post-conditions that indicate bugs) are preserved as assert statements. Tests updated to expect ValueError/TypeError instead of AssertionError where the production code was changed.
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
assertstatements used for input validation to explicitif/raise ValueError/TypeError/FileNotFoundErroracross the codebase so that validation is not silently stripped underPYTHONOPTIMIZE=1(python -O).assert.assertRaises(AssertionError)toassertRaises(ValueError)/assertRaises(TypeError)where production code changed.Files changed (16)
Production code (13 files):
ncore/impl/common/transformations.py— interval, pose interpolator, point cloud transform validationncore/impl/common/util.py— file/directory existence checksncore/impl/data/compat.py— frame time range validationncore/impl/data/types.py— all dataclass__post_init__field validationncore/impl/data/v4/compat.py— component group name validation (from prior PR)ncore/impl/data/v4/components.py— pose, sensor frame, point cloud, label storage validationncore/impl/sensors/camera.py— constructor fields, argument shapes/dtypes/timestampsncore/impl/sensors/common.py— overflow checks, newton iterations, quaternion shapesncore/impl/sensors/lidar.py— argument shapes/dtypes/timestampsncore/impl/data_converter/base.py— sensor ID subset validationtools/data_converter/colmap/converter.py— camera type validationtools/data_converter/pai/converter.py— pose count, platform class validationtools/data_converter/waymo/converter.py— frame count validationtools/ncore_project_pc_to_img.py— CLI parameter validationTest code (3 files):
ncore/impl/common/transformations_test.pyncore/impl/data/v4/components_test.pyncore/impl/sensors/camera_test.pyVerification
All 28 test targets pass both with and without
PYTHONOPTIMIZE=1: