MarketSquare / roboswag

Apache License 2.0
26 stars 2 forks source link

Run black on generated output #20

Closed bhirsz closed 2 years ago

bhirsz commented 2 years ago

Could it be possible to run black from python on generated class? We're trying to match the format using Jinja templates (and it even spread in multi lines if line is too long) but it's still not perfect. We can minimize the effort on our side if we were able to use external formatter (ie the whole get_python_method_signatur in endpoint.py could be a lot less complex).

mnojek commented 2 years ago

Actually I had the same idea some time ago and started working on that but haven't finished with any satisfactory solution. Will come back to it.

bhirsz commented 2 years ago

It's possible to use Black API directly: https://black.readthedocs.io/en/stable/contributing/reference/reference_functions.html?highlight=format_str#black.format_str

bhirsz commented 2 years ago

@mnojek Did you perhaps completed it already? I saw blackfiy methods in the code.

mnojek commented 2 years ago

Yes, it blackifies the files already here: roboswag/generate/generate.py#L40

bhirsz commented 2 years ago

Since it's implemented, closing the issue.