canonical / cos-configuration-k8s-operator

This charmed operator for Kubernetes enables you to provide configurations to various components of the Canonical Observability Stack (COS) bundle.
https://charmhub.io/cos-configuration-k8s
Apache License 2.0
4 stars 5 forks source link

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

Closed tonyandrewmeyer closed 1 month ago

tonyandrewmeyer commented 3 months ago

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

This PR adds a typing.cast call where the config values are loaded and used where the type should be str.

Context

N/A

Testing Instructions

Run tox -e static-charm with / without this change, with ops 2.12 and ops 2.13 (or the PR linked above if before that release).

Upgrade Notes

N/A

tonyandrewmeyer commented 1 month ago

Someone has since committed the fix in a different PR so closing.