← Back to issue list

Drop extraneous type checks

View original Github issue

Metadata

Project
craft-parts
Number
#1707
Type
issue
State
open
Author
mr-cal
Labels
—
Created
Updated
Closed
—

Current evaluation

Maintainer cleanup task to remove redundant runtime type checks (e.g. the isinstance(dict) guard in PartSpec.unmarshal); open, unlabelled, no comments, and only one example site given.

Suggested action: needs triage

Reason: The issue has no labels, assignee, or maintainer comments, so it has not been triaged; the body says only "such as" plus a single linked example (parts.py L683-684, now the `if not isinstance(data, dict): raise TypeError("part data is not a dictionary")` guard in unmarshal, at L712-714), leaving the candidate set open-ended. The same pattern appears in at least 12 places (filesystem_mounts.py:76/213, infos.py:129/183, parts.py:712/861/1495, state_manager/*), several of which produce user-facing errors asserted by tests (e.g. tests/integration/test_main.py:143 "parts definition must be a dictionary", tests/unit/test_parts.py:769), so maintainers need to decide which guards are safe to drop and which to keep.

Evaluated by: mr-cal-bot

Impact: 25 Quick Win: 8 Complexity: 30 Confidence: 70 Actionability: 45

Issue body

### What needs to get done Remove the extraneous type checks, such as: https://github.com/canonical/craft-parts/blob/d8e891aeffb41f7a63d8d69ebba402c237fedad8/craft_parts/parts.py#L683-L684 ### Why it needs to get done These were added before we had confidence in our type-checking and can be removed to simplify the codebase.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 25
Quick Win: 8
Complexity: 30
Confidence: 70
Actionability: 45
needs triage Maintainer cleanup task to remove redundant runtime type checks (e.g. the isinstance(dict) guard in PartSpec.unmarshal); open, unlabelled, no comments, and only one example site given.
stealth/space-bunny-alpha
Impact: 15
Quick Win: 4
Complexity: 40
Confidence: 78
Actionability: 45
needs triage Maintainer cleanup task: remove redundant runtime type checks (e.g. the isinstance guard in PartSpec.unmarshal) now that typing is trustworthy. Referenced lines are superseded by later commits, but the check itself remains at HEAD.
stealth/space-bunny-alpha
Impact: 27
Quick Win: 9
Complexity: 47
Confidence: 92
Actionability: 66
needs triage Untriaged maintainer cleanup to remove redundant runtime type checks; the linked revision contains 15 checker-suppressed candidates, but the complete scope and expected invalid-input behavior are unspecified.
qwen3.6-35b-a3b-mtp-q6
Impact: 35
Quick Win: 26
Staleness: 5
Complexity: 25
Confidence: 75
Support Request: 0
needs triage Maintainer mr-cal requests removing redundant isinstance(data, dict) checks across craft-parts, added before strict type checking was enabled. 12 occurrences found. Issue is 4 days old with no maintainer response.

Update history

Date Change
updated
created

Related work

  • Related To: craft-parts#1706 (confidence 45%)

    The body justifies the cleanup by type-checking confidence ("added before we had confidence in our type-checking"); commit 770e2130 is titled 'style: drop mypy, pyright', which changes that context, but I found no commit actually removing these checks.

Related issues

No related issues found above the similarity threshold.