refactor: remove dead and redundant code#135
Merged
Merged
Conversation
0d61b9a to
9cd6501
Compare
9cd6501 to
2fd4724
Compare
The `is_valid_serial_number()` function in `model.py` had no call sites anywhere in the library or the test suite, so it was effectively dead code. It also predated the current API: it accepts a `str | None` and checks for the literal sentinel `"urn:uuid:None"`, whereas `StandardBom.serial_number` now exposes a `UUID`. The helper no longer matched how serial numbers are represented, so keeping it risked confusion. Remove it to reduce dead surface area. No behavior or public API change; the full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) still passes.
Keep the defensive None checks around CycloneDX-managed collections, so the code remains resilient if the upstream API changes its default initializers. Simplify the author list getter by using an empty-list fallback directly, and remove the redundant `custom_property_key is not None` checks from custom property accessors. The key is typed as `str`, and all callers pass concrete property constants, so those clauses did not add protection. No behavior change; the full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) passes.
`SbomNature` defines explicit string values (`"source"`, `"binary"`), so the `enum.auto` case in the `__new__` type check can never occur — members are never generated via `auto()`. Narrow the guard to `isinstance(value, str)` and remove the now-unused `import enum`. No behavior or public API change; the type check still rejects non-string values exactly as before. The full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) passes.
`renovate.json` only contained an empty object, so it did not configure Renovate behavior. Dependabot is already configured in `.github/dependabot.yml` for Poetry/pip and GitHub Actions updates, making the empty Renovate file redundant repository noise. No runtime behavior change; the full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) passes.
`ImmutableList` does not store a `_length` attribute; length is derived from the immutable `_items` tuple. The previous test passed by trying to assign a nonexistent frozen dataclass field, which did not verify any real length state. Replace it with a behavior-focused assertion: constructing from a mutable list takes a tuple snapshot, so later mutations to the source list do not affect `len()`. No runtime behavior change; the full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) passes.
2fd4724 to
58a7182
Compare
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
is_valid_serial_number()helper.enum.autobranch fromSbomNature.__new__.renovate.json; Dependabot remains configured.ImmutableListlength test to snapshot behavior.Testing
poetry run tox run