Skip to content

nbqa-pyupgrade fails on f-string with curly brace #857

@christian-steinmeyer

Description

@christian-steinmeyer

I'm using this pre-commit config:

  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.8.5
    hooks:
      - id: nbqa-pyupgrade
        args: ["--py310-plus"]

and get a failed hook on a notebook cell with this content:

sql = f"""
  SELECT
      A,
      B,
      `SOME_ÜMLAUT`
  FROM MY_TABLE
    WHERE `SOME_ÜMLAUT` >= '{SOME_VARIABLE}'
""" 

where it autofixes the last line to

WHERE `SOME_ÜMLAUT` >= '{{SOME_VARIABLE}'  # note the second opening curly bracket

Pyupgrade (@ v3.16.0) itself doesn't have this issue, when run on an equivalent python file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions