Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacken-docs does not work with tabbed indentation #216

Closed
jpfeuffer opened this issue Jan 31, 2023 · 2 comments
Closed

Blacken-docs does not work with tabbed indentation #216

jpfeuffer opened this issue Jan 31, 2023 · 2 comments

Comments

@jpfeuffer
Copy link

jpfeuffer commented Jan 31, 2023

Python Version

3.10

Package Version

1.13.0

Description

.. code-block: python
    
    def foo():
        pass

where the indentation are tabs. Rst recommends spaces but allows tabs. Blacken does not and fails.

Traceback (most recent call last):
  File "/workspace/.pyenv_mirror/user/current/bin/blacken-docs", line 8, in <module>
    sys.exit(main())
  File "/workspace/.pyenv_mirror/user/current/lib/python3.10/site-packages/blacken_docs/__init__.py", line 293, in main
    retv |= format_file(
  File "/workspace/.pyenv_mirror/user/current/lib/python3.10/site-packages/blacken_docs/__init__.py", line 236, in format_file
    new_contents, errors = format_str(
  File "/workspace/.pyenv_mirror/user/current/lib/python3.10/site-packages/blacken_docs/__init__.py", line 215, in format_str
    src = RST_RE.sub(_rst_match, src)
  File "/workspace/.pyenv_mirror/user/current/lib/python3.10/site-packages/blacken_docs/__init__.py", line 122, in _rst_match
    min_indent = min(INDENT_RE.findall(match["code"]))
ValueError: min() arg is an empty sequence

Would be great if:

  • blacken allows tabs
  • has better error handling when looking for min/max indentation in general
@adamchainz
Copy link
Owner

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 if you would like to make a PR please do so.

@adamchainz
Copy link
Owner

Just realized #108 is a duplicate (it had a poor title). Closing this in favour of the older issue number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants