Skip to content

aws: fix f-string error when print log#697

Merged
liangxiao1 merged 1 commit intovirt-s1:masterfrom
liangxiao1:aws
Mar 24, 2026
Merged

aws: fix f-string error when print log#697
liangxiao1 merged 1 commit intovirt-s1:masterfrom
liangxiao1:aws

Conversation

@liangxiao1
Copy link
Copy Markdown
Collaborator

@liangxiao1 liangxiao1 commented Mar 24, 2026

python11 f-string does not accept double quotation, update to single. Traceback (most recent call last):
File "/home/ec2/p3_venv/bin/os-tests", line 8, in
sys.exit(main())
^^^^^^
File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/os_tests_run.py", line 38, in main
vms, disks, nics, nets = init_provider(params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/libs/utils_lib.py", line 157, in init_provider
from .resources_aws import EC2VM,EC2Volume,EC2NIC
File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/libs/resources_aws.py", line 98
LOG.info(f"Use exists {self.id} which is_allow_delete is {self.params.get("is_allow_delete")}")
^^^^^^^^^^^^^^^
SyntaxError: f-string: unmatched '('

Summary by Sourcery

Bug Fixes:

  • Resolve a Python 3.11 f-string syntax error in EC2 instance logging when reusing existing resources.

python11 f-string does not accept double quotation, update to single.
Traceback (most recent call last):
  File "/home/ec2/p3_venv/bin/os-tests", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/os_tests_run.py", line 38, in main
    vms, disks, nics, nets = init_provider(params=params)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/libs/utils_lib.py", line 157, in init_provider
    from .resources_aws import EC2VM,EC2Volume,EC2NIC
  File "/home/ec2/p3_venv/lib64/python3.11/site-packages/os_tests/libs/resources_aws.py", line 98
    LOG.info(f"Use exists {self.id} which is_allow_delete is {self.params.get("is_allow_delete")}")
                                                                               ^^^^^^^^^^^^^^^
SyntaxError: f-string: unmatched '('

Signed-off-by: Frank Liang <xiliang@redhat.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes a Python 3.11 f-string syntax error in AWS EC2 resource logging by switching the inner string quotes from double to single quotes inside the f-string expressions.

File-Level Changes

Change Details Files
Resolve f-string syntax error in EC2 resource logging when checking the is_allow_delete parameter.
  • Updated f-string log message in EC2 create path to use single quotes around the is_allow_delete dict key when calling params.get
  • Updated f-string log message in EC2 delete path to use single quotes around the is_allow_delete dict key when calling params.get
os_tests/libs/resources_aws.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The same logging message is now duplicated in both create and delete; consider extracting this into a small helper method or shared constant to avoid repetition and keep future changes to the message in one place.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The same logging message is now duplicated in both `create` and `delete`; consider extracting this into a small helper method or shared constant to avoid repetition and keep future changes to the message in one place.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@liangxiao1 liangxiao1 merged commit 21a48bd into virt-s1:master Mar 24, 2026
2 checks passed
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.

1 participant