Update charm templates to use ops 2.2.0 and new "import ops" style
Metadata
Current evaluation
Merged PR #1055 (commit 8f77e7fb), updating all three charm templates to ops 2.2.0, the `import ops` style, and typed event handlers.
Resolution: closed resolved
Reason: PR #1055 was merged as commit 8f77e7fb, updating the generated charm templates to use the ops 2.2.0 import style and event type hints.
Evaluated by: mr-cal-bot
No scores available.
Issue body
With https://github.com/canonical/operator/pull/910 (released in ops 2.2.0) the recommended way to import ops is simply `import ops`, so you don't have to worry about which sub-module the various names are in.
Also add type hints for the event types.
I've created a charm using `charmcraft init` with each of these 3 template types, and verified the code is correct and passes the unit tests.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #1055 (commit 8f77e7fb), updating all three charm templates to ops 2.2.0, the `import ops` style, and typed event handlers. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #1055 (commit 8f77e7fb), updating all three charm templates to ops 2.2.0, the `import ops` style, and typed event handlers. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged update to charm templates adopting ops 2.2.0 and the simplified import ops syntax. Added type hints for event types. Approved by two reviewers, passed CI, and verified with charmcraft init and unit tests. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged update to charm templates adopting ops 2.2.0 and the simplified import ops syntax. Added type hints for event types. Changes verified via charmcraft init and unit tests. |
Update history
No update history recorded yet.
Related work
-
Related To:
operator#910
(confidence 99%)
Added the root-level ops imports released in ops 2.2.0 and used by the updated templates.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1911 feat: use ops.main() type hints | charmcraft | merged | Updated charm templates to require ops 2.17.0 and pass the charm class to typed ops.main(); merged as commit 2fe53628. | |
| #175 Tweek template | charmcraft | merged | Merged PR #175 in commit 0cc248c0, updating Charmcraft’s template from ops 0.7 to ops 0.8. |