adafruit / adafruit/circup

Update command only partially working for local path instead of device

Open
#220 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
172
Forks
41
Avg merge
1d 20h
Merged PRs (30d)
1

Description

Technically the combination of `--path`, `--cpy-version`, and `--board-id` should allow any of the other commands to run targeting a local directory (without a boot_out.txt file) instead of a physical device.

However the `update` command currently raises an error if you attempt to use it with these arguments.
```
$ circup --path fake_project/ --cpy-version 8.0.0 --board-id fake update
Found device at fake_project/, running CircuitPython 8.0.0.
A newer version of CircuitPython (9.0.4) is available.
Get it here: https://circuitpython.org/board/fake
Traceback (most recent call last):
File "/home/timc/.local/bin/circup", line 33, in
sys.exit(load_entry_point('circup', 'console_scripts', 'circup')())
File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/timc/.local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/timc/repos/circuitpython/circup/circup/commands.py", line 493, in update
modules_to_update = [m for m in installed_modules if m.outofdate]
File "/home/timc/repos/circuitpython/circup/circup/commands.py", line 493, in
modules_to_update = [m for m in installed_modules if m.outofdate]
File "/home/timc/repos/circuitpython/circup/circup/module.py", line 108, in outofdate
if self.mpy_mismatch:
File "/home/timc/repos/circuitpython/circup/circup/module.py", line 142, in mpy_mismatch
if self.min_version and cpv < VersionInfo.parse(self.min_version):
UnboundLocalError: local variable 'cpv' referenced before assignment
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported command using a local path, --cpy-version, and --board-id, then inspect circup/commands.py around update and circup/module.py around mpy_mismatch. Confirm the behavior of the version check for this local-path case. Done means the update command no longer raises UnboundLocalError and completes its local-directory workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.