]>
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:
token.GREATEREQUAL,
}
MATH_OPERATORS = {
token.GREATEREQUAL,
}
MATH_OPERATORS = {
+ token.VBAR,
+ token.CIRCUMFLEX,
+ token.AMPER,
+ token.LEFTSHIFT,
+ token.RIGHTSHIFT,
token.PLUS,
token.MINUS,
token.STAR,
token.SLASH,
token.PLUS,
token.MINUS,
token.STAR,
token.SLASH,
- token.VBAR,
- token.AMPER,
- token.LEFTSHIFT,
- token.RIGHTSHIFT,
}
STARS = {token.STAR, token.DOUBLESTAR}
VARARGS_PARENTS = {
}
STARS = {token.STAR, token.DOUBLESTAR}
VARARGS_PARENTS = {
syms.power,
}
COMPREHENSION_PRIORITY = 20
syms.power,
}
COMPREHENSION_PRIORITY = 20
-COMMA_PRIORITY = 10
-TERNARY_PRIORITY = 7
-LOGIC_PRIORITY = 5
-STRING_PRIORITY = 4
-COMPARATOR_PRIORITY = 3
-MATH_PRIORITY = 1
+COMMA_PRIORITY = 18
+TERNARY_PRIORITY = 16
+LOGIC_PRIORITY = 14
+STRING_PRIORITY = 12
+COMPARATOR_PRIORITY = 10
+MATH_PRIORITIES = {
+ token.VBAR: 8,
+ token.CIRCUMFLEX: 7,
+ token.AMPER: 6,
+ token.LEFTSHIFT: 5,
+ token.RIGHTSHIFT: 5,
+ token.PLUS: 4,
+ token.MINUS: 4,
+ token.STAR: 3,
+ token.SLASH: 3,
+ token.DOUBLESLASH: 3,
+ token.PERCENT: 3,
+ token.AT: 3,
+ token.TILDE: 2,
+ token.DOUBLESTAR: 1,
+}
and leaf.parent
and leaf.parent.type not in {syms.factor, syms.star_expr}
):
and leaf.parent
and leaf.parent.type not in {syms.factor, syms.star_expr}
):
+ return MATH_PRIORITIES[leaf.type]
if leaf.type in COMPARATORS:
return COMPARATOR_PRIORITY
if leaf.type in COMPARATORS:
return COMPARATOR_PRIORITY
Currently looking for:
- f-strings; and
Currently looking for:
- f-strings; and
- - trailing commas after * or ** in function signatures.
+ - trailing commas after * or ** in function signatures and calls .
"""
for n in node.pre_order():
if n.type == token.STRING:
"""
for n in node.pre_order():
if n.type == token.STRING:
- n.type == syms.typedargslist
+ n.type in {syms.typedargslist, syms.arglist}
and n.children
and n.children[-1].type == token.COMMA
):
and n.children
and n.children[-1].type == token.COMMA
):
if ch.type in STARS:
return True
if ch.type in STARS:
return True
+ if ch.type == syms.argument:
+ for argch in ch.children:
+ if argch.type in STARS:
+ return True
+