style: fix bare except Exception clauses (closes #74)#77
style: fix bare except Exception clauses (closes #74)#77sjhddh wants to merge 1 commit intoHKUDS:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #74 by updating multiple Python harnesses to bind caught Exception instances (except Exception as e:) instead of using bare except Exception: with the stated goal of improving debuggability.
Changes:
- Replaced
except Exception:withexcept Exception as e:in several REPL/demo paths. - Updated some auth/login flows to bind exceptions during “best effort” user-info verification.
- Updated image-dimension probing fallback to bind exceptions when PIL/image parsing fails.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| zoom/agent-harness/cli_anything/zoom/zoom_cli.py | Binds exceptions in REPL auth status/context lookup paths. |
| zoom/agent-harness/cli_anything/zoom/core/auth.py | Binds exceptions during user info verification in login flows. |
| shotcut/agent-harness/workflow_demo.py | Binds exceptions when counting filters in the demo workflow. |
| obs-studio/agent-harness/cli_anything/obs_studio/obs_studio_cli.py | Binds exceptions while computing project name for REPL prompt. |
| libreoffice/agent-harness/cli_anything/libreoffice/libreoffice_cli.py | Binds exceptions in REPL prompt helpers (project name / modified flag). |
| inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py | Binds exceptions while computing project name for REPL prompt. |
| gimp/agent-harness/cli_anything/gimp/gimp_cli.py | Binds exceptions in REPL project name lookup. |
| gimp/agent-harness/cli_anything/gimp/core/layers.py | Binds exceptions during PIL-based image dimension probing fallback. |
Comments suppressed due to low confidence (1)
zoom/agent-harness/cli_anything/zoom/core/auth.py:141
except Exception as e:bindsebut the exception is not used. If the goal is improved debuggability, consider includingstr(e)in the returned dict (e.g., anerror/detailsfield) or logging it; otherwise bind to_instead.
except Exception as e:
return {
"status": "logged_in",
"message": "Tokens saved. Could not verify user info.",
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| except Exception: | ||
| except Exception as e: | ||
| return {"status": "logged_in", "message": "Tokens saved."} |
| except Exception as e: | ||
| return False |
| if s.has_project(): | ||
| return s.project_path or "untitled" | ||
| except Exception: | ||
| except Exception as e: |
| p = sess.get_project() | ||
| proj_name = p.get("name", "") if isinstance(p, dict) else "" | ||
| except Exception: | ||
| except Exception as e: |
| except Exception as e: | ||
| skin.info("Run 'auth setup' to configure OAuth credentials.") |
| f = filt_mod.list_filters(session, track["index"], c["clip_index"]) | ||
| filter_count += len(f) | ||
| except Exception: | ||
| except Exception as e: |
| info = proj_mod.get_project_info(sess.get_project()) | ||
| return info.get("name", "") | ||
| except Exception: | ||
| except Exception as e: |
| except Exception as e: | ||
| pass | ||
| return "" |
| with Image.open(path) as img: | ||
| w, h = img.size | ||
| except Exception: | ||
| except Exception as e: |
| except Exception as e: | ||
| context = "" |
|
Only |
|
Thanks for the review. I updated the PR to use |
|
LGTM! |
|
There's a merge conflict in |
9a44fcd to
c3388b0
Compare
|
@sehawq I've rebased the branch onto |
|
The |
|
I apologize for the back-and-forth on this issue — Closing — this is the same |
This PR fixes issue #74 by replacing bare
except Exception:withexcept Exception as e:across all harnesses to align with Python best practices and improve debuggability.(Code refactoring executed using the newly open-sourced 0-editor)