Repository navigation
Commit 8a09fd5
fix: assert hygiene -- unreachable assert, two caller-facing checks
Found while surveying src/'s ~48 Bandit B101 (assert_used) findings; most
are legitimate (type-narrowing after a prior check, or optional-dependency
guards immediately following an ImportError raise) and are staying as-is.
Three were real issues:
- Sources.py (PointCloud publish support): `assert o3d is not None` sat
*inside* the `if not _open3d_available: raise ImportError(...)` block,
after the raise -- unreachable dead code, apparently a mis-indented
copy of the same pattern used correctly at 7 other call sites in this
file. Dedented to match.
- BundleAdjust.py: `add_projection()`'s `assert len(uv) == 2` validates a
caller-supplied argument on a public method, not an internal invariant --
converted to `if len(uv) != 2: raise ValueError(...)` so it survives
`python -O` instead of silently vanishing.
- Camera.py: `nu`/`nv`/`width`/`height` each asserted
`self._imagesize is not None, "imagesize not set"` -- a real "you called
this before configuring the camera" caller mistake (the informative
message was the tell), not an internal invariant. Converted to
`if self._imagesize is None: raise ValueError(...)`, matching the
existing `raise ValueError("imagesize or rho properties not set")`
convention already used elsewhere in this file.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 3636461 commit 8a09fd5
3 files changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
| 409 | + | |
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
| 354 | + | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| |||
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
373 | | - | |
| 374 | + | |
| 375 | + | |
374 | 376 | | |
375 | 377 | | |
376 | 378 | | |
| |||
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
393 | | - | |
| 395 | + | |
| 396 | + | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| |||
410 | 413 | | |
411 | 414 | | |
412 | 415 | | |
413 | | - | |
| 416 | + | |
| 417 | + | |
414 | 418 | | |
415 | 419 | | |
416 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2348 | 2348 | | |
2349 | 2349 | | |
2350 | 2350 | | |
2351 | | - | |
| 2351 | + | |
2352 | 2352 | | |
2353 | 2353 | | |
2354 | 2354 | | |
| |||
0 commit comments