← Back to issue list

feat: use ops.main() type hints

View original Github issue

Metadata

Project
charmcraft
Number
#1911
Type
pull request
State
merged
Author
dimaqq
Labels
—
Created
Updated
Closed

Current evaluation

Updated charm templates to require ops 2.17.0 and pass the charm class to typed ops.main(); merged as commit 2fe53628.

Resolution: closed resolved

Reason: PR charmcraft#1911 was approved and merged, updating 14 template files so newly generated charms use the correctly typed ops.main() call from ops 2.17.0.

Evaluated by: mr-cal-bot

No scores available.

Issue body

The `ops.main` entry point will be properly typed starting with the upcoming release, ops==2.17.0 This PR updates the templates so that new charms use the fixed type hints. It is paired with #1883 where charmcraft analyse validates that ops.main is called. We'll be relying on charm repo static type checker to validate that ops.main is called with correct arguments. - [x] wait for ops 2.17.0 to be released - [x] update ops version in the templates - [x] update ops.main() call in the templates https://warthogs.atlassian.net/browse/CHARMTECH-276 parent: https://warthogs.atlassian.net/browse/CHARMTECH-219

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Updated charm templates to require ops 2.17.0 and pass the charm class to typed ops.main(); merged as commit 2fe53628.
stealth/space-bunny-alpha — closed resolved Merged as 2fe53628: charm templates now use the typed ops.main() API and ops 2.17.0.
stealth/space-bunny-alpha — closed resolved Merged as commit 2fe53628: charm templates now use typed ops.main() from ops 2.17.0. The update complements #1883.
qwen/qwen3.6-35b-a3b — — Merged after updating charm templates to use newly typed ops.main() from ops 2.17.0. Approved by reviewers and resolved merge conflicts with related PR #1883.
qwen3.6-35b-a3b-mtp-q6 — — Merged. Updated charmcraft templates to use ops.main() type hints from ops 2.17.0. Dependency specifications and template calls were updated following the library release and code review.

Update history

No update history recorded yet.

Related work

  • Related To: charmcraft#1883 (confidence 99%)

    Paired PR charmcraft#1883, merged as b6fbbe93, added charmcraft analyse validation for ops.main() calls.

Related issues

Issue Project State Summary Similarity
#1055 Update charm templates to use ops 2.2.0 and new "import ops" style charmcraft merged Merged PR #1055 (commit 8f77e7fb), updating all three charm templates to ops 2.2.0, the `import ops` style, and typed event handlers.
77%
#1933 feat: use the newer ops.testing classes for the charm unit tests charmcraft merged Merged PR #1933 migrated simple, machine, and Kubernetes charm templates from legacy Harness tests to ops.testing while preserving test coverage.
71%
#1820 feat: [wip] detect charm classes and ops.main() calls charmcraft closed Closed unmerged as WIP; its ops.main analysis was superseded by charmcraft#1883, merged as b6fbbe93 to add charmcraft analyse validation for Operator Framework charms.
70%