grantjenks / blue

The slightly less uncompromising Python code formatter.
https://blue.readthedocs.io/
Other
393 stars 21 forks source link

Don't bind specific versions of `black`, monkey patch methods on `ast` level #88

Open KOLANICH opened 1 year ago

KOLANICH commented 1 year ago

Currently blue binds exact version of black. It is not cool, we miss the possibility to update black.

If I understand right, it does it because a lot of things are hardcoded into black to make it look more uncompromising and deter runtime modification, so you just replace the methods with own ines, and to make sure they are consistent with the rest of black you bind the exact version.

So the proposal:

  1. ast.parse the needed files of black
  2. Modify the AST heuristically with the custom code. It can do things like replacing hardcoded literals.
  3. exec
  4. PROFIT

It should allow us to use the latest version of black.