Hacker News new | past | comments | ask | show | jobs | submit login

Also, sometimes the formatting simply makes reading something messy merely tractable, not aesthetically pleasing.

Once, a product launch depended on me urgently kludging a device driver in Python (long story). And this involved a large hand-maintained mapping table. I wrote it quickly but carefully, and found some formatting that made the table readable enough, without implementing a minilanguage in Python.

But the Black formatter had been rigged to run automatically on commit, so... poof! :)




Black supports ignoring sections with a `# fmt: off` directive, and a hand-formatted constant table is a common use for that:

https://black.readthedocs.io/en/stable/usage_and_configurati...

Other formatters have similar functionality; e.g.:

- /* prettier-ignore */: https://prettier.io/docs/en/ignore.html#javascript

- #[rustfmt::skip]: https://github.com/rust-lang/rustfmt?tab=readme-ov-file#tips


Thank you, that'll come in handy again, I'm sure.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: