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

Support for tab indentation #47

Closed
rslinckx opened this issue Mar 21, 2018 · 4 comments
Closed

Support for tab indentation #47

rslinckx opened this issue Mar 21, 2018 · 4 comments
Labels
R: invalid This issue / pull request doesn't seem right R: not a bug This is deliberate behavior of Black.

Comments

@rslinckx
Copy link

Black always output 4 spaces for indentation.

It would be nice to have a --use-tabs or similar to tell it to output tabs instead. By manually switching the ' '*self.depth into '\t'*self.depth in the Line.str() method it seems to support this rather nicely.

I'm not sure if there are other edge cases to consider (i see another ' ' literal in the code but i don't understand when it applies)

Would something like this be considered ?

@ambv
Copy link
Collaborator

ambv commented Mar 21, 2018

No, tabs for indentation are the devil. Making this configurable would go against Black's philosophy.

@ambv ambv closed this as completed Mar 21, 2018
@ambv ambv added R: invalid This issue / pull request doesn't seem right R: not a bug This is deliberate behavior of Black. labels Mar 21, 2018
sciyoshi pushed a commit to sciyoshi/black that referenced this issue Nov 6, 2018
@BrettMoan
Copy link

BrettMoan commented Nov 17, 2018

Python is a language that is conscience of spaced alignment. requiring which requires consistency in the offset of the characters from the newlines.

tabs for indentation are the devil.

this is as ignorant as it is absurd

The "tab" key was named in the 1900s, and is based off of the definitions of words, at that time.

at that time
to tabulate was to make spaced words flat
while
to indent was to create two inequal sections on a sheet.
http://webstersdictionary1828.com

at that time, "to indent" text was "to tabulate"

Tab stops create alignment, originally for mathematical tables.

Python uses alignment for code blocks. tabs are the natural character for this purpose, not spaces.

Furthermore, even the modern definitions show that tabulation and indentation go hand in hand.

tabulate
(transitive) To arrange in tabular form; to arrange into a table.
(transitive) To set out as a list; to enumerate, to list.
https://en.wiktionary.org/wiki/tabulate

tabular (comparative more tabular, superlative most tabular)
having a flat, plane surface
organized as a table or list
calculated by means of a table
https://en.wiktionary.org/wiki/tabular

indent (plural indents)
A cut or notch in the margin of anything, or a recess like a notch.
https://en.wiktionary.org/wiki/indent

Tabs notch the text in an flat, organized and calculateble way.

Furthermore:
The fact that "line length" is configurable in Black's philosophy but characters for indentation is not, is intellectually inconsistent. Please consider becoming intellectually consistent in this use case.

@zsol
Copy link
Collaborator

zsol commented Nov 17, 2018

@BrettMoan we appreciate your thorough comment but this will not be supported by Black.

@ambv
Copy link
Collaborator

ambv commented Nov 17, 2018

@BrettMoan, whipping out Wiktionary feels rather condescending. I don't understand how you expected to change anybody's mind that way, let alone by starting with that I am ignorant and absurd.

What is ignorant and absurd is fighting against PEP 8, defined in 2001, eighteen years later. Tabs might be theoretically better but that ship has sailed a very long time ago.

Black's code style is opinionated and that is one of the opinions. Four spaces. Done. The goal behind it is to unify as much community around this as possible, especially programmers and teams who haven't form an opinion yet. I won't present tabs as an option because it is not a valid one.

The Python community moved on.

If your editor is configured to use tabs for Python indentation, that means you are unable to meaningfully contribute to any open source software, including Python itself. Some code editors and other tooling will be confused by tabs in Python indentation, leading to mixed spaces and tabs which is not supported on Python 3.

@psf psf locked as resolved and limited conversation to collaborators Nov 17, 2018
jleclanche referenced this issue in jleclanche/tan Nov 9, 2019
jleclanche referenced this issue in jleclanche/tan Nov 9, 2019
sciyoshi pushed a commit to sciyoshi/black that referenced this issue Nov 18, 2021
sciyoshi referenced this issue in jleclanche/tan Jan 30, 2022
Closes #47

Fix case where tabs can exceed line length

Closes #9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
R: invalid This issue / pull request doesn't seem right R: not a bug This is deliberate behavior of Black.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants