@@ -254,19 +254,23 @@ class Relation(object):
254254 """
255255 Represents selector:has(subselector)
256256 """
257+
257258 def __init__ (self , selector , subselector ):
258259 self .selector = selector
259260 self .subselector = subselector
260261
261262 def __repr__ (self ):
262- return '%s[%r:has(%r)]' % (
263- self .__class__ .__name__ , self .selector , self .subselector )
263+ return "%s[%r:has(%r)]" % (
264+ self .__class__ .__name__ ,
265+ self .selector ,
266+ self .subselector ,
267+ )
264268
265269 def canonical (self ):
266270 subsel = self .subselector .canonical ()
267271 if len (subsel ) > 1 :
268- subsel = subsel .lstrip ('*' )
269- return ' %s:has(%s)' % (self .selector .canonical (), subsel )
272+ subsel = subsel .lstrip ("*" )
273+ return " %s:has(%s)" % (self .selector .canonical (), subsel )
270274
271275 def specificity (self ):
272276 a1 , b1 , c1 = self .selector .specificity ()
@@ -564,7 +568,7 @@ def parse_simple_selector(stream, inside_negation=False):
564568 if next != ('DELIM' , ')' ):
565569 raise SelectorSyntaxError ("Expected ')', got %s" % (next ,))
566570 result = Negation (result , argument )
567- elif ident .lower () == ' has' :
571+ elif ident .lower () == " has" :
568572 arguments = parse_relative_selector (stream )
569573 result = Relation (result , arguments )
570574 else :
@@ -586,25 +590,24 @@ def parse_arguments(stream):
586590 if next .type in ('IDENT' , 'STRING' , 'NUMBER' ) or next in [
587591 ('DELIM' , '+' ), ('DELIM' , '-' )]:
588592 arguments .append (next )
589- elif next == (' DELIM' , ')' ):
593+ elif next == (" DELIM" , ")" ):
590594 return arguments
591595 else :
592- raise SelectorSyntaxError (
593- "Expected an argument, got %s" % (next ,))
596+ raise SelectorSyntaxError ("Expected an argument, got %s" % (next ,))
594597
595598
596599def parse_relative_selector (stream ):
597600 arguments = []
598601 stream .skip_whitespace ()
599602 next = stream .next ()
600- if next in [(' DELIM' , '+' ), (' DELIM' , '-' ), (' DELIM' , '>' ), (' DELIM' , '~' )]:
603+ if next in [(" DELIM" , "+" ), (" DELIM" , "-" ), (" DELIM" , ">" ), (" DELIM" , "~" )]:
601604 arguments .append (next )
602- elif next .type in (' IDENT' , ' STRING' , ' NUMBER' ):
605+ elif next .type in (" IDENT" , " STRING" , " NUMBER" ):
603606 arguments .append (Element (element = next .value ))
604607 while 1 :
605608 stream .skip_whitespace ()
606609 next = stream .next ()
607- if next .type in (' IDENT' , ' STRING' , ' NUMBER' ):
610+ if next .type in (" IDENT" , " STRING" , " NUMBER" ):
608611 arguments .append (Element (element = next .value ))
609612 elif next == ('DELIM' , ')' ):
610613 return arguments
0 commit comments