https://www.boundaryml.com logo
Would it be possible for you to run
# suggestions
r
Would it be possible for you to run
black
/
isort
on all the Python code you generate? Maybe even later
flake8
and
mypy
? These are the most common libraries for format, lint and type checking and when I ever open
baml_client/
code VSCode reformats it which is undesirable.
a
We have an
on_generate
option for generators. Though I see it's not very well documented. But this is how we use it for Go in our integ tests:
Copy code
generator lang_go {
  output_type go
  output_dir "../go"
  version "0.207.0"
  client_package_name "example.com/integ-tests"
  on_generate "gofmt -w . && goimports -w . && go mod tidy"
}
Can be applied to Python as well. Formatters and import sorting won't run into any issues but linters probably will, and generation fails if
on_generate
fails so I woldn't add linters yet.
p
Ruff, please! No black/isort or anything from the dark ages 😅
Only ruff and uv 🙏🏽🙏🏽🙏🏽
The code gen is currently very annoying in that running "ruff format *.py" will totally reformat the entire baml_client directory, only to have it overwritten again every time a BAML file in the playground is saved. Tons of needless IO
It would make far more sense to allow the user to set an auto format command in generators.baml that always runs every time the BAML source file is saved (after code gen happens). Among all the code formatters out there, only ruff is fast enough to provide near-instantaneous, recursive formatting on large projects
r
Lol, dark ages 🙂
Copy code
on_generate "black . && isort ."
Or if you're a cool kit:
Copy code
on_generate: "ruff ."
m
how do folks handle mypy then? Because if you add
touch py.typed
then the generator breaks because there's an extra file there or am I in the dark ages 😅
r
@Matt I just ignore the folder...