Conversation
gboutry
left a comment
There was a problem hiding this comment.
Thanks for looking into this, and enabling the appropriate linter plugins
This will still need rebase on main, but good job
| "S", # bandit | ||
| "I", # isort | ||
| "CPY", # flake8-copyright | ||
| "LOG", # flake8-logging |
There was a problem hiding this comment.
Pull request overview
This PR enables Ruff’s flake8-logging (LOG) and flake8-logging-format (G) rules to standardize Python logging usage (consistent logger objects and lazy formatting), and updates the codebase accordingly.
Changes:
- Enable Ruff
LOG/Glint rules inpyproject.toml. - Update many Python modules/tests to use module-level
LOG = logging.getLogger(__name__)and%-style lazy formatting instead of f-strings / directlogging.*calls. - Minor tox command cleanup (formatting + allowing
{posargs}to override default paths in fmt/pep8 envs).
Reviewed changes
Copilot reviewed 68 out of 68 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sunbeam-python/pyproject.toml | Enables Ruff LOG and G rule families. |
| sunbeam-python/tox.ini | Normalizes command formatting; allows posargs for fmt/pep8 target paths. |
| sunbeam-python/tests/functional/local/utils.py | Introduces module LOG and updates info logs to use it. |
| sunbeam-python/tests/functional/local/test_sriov.py | Uses module LOG and lazy formatting. |
| sunbeam-python/tests/functional/local/test_network_node.py | Uses module LOG and lazy formatting. |
| sunbeam-python/tests/functional/local/test_dpdk.py | Uses module LOG; adjusts debug formatting specifiers. |
| sunbeam-python/sunbeam/utils.py | Replaces eager logging with structured/lazy logging. |
| sunbeam-python/sunbeam/storage/steps.py | Converts f-string logs to lazy formatting; updates warning/error logging. |
| sunbeam-python/sunbeam/storage/service.py | Converts f-string logs to lazy formatting; improves exception logging formatting. |
| sunbeam-python/sunbeam/storage/manager.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/storage/base.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/steps/vault.py | Converts f-string logs to lazy formatting; improves exception formatting. |
| sunbeam-python/sunbeam/steps/upgrades/intra_channel.py | Converts f-string logs to lazy formatting; improves timeout warnings. |
| sunbeam-python/sunbeam/steps/upgrades/inter_channel.py | Converts f-string logs to lazy formatting; minor wording fix (“MySQL”). |
| sunbeam-python/sunbeam/steps/sync_feature_gates.py | Converts warning to lazy formatting; clarifies messages. |
| sunbeam-python/sunbeam/steps/openstack.py | Converts f-string logs to lazy formatting; improves timeout/invalid input warnings. |
| sunbeam-python/sunbeam/steps/mysql.py | Converts f-string logs to lazy formatting; adjusts messages/casing. |
| sunbeam-python/sunbeam/steps/microovn.py | Converts f-string logs to lazy formatting; improves timeout warning. |
| sunbeam-python/sunbeam/steps/microceph.py | Converts f-string logs to lazy formatting; tweaks message punctuation. |
| sunbeam-python/sunbeam/steps/k8s.py | Converts f-string logs to lazy formatting; improves exception logging. |
| sunbeam-python/sunbeam/steps/juju.py | Converts f-string logs to lazy formatting; improves subprocess stderr logging. |
| sunbeam-python/sunbeam/steps/hypervisor.py | Removes traceback usage; uses logger exception context instead; converts logs. |
| sunbeam-python/sunbeam/steps/configure.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/steps/clusterd.py | Avoids logging raw objects directly; adds context to cluster-related logs. |
| sunbeam-python/sunbeam/steps/cluster_status.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/steps/cinder_volume.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/provider/maas/steps.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/provider/maas/commands.py | Converts f-string logs to lazy formatting; improves error wording. |
| sunbeam-python/sunbeam/provider/local/steps.py | Converts f-string + logging.* calls to module LOG and lazy formatting. |
| sunbeam-python/sunbeam/provider/local/deployment.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/provider/local/commands.py | Converts f-string logs to lazy formatting; improves exception logging. |
| sunbeam-python/sunbeam/provider/common/multiregion.py | Switches from logging.debug to module LOG.debug. |
| sunbeam-python/sunbeam/log.py | Converts f-string debug log to lazy formatting. |
| sunbeam-python/sunbeam/hooks.py | Converts f-string logs to lazy formatting; switches to LOG.info in hooks. |
| sunbeam-python/sunbeam/features/vault/feature.py | Converts f-string logs to lazy formatting; avoids logging secrets; improves wording. |
| sunbeam-python/sunbeam/features/validation/feature.py | Converts f-string logs to lazy formatting; minor punctuation consistency. |
| sunbeam-python/sunbeam/features/tls/common.py | Converts f-string logs to lazy formatting across action helpers. |
| sunbeam-python/sunbeam/features/telemetry/feature.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/shared_filesystem/manila_data.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/observability/feature.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/maintenance/checks.py | Converts f-string logs to lazy formatting; improves debug context. |
| sunbeam-python/sunbeam/features/ldap/feature.py | Improves timeout warnings; converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/interface/v1/openstack.py | Converts f-string logs to lazy formatting; improves timeout logs. |
| sunbeam-python/sunbeam/features/interface/v1/base.py | Converts f-string logs to lazy formatting; improves warnings with context. |
| sunbeam-python/sunbeam/features/interface/utils.py | Converts “log raw exception” to contextual lazy formatting. |
| sunbeam-python/sunbeam/features/instance_recovery/consul.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/dns/feature.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/features/caas/feature.py | Converts f-string logs to lazy formatting; improves messages. |
| sunbeam-python/sunbeam/features/baremetal/steps.py | Converts f-string logs to lazy formatting; adjusts exception logging. |
| sunbeam-python/sunbeam/feature_manager.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/feature_gates.py | Converts f-string logs to lazy formatting; improves gated-feature debug message. |
| sunbeam-python/sunbeam/core/watcher.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/core/terraform.py | Converts f-string logs to lazy formatting; improves exception logging for subprocess failures. |
| sunbeam-python/sunbeam/core/steps.py | Converts f-string logs to lazy formatting; improves debug messages for k8s annotations/pools. |
| sunbeam-python/sunbeam/core/questions.py | Converts f-string logs to lazy formatting; improves error repr logging. |
| sunbeam-python/sunbeam/core/openstack_api.py | Converts f-string info logs to lazy formatting. |
| sunbeam-python/sunbeam/core/k8s.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/core/juju.py | Converts f-string logs to lazy formatting; improves track-compare error logging. |
| sunbeam-python/sunbeam/core/deployments.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/core/deployment.py | Converts f-string logs to lazy formatting; adjusts log levels/messages. |
| sunbeam-python/sunbeam/core/common.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/core/checks.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/commands/refresh.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/commands/proxy.py | Fixes click.echo error message formatting; converts debug logs to lazy formatting. |
| sunbeam-python/sunbeam/commands/manifest.py | Converts f-string logs to lazy formatting; switches to LOG.exception on failure. |
| sunbeam-python/sunbeam/commands/launch.py | Improves exception logging (use LOG.exception) and avoids f-string logging. |
| sunbeam-python/sunbeam/commands/generate_cloud_config.py | Converts f-string logs to lazy formatting. |
| sunbeam-python/sunbeam/commands/configure.py | Converts f-string logs to lazy formatting; improves exception logging consistency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c48e22d to
641ab5d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 76 out of 76 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Himawan Winarto <himawan.winarto@canonical.com>
Refactor logging calls on the files that break the linter Signed-off-by: Himawan Winarto <himawan.winarto@canonical.com>
Signed-off-by: Himawan Winarto <himawan.winarto@canonical.com>
Signed-off-by: Himawan Winarto <himawan.winarto@canonical.com>
Signed-off-by: Himawan Winarto <himawan.winarto@canonical.com>
641ab5d to
f0f6188
Compare
Add automatic linting for the logging function based on the LOG and G rules in
ruff.This will standardize the logging across the Python codebase.
For references:
Error logging pattern
gives
subprocesserror logging patterngives