Skip to content

Failed to parse a complex statement #4

@alvingao

Description

@alvingao

First of all, I'd like to thank you for this great tool. It saved me a lot time! The tool correctly converted most of the f-strings but left one case as below.

Environment:

macOS Sequoia 15.5
Python 3.10.18
printf-log-formatter 0.3.0

Reproducing steps:

  1. Save the following code as test.py.
import logging

logger = logging.getLogger(__name__)

dir_name = 'some_dir'
dir_path = '/full/path/to/some_dir'
exists = False

logger.info(f"  {dir_name}: {dir_path} {'✓' if exists else '✗'}")
  1. Run printf-log-formatter test.py --log-level info. The output will be as below:
Failed to parse `test.py` line 9. Please open an issue at https://github.com/sondrelg/printf-log-formatter/issues/new
  1. If I remove the complex statement from the last line and change it into below, the tool will work correctly:
logger.info(f"  {dir_name}: {dir_path}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions