blacken-docs icon indicating copy to clipboard operation
blacken-docs copied to clipboard

Support tabbed indentation

Open Borda opened this issue 3 years ago • 2 comments

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

Borda avatar Aug 05 '21 23:08 Borda

it appears to be mad because this file is tab-indented: docs/source/general/predictions.rst

asottile avatar Aug 05 '21 23:08 asottile

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.

adamchainz avatar Aug 16 '23 08:08 adamchainz