canonical / gunicorn-k8s-operator

gunicorn-k8s-operator - charm repository.
Apache License 2.0
2 stars 3 forks source link

fix: tell type checkers that the config options are strings (trivial) #95

Closed tonyandrewmeyer closed 5 months ago

tonyandrewmeyer commented 6 months ago

Applicable spec: N/A

Overview

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).

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

Rationale

Covered in the overview.

Juju Events Changes

N/A

Module Changes

N/A

Library Changes

N/A

Checklist

No doc changes.

yanksyoon commented 6 months ago

/canonical/self-hosted-runners/run-workflows 85546128e71a6f5bb8f0565dd9f8ac4c9e313276

github-actions[bot] commented 6 months ago

Test coverage for 85546128e71a6f5bb8f0565dd9f8ac4c9e313276

Name           Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------
src/charm.py     188      3     68      5    97%   302->305, 396, 403->391, 409, 417
----------------------------------------------------------
TOTAL            188      3     68      5    97%

Static code analysis report

Run started:2024-04-11 06:26:19.315047

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 1059
    Total lines skipped (#nosec): 0
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
Files skipped (0):
arturo-seijas commented 5 months ago

Hi! I think I've done and merge the same change in https://github.com/canonical/gunicorn-k8s-operator/pull/99. Thanks for the contribution in any case :)