jupyterlab-contrib / jupyterlab_code_formatter

A JupyterLab plugin to facilitate invocation of code formatters.
https://jupyterlab-code-formatter.readthedocs.io/
MIT License
851 stars 55 forks source link

First formatting works; second fails #292

Open mikeage opened 1 year ago

mikeage commented 1 year ago

Checklist prior to opening an issue

Describe the bug Given the following python code in a jupyter cell, it formats it correctly the first time, but fails the second time:

print("Foo: %s" % (len(df.loc[(df["Cloudfront-Is-Android-Viewer"] == "true") & (df["OS_TYPE"] != "ANDROID_OS_TYPE")])))

Formats to

print(
    "Foo: %s"
    % (
        len(
            df.loc[
                (df["Cloudfront-Is-Android-Viewer"] == "true")
                & (df["OS_TYPE"] != "ANDROID_OS_TYPE")
            ]
        )
    )
)

But if I click the button again, I get:

Jupyterlab Code Formatter Error
Cannot parse: 4:8: len(

Diagnostic commands Please attach the output of the following commands (please format them properly)

/usr/local/share/jupyter/labextensions jupyterlab-theme-solarized-dark v2.0.0-dev.1 enabled OK (python, jupyterlab_theme_solarized_dark)

Other labextensions (built into JupyterLab) app dir: /Users/mikemi/src/cloudfront-header-analysis/.venv/share/jupyter/lab

- `jupyter serverextension list`

$ jupyter serverextension list config dir: /Users/mikemi/src/cloudfront-header-analysis/.venv/etc/jupyter jupyter_server_ydoc enabled

ryantam626 commented 1 year ago

Sorry for the late reply, I haven't given this project much love, I just kinda lost steam over the years as I got increasingly burnt out, but lately I have gotten a second wind (perhaps only for a brief period...)

FWIW I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), I can look into this bug after that.

Without the the refactor, the development envrionment for this plugin is just nightmare-ish to use, so that is currently trumping all tasks.

mikeage commented 1 year ago

That's cool... I've been there on my own projects :-)