blacken-docs
blacken-docs copied to clipboard
Support tabbed indentation
Hi, thx for this nice package :rabbit: recently we crossed difficulty, hard to decode where the code issue is (I think that we have some problem in our code sample in docs, but no idea where...)
- hook id: blacken-docs
- exit code: 1
Traceback (most recent call last):
File "/pc/clone/_hcfpzVEQoOuvvQz-hvKAg/py_env-python3/bin/blacken-docs", line 8, in <module>
sys.exit(main())
File "/pc/clone/_hcfpzVEQoOuvvQz-hvKAg/py_env-python3/lib/python3.8/site-packages/blacken_docs.py", line 231, in main
retv |= format_file(filename, black_mode, skip_errors=args.skip_errors)
File "/pc/clone/_hcfpzVEQoOuvvQz-hvKAg/py_env-python3/lib/python3.8/site-packages/blacken_docs.py", line 187, in format_file
new_contents, errors = format_str(contents, black_mode)
File "/pc/clone/_hcfpzVEQoOuvvQz-hvKAg/py_env-python3/lib/python3.8/site-packages/blacken_docs.py", line 175, in format_str
src = RST_RE.sub(_rst_match, src)
File "/pc/clone/_hcfpzVEQoOuvvQz-hvKAg/py_env-python3/lib/python3.8/site-packages/blacken_docs.py", line 100, in _rst_match
min_indent = min(INDENT_RE.findall(match['code']))
ValueError: min() arg is an empty sequence
we are running it on this repo/PR https://github.com/PyTorchLightning/lightning-flash/pull/635 and the pre-commit bot results https://results.pre-commit.ci/run/github/333857397/1628203901.qtZyKfFxSMOJBpcB4hdu1Q
it appears to be mad because this file is tab-indented: docs/source/general/predictions.rst
Just closed dupe #216.
I think it would be acceptable to add support for tabs. But I wouldn't like to limit this to a single markup language, so work on this should add support and tests for all of them. I don't have time to do that myself, but I'm open to review PRs.