-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make Context and Manager variadic types (#1445)
Closes #1444. This change enables passing the Charm type all the way from the Context to the charm attribute in the manager for better autocompletion and type checks. You can give this a try with the following code snippet: ```python from ops import CharmBase from testing.src.scenario import Context, State class MyCharm(CharmBase): some_attribute: str def test_function(): ctx = Context(MyCharm) state = State() with ctx(ctx.on.config_changed(), state) as manager: charm = manager.charm charm.some_attribute # behold, autocompletion! ``` A word of caution, though, the testing module is not using the bundled scenario code base. It is still using `ops_scenario`. For users to benefit from this new feature, we would need to change the import machinery.
- Loading branch information
Showing
2 changed files
with
17 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters