Skip to content

Conversation

@tonyandrewmeyer
Copy link
Collaborator

@tonyandrewmeyer tonyandrewmeyer commented Dec 18, 2025

Neither of the get_filesystem methods make any use of the generic type of Context, but we need to provide a type to avoid having calls need a type: ignore, so Any seems the appropriate type.

Maybe #2242 should be done instead? But I think that can be done later, replacing this if needed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the type annotations for the get_filesystem methods in two classes (Container and Storage) to use Context[Any] instead of the bare Context type. Since these methods only use generic Context methods that don't depend on the specific charm type parameter, using Any as the type parameter is appropriate and avoids requiring type: ignore comments at call sites.

Key changes:

  • Updated type annotation for Container.get_filesystem() parameter from Context to Context[Any]
  • Updated type annotation for Storage.get_filesystem() parameter from Context to Context[Any]
  • Removed the entire testing/tests/test_plugin.py test file (unrelated to type annotations)

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

File Description
testing/tests/test_plugin.py Entire test file deleted (appears unrelated to the PR's stated purpose)
testing/src/scenario/state.py Updated get_filesystem method type annotations from Context to Context[Any] in both Container and Storage classes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good fix to me. In addition to the covariance issue, another thing that might improve the typing UX of Context would be adding a default to the generic as well. I'll add a note to the issue.

Copy link
Contributor

@dimaqq dimaqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the expert here.
Approving on the assumption that this doesn't appear to be breaking the state transition tests in the third-party charms that we track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants