-
-
Notifications
You must be signed in to change notification settings - Fork 614
Description
Description
ScanCode 32.4.1 fails to start when Click 8.3.0 is installed, throwing a TypeError: Secondary flag is not valid for non-boolean flag. This appears to be a compatibility issue between ScanCode's CLI option definitions and stricter validation introduced in Click 8.3.0.
Error Message
Traceback (most recent call last):
File "/tmp/scancode-env/bin/scancode", line 5, in <module>
from scancode.cli import scancode
File "/tmp/scancode-env/lib/python3.10/site-packages/scancode/cli.py", line 383, in <module>
def scancode(
File "/tmp/scancode-env/lib/python3.10/site-packages/click/decorators.py", line 374, in decorator
_param_memo(f, cls(param_decls, **attrs))
File "/tmp/scancode-env/lib/python3.10/site-packages/commoncode/cliutils.py", line 454, in __init__
super(PluggableCommandLineOption, self).__init__(
File "/tmp/scancode-env/lib/python3.10/site-packages/click/core.py", line 2793, in __init__
raise TypeError("Secondary flag is not valid for non-boolean flag.")
TypeError: Secondary flag is not valid for non-boolean flag.
How To Reproduce
- Install scancode-toolkit 32.4.1 via pip:
- This will automatically install Click 8.3.0 (latest version)
- Try to run any scancode command:
- Observe the error above
pip install scancode-toolkit==32.4.1
scancode --license <repo-path>
Environment Information
- ScanCode Version: 32.4.1
- Click Version: 8.3.0 (problematic), 8.2.1 (works)
- Python Version: 3.10 (but likely affects other versions)
- OS: Linux x64 (but likely affects other platforms)
- Installation Method: pip install
Root Cause Analysis
The issue appears to be in commoncode/cliutils.pyline 454, where PluggableCommandLineOption is trying to create CLI options that Click 8.3.0 considers invalid. Specifically, Click 8.3.0 introduced stricter validation that prohibits secondary flags (like --flag/--no-flag) for non-boolean options.
Current Workaround
Downgrade Click to the previously working version:
pip install click==8.2.1 --upgrade
Suggested Solution
Update ScanCode's CLI option definitions to be compatible with Click 8.3.0's stricter validation rules. This likely involves:
- Reviewing all CLI options defined in ```commoncode/cliutils.py``` and related files
- Ensuring that only boolean flags use secondary flag patterns
- Updating any non-boolean options that incorrectly use secondary flags
- Testing with both Click 8.2.1 and 8.3.0 to ensure backward compatibility
Additional Context
- The pre-built ScanCode release archive (TAR) works because it includes its own venv with Click 8.2.1
- This affects users who install via pip, as they get the latest Click version automatically
- Multiple users have reported this issue independently
Dependency Version Information
Working combination (from release archive):
- scancode-toolkit: 32.4.1
- click: 8.2.1
Failing combination (from pip install):
- scancode-toolkit: 32.4.1
- click: 8.3.0
Request
Could the maintainers please:
- Update the code to be compatible with Click 8.3.0
- Consider pinning Click to a specific version range in requirements until compatibility is ensured
- Update the installation documentation to mention this compatibility issue as a temporary workaround
Thank you for maintaining this valuable tool!