Zac-HD / shed

`shed` canonicalises Python code. Shed your legacy, stop bikeshedding, and move on. Black++
https://pypi.org/project/shed/
GNU Affero General Public License v3.0
342 stars 23 forks source link

Enable PyBetter's `FixTrivialNestedWiths` when Black improves multiple context manager formatting #17

Closed Zac-HD closed 1 year ago

Zac-HD commented 3 years ago

https://github.com/psf/black/issues/664 proposes breaking very long with-statements using backslashes (< 3.9) or parentheses (>= 3.9), and shows the ugly current formatting for such statements.

Once that's done, re-enabling FixTrivialNestedWiths will be an obvious win. If Black initially only supports parenthesised context managers we can re-enable this refactoring for py39+ only.

Zac-HD commented 1 year ago

Thanks to https://github.com/psf/black/pull/3489, this now works on Python 3.9 and later. I propose that shed --refactor should follow suit.

Python 3.7 will reach end of life before https://github.com/psf/black/issues/3484 ships (black == 24.1.0 at earliest), but we can enable this feature for 3.8 if Black ships it before 3.8 reaches EOL too.