Skip to content

[BUG] SyntaxError on Python < 3.12: backslash in f-string expression in dax_parser.py #6

@maniatisn

Description

@maniatisn

Hello! Just installed the package and found a minor issue you may want to address.

Issue

powerbi_ontology fails to import on Python 3.11 (and any version below 3.12) with:

  File powerbi_ontology/dax_parser.py, line 180
    name=f"{measure_name}_Switch_{case_value.replace('\"', '').replace(' ', '_')}",
                                                                                  ^
SyntaxError: f-string expression part cannot include a backslash

Backslashes inside f-string expressions were only allowed starting in Python 3.12 (PEP 701). Since no python_requires >= 3.12 is specified, the package installs on older versions but immediately crashes on import.

Steps to Reproduce

pip install powerbi-ontology-extractor
python -c "from powerbi_ontology import PowerBIExtractor"

Environment

  • Python 3.11.x
  • pbi-ontology-extractor 0.1.5
  • macOS

Suggested Fix

  • Extract the .replace() calls into a variable before the f-string in dax_parser.py line 180.
  • Alternatively, add python_requires=">=3.12" to the package metadata if 3.12+ is intentional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions