Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tell type checkers that the config options are strings #322

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

tonyandrewmeyer
Copy link
Contributor

Issue

ops<=2.12 wrongly has self.config[x] typed as str, when actually it could be an int, float, bool, or str, depending on the config type. We're fixing this in ops:#1183, but that will break static checking that currently assumes that the config is a str (because ops doesn't validate the schema, so all options will be bool|int|float|str).

Solution

Five typing.cast calls where the config values are loaded and used where the type should be str.

Context

Covered above.

Testing Instructions

Run tox -e static-charm with/without the PR with ops 2.12 and with either the PR branch linked above or once that's merged ops main/2.13.

Upgrade Notes

N/A

Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

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

Thanks :)

@PietroPasotti PietroPasotti merged commit 7bd93a1 into canonical:main Apr 11, 2024
12 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the fix-config-types branch April 17, 2024 04:20
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.

2 participants