[SP-3728] Fix scanoss-py inspect copyleft help display#184
[SP-3728] Fix scanoss-py inspect copyleft help display#184descorchator wants to merge 1 commit intomainfrom
Conversation
Implemented by Gepeto Escalante. JIRA: https://scanoss.atlassian.net/browse/SP-3728
📝 WalkthroughWalkthroughModified error handling in four inspect subcommands to dynamically build help invocation paths based on available subcommands. When input is missing, the program now determines the appropriate help context instead of using a static help invocation sequence. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SCANOSS SCAN Completed 🚀
View more details on SCANOSS Action Summary |
JIRA Ticket: SP-3728
Fix scanoss-py inspect copyleft help display
Changes
Confirmed safe — line 1341 is only reached when
subparsercmdisraw/dt/glc/gitlab, which all definesubparser_subcmdas adestin their subparsers. Python evaluatesandconditions left-to-right with short-circuit evaluation, so if the second condition isFalse, line 1341 is never evaluated.Summary
Root cause: In v1.32.0, the
inspectcommand was refactored to support nested command groups (raw,dt,gitlab) with asubparser_subcmdattribute. Legacy backward-compatible commands (scanoss-py inspect copyleft) were kept at the top level ofinspectbut their parser doesn't definesubparser_subcmd. When any of the four inspect handler functions (inspect_copyleft,inspect_undeclared,inspect_license_summary,inspect_component_summary) tried to display help on missing input, they directly accessedargs.subparser_subcmd, causing anAttributeErrorfor legacy commands.Fix applied in
src/scanoss/cli.py— four handler functions modified (lines ~1809, ~1870, ~1929, ~1981):Changed from:
To:
This safely handles both paths:
scanoss-py inspect copyleft):subcmdisNone, help args =['inspect', 'copyleft', '-h']scanoss-py inspect raw copyleft):subcmdis'copyleft', help args =['inspect', 'raw', 'copyleft', '-h']This PR was automatically generated by Gepeto Escalante.
Summary by CodeRabbit