refactor: use shopen instead of manual launch_editor#4
Conversation
…anum#767) Replace the hand-rolled launch_editor utility (which tried editor/EDITOR/ xdg-open/open in sequence) with the shopen library. Removes subprocess and os imports from utils.py. Conflict-resolved against main. Co-Authored-By: David Barnett <noreply@github.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Refactors the CLI’s “edit config” workflow to rely on the shopen library for cross-platform “open/edit” behavior, replacing the project’s hand-rolled editor/launcher logic.
Changes:
- Add
shopenas a runtime dependency. - Remove
launch_editor(and now-unused imports) fromgcalcli/utils.py. - Update
gcalcli config editto callshopen.open(..., 'edit').
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Adds the shopen dependency required by the new config-edit implementation. |
| gcalcli/utils.py | Removes the legacy launch_editor helper and associated unused imports. |
| gcalcli/cli.py | Switches the config edit subcommand to use shopen for launching an editor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| config_filepath.parent.mkdir(parents=True, exist_ok=True) | ||
| with open(config_filepath, 'w') as f: | ||
| f.write(EMPTY_CONFIG_TOML) | ||
| utils.launch_editor(config_filepath) | ||
| shopen.open(config_filepath, 'edit') |
There was a problem hiding this comment.
The new config edit path now depends on calling shopen.open(...), but there doesn’t appear to be any automated test covering this behavior (the existing CLI bats tests cover other commands but not config edit). Please add a test that exercises gcalcli config edit while stubbing/monkeypatching shopen.open so the test can assert it’s invoked with edit without launching a real editor, and that the config file is created when missing.
| "platformdirs", | ||
| "pydantic", | ||
| "python-dateutil", | ||
| "shopen >= 0.2.2", |
There was a problem hiding this comment.
Dependency spec formatting is inconsistent with the rest of this file: other requirements are written without spaces around the version operator (e.g., google-api-python-client>=1.4). Consider changing "shopen >= 0.2.2" to "shopen>=0.2.2" for consistency and to avoid potential issues with tools that do strict parsing.
| "shopen >= 0.2.2", | |
| "shopen>=0.2.2", |
Ported from insanum/gcalcli#767 by @dbarnett. Conflict-resolved against this fork's main.
Summary
launch_editor(which triededitor/$EDITOR/xdg-open/openin sequence) with theshopenlibrarylaunch_editorfromutils.py, along with now-unusedosandsubprocessimportsshopen >= 0.2.2topyproject.tomldependenciesWhy
The
shopenlibrary handles cross-platform file opening/editing more robustly than the manual fallback chain.🤖 Generated with Claude Code