]>
git.madduck.net Git - etc/vim.git/blobdiff - black.py
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
"""
srcbuf = io.BytesIO(src)
encoding, lines = tokenize.detect_encoding(srcbuf.readline)
"""
srcbuf = io.BytesIO(src)
encoding, lines = tokenize.detect_encoding(srcbuf.readline)
+ if not lines:
+ return "", encoding, "\n"
+
newline = "\r\n" if b"\r\n" == lines[0][-2:] else "\n"
srcbuf.seek(0)
with io.TextIOWrapper(srcbuf, encoding) as tiow:
newline = "\r\n" if b"\r\n" == lines[0][-2:] else "\n"
srcbuf.seek(0)
with io.TextIOWrapper(srcbuf, encoding) as tiow:
def lib2to3_parse(src_txt: str) -> Node:
"""Given a string with source, return the lib2to3 Node."""
grammar = pygram.python_grammar_no_print_statement
def lib2to3_parse(src_txt: str) -> Node:
"""Given a string with source, return the lib2to3 Node."""
grammar = pygram.python_grammar_no_print_statement
- if src_txt[-1] != "\n":
+ if src_txt[-1: ] != "\n":
src_txt += "\n"
for grammar in GRAMMARS:
drv = driver.Driver(grammar, pytree.convert)
src_txt += "\n"
for grammar in GRAMMARS:
drv = driver.Driver(grammar, pytree.convert)
syms.dictsetmaker,
syms.listmaker,
syms.testlist_gexp,
syms.dictsetmaker,
syms.listmaker,
syms.testlist_gexp,
+ syms.testlist_star_expr,
}
TEST_DESCENDANTS = {
syms.test,
}
TEST_DESCENDANTS = {
syms.test,
result.append(leaf, preformatted=True)
for comment_after in line.comments_after(leaf):
result.append(comment_after, preformatted=True)
result.append(leaf, preformatted=True)
for comment_after in line.comments_after(leaf):
result.append(comment_after, preformatted=True)
- bracket_split_succeeded_or_raise(head, body, tail)
assert opening_bracket and closing_bracket
assert opening_bracket and closing_bracket
+ body.should_explode = should_explode(body, opening_bracket)
+ bracket_split_succeeded_or_raise(head, body, tail)
+ # the body shouldn't be exploded
+ not body.should_explode
# the opening bracket is an optional paren
# the opening bracket is an optional paren
- opening_bracket.type == token.LPAR
+ and opening_bracket.type == token.LPAR
and not opening_bracket.value
# the closing bracket is an optional paren
and closing_bracket.type == token.RPAR
and not opening_bracket.value
# the closing bracket is an optional paren
and closing_bracket.type == token.RPAR
yield from right_hand_split(line, line_length, py36=py36, omit=omit)
return
except CannotSplit:
yield from right_hand_split(line, line_length, py36=py36, omit=omit)
return
except CannotSplit:
+ if len(body.leaves) == 1 and not is_line_short_enough(
+ body, line_length=line_length
+ ):
+ raise CannotSplit(
+ "Splitting failed, body is still too long and can't be split."
+ )
ensure_visible(opening_bracket)
ensure_visible(closing_bracket)
ensure_visible(opening_bracket)
ensure_visible(closing_bracket)
- body.should_explode = should_explode(body, opening_bracket)
for result in (head, body, tail):
if result:
yield result
for result in (head, body, tail):
if result:
yield result