Skip to content

Potential fix for code scanning alert no. 14: Module is imported with 'import' and 'import from'#71

Merged
zliang-akamai merged 1 commit intomainfrom
alert-autofix-14
Mar 4, 2026
Merged

Potential fix for code scanning alert no. 14: Module is imported with 'import' and 'import from'#71
zliang-akamai merged 1 commit intomainfrom
alert-autofix-14

Conversation

@zliang-akamai
Copy link
Copy Markdown
Member

Potential fix for https://github.com/linode/py-metadata/security/code-scanning/14

To fix the problem, avoid importing logging both with import logging and from logging import Logger. Since the code already uses logging.getLogger, we should keep import logging and remove the from logging import Logger import. Then, fully-qualify the Logger annotation where it is used.

Concretely:

  • In linode_metadata/watcher.py, delete the line from logging import Logger.
  • Change the type annotation _logger: Logger in BaseMetadataWatcher to _logger: logging.Logger, which uses the already-imported logging module.
  • No other code changes are required; runtime behavior remains the same, as this only affects imports and annotations.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… 'import' and 'import from'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@zliang-akamai zliang-akamai marked this pull request as ready for review February 3, 2026 03:48
@zliang-akamai zliang-akamai requested a review from a team as a code owner February 3, 2026 03:48
@zliang-akamai zliang-akamai requested review from jriddle-linode and lgarber-akamai and removed request for a team February 3, 2026 03:48
Copy link
Copy Markdown
Contributor

@lgarber-akamai lgarber-akamai left a comment

Choose a reason for hiding this comment

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

LGTM!

@zliang-akamai zliang-akamai merged commit c3dd528 into main Mar 4, 2026
13 checks passed
@yec-akamai yec-akamai added the improvement for improvements in existing functionality in the changelog. label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants