Ask Your Question

Auto-format stops working after upgrade from 7 to 8

asked 2022-02-11 16:05:52 -0500

K Lars Lohn's avatar

updated 2022-02-12 10:43:31 -0500

I recently upgraded from Wing 7 to Wing 8. Auto-formating using any of Black, PEP8 or Yapf no longer works.

I've checked the settings in both "Edit -> Preferences -> Editor -> Auto-formatting" and "Project -> Project Properties -> Options -> Auto-reformat". They both agree with "Auto-Reformat: Whole Files Before Save", and "Reformatter: Black".

I start Wing on Ubuntu 21.10 in a Python 3.10.2 virtual env. I have confirmed that all of black, pep8, yapf are installed and import properly in the Wing Python Shell under Py3.10.


edit retag flag offensive close merge delete


Could you please send us a bug report from Wing's Help menu or the end of the ide.log file from the Settings Directory listed in Wing's about box, right after trying and failing to do a reformat? That may show us what is failing. Thanks!

Wingware Support's avatar Wingware Support  ( 2022-02-12 11:44:35 -0500 )edit

Thanks for the pointer to the log file.

The reformat fails because the version of "black" that the IDE invokes doesn't understand the 3.10.2 structural pattern matching construct. It gives this error: "error: cannot format /home/lars/.cache/wingpro8/tmp/3564325/ Cannot parse: 53:14: match the_other, len(the_other):".

If I invoke "black" from the command line in my venv, "black" succeeds in reformatting.

Further exploration of the log show that the IDE is invoking black with '--target-version', 'py39' parameters.

Have I missed a config parameter that is supposed to inform the IDE as to the version of Python I want?

I checked my "Project -> Environment" setup where I have the Python Executable set to "Activated Env: /home/lars/venv/py310/bin/activate"

I realize that there is another parallel problem going on that could stem from the same issue. Syntax highlighting in the ...(more)

K Lars Lohn's avatar K Lars Lohn  ( 2022-02-12 13:55:46 -0500 )edit

I think black did not have --target-version py310 the last time I looked at this, but perhaps it's available now. This has been an annoying part of supporting black -- the fact that it lags behind Python and does weird things with what Python version it's checking for. We'll revisit this since maybe specifying --target-version at all is a mistake, but I seem to remember there was some reason it was needed.

That said, Wing runs black with /path/to/your/python -m black so it seems like it should be running the right one. Is the Python Shell in Wing showing that it's running Python 3.10?

In terms of Wing not understanding 3.10.2 patterning matching construct: It may be something we missed, and need to add support for, but I need to check with someone else here and can't right at the ...(more)

Wingware Support's avatar Wingware Support  ( 2022-02-12 21:02:46 -0500 )edit

Is the Python Shell in Wing showing that it's running Python 3.10? yes, the Python Shell in Wing is correctly running Python 3.10 from my venv

I think black did not have --target-version py310 black added support for py310 structural pattern matching in May 2021: annoying part of supporting lags behind Python I believe that much of Python versioning, distribution, packaging, etc is chaos. I commend you for staying as current as you do.

K Lars Lohn's avatar K Lars Lohn  ( 2022-02-13 10:18:21 -0500 )edit

Yup, looks like this shipped in Black in Nov 2021... times does fly. We'll try to fix this soon to send the py310 flag. Or perhaps to not send any flag if that works now.

Wingware Support's avatar Wingware Support  ( 2022-02-14 09:41:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-02-14 09:51:56 -0500

Invocation of Black when using Python 3.10 should be fixed in our next release (version 8.2). We will still end up sending --target-version on the command line when we invoke it, since its default is to auto-detect based on the file contents and it seems better to be explicit about which Python version is being used. We may revisit later, though, as it'll probably become an issue again with Python 3.11.

edit flag offensive delete link more


great, thank you for your attention to this.

K Lars Lohn's avatar K Lars Lohn  ( 2022-02-14 10:40:37 -0500 )edit

I confirm that formating now works properly under 8.2

K Lars Lohn's avatar K Lars Lohn  ( 2022-02-20 15:57:55 -0500 )edit

Thanks, good to know.

Wingware Support's avatar Wingware Support  ( 2022-02-21 11:09:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2022-02-11 16:05:52 -0500

Seen: 213 times

Last updated: Feb 20 '22