Skip to content

Commit 772170f

Browse files
author
annbgn
committed
run black
1 parent 76b78cd commit 772170f

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

cssselect/parser.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,12 @@ def __repr__(self):
206206
[token.value for token in self.arguments],
207207
self.of_type.__repr__(),
208208
)
209-
return '%s[%r:%s(%r)]' % (
210-
self.__class__.__name__, self.selector, self.name,
211-
[token.value for token in self.arguments])
209+
return "%s[%r:%s(%r)]" % (
210+
self.__class__.__name__,
211+
self.selector,
212+
self.name,
213+
[token.value for token in self.arguments],
214+
)
212215

213216
def argument_types(self):
214217
return [token.type for token in self.arguments]
@@ -620,7 +623,7 @@ def parse_arguments(stream):
620623
("DELIM", "-"),
621624
]:
622625
arguments.append(next)
623-
elif next == ('DELIM', ')'):
626+
elif next == ("DELIM", ")"):
624627
return arguments, None
625628

626629
else:
@@ -709,11 +712,11 @@ def parse_series(tokens):
709712
710713
"""
711714
for token in tokens:
712-
if token.type == 'STRING':
713-
raise ValueError('String tokens not allowed in series.')
715+
if token.type == "STRING":
716+
raise ValueError("String tokens not allowed in series.")
714717

715-
s = ''.join(token.value for token in tokens).strip()
716-
if s == 'odd':
718+
s = "".join(token.value for token in tokens).strip()
719+
if s == "odd":
717720
return 2, 1
718721
elif s == "even":
719722
return 2, 0

cssselect/xpath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def xpath_nth_child_function(self, xpath, function, last=False, add_name_test=Tr
447447
if function.of_type:
448448
nodetest = self.xpath(function.of_type.parsed_tree)
449449
elif add_name_test:
450-
nodetest = '*'
450+
nodetest = "*"
451451
else:
452452
nodetest = "%s" % xpath.element
453453

tests/test_cssselect.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,10 @@ def xpath(css):
403403
)
404404

405405
# --- nth-* and nth-last-* -------------------------------------
406+
assert xpath("e:nth-child(2n+1 of S)") == "e[count(preceding-sibling::S) mod 2 = 0]"
407+
assert xpath("e:nth-of-type(2n+1 of S)") == "e[count(preceding-sibling::S) mod 2 = 0]"
406408
assert (
407-
xpath("e:nth-child(2n+1 of S)")
408-
== "e[count(preceding-sibling::S) mod 2 = 0]"
409-
)
410-
assert (
411-
xpath("e:nth-of-type(2n+1 of S)")
412-
== "e[count(preceding-sibling::S) mod 2 = 0]"
413-
)
414-
assert (
415-
xpath('e:nth-child(2n+1 of li.important)')
409+
xpath("e:nth-child(2n+1 of li.important)")
416410
== "e[count(preceding-sibling::li[@class and contains(concat(' ', normalize-space(@class), ' '), ' important ')]) mod 2 = 0]"
417411
)
418412

@@ -581,8 +575,11 @@ def xpath_five_attributes_pseudo(self, xpath):
581575
# element's attribute by name
582576
def xpath_attr_functional_pseudo_element(self, xpath, arguments):
583577
attribute_name = arguments[0][0].value
584-
other = XPathExpr('@%s' % attribute_name, '', )
585-
return xpath.join('/', other)
578+
other = XPathExpr(
579+
"@%s" % attribute_name,
580+
"",
581+
)
582+
return xpath.join("/", other)
586583

587584
# pseudo-element:
588585
# element's text() nodes

0 commit comments

Comments
 (0)