Skip to content

Commit

Permalink
Remove 'else' clauses; none of the 'if' clauses fall through.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 14, 2024
1 parent cd435f7 commit bde08c8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cssutils/css/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,21 @@ def _char(self, expected, seq, token, tokenizer=None): # noqa: C901
else:
return Constants.simple_selector_sequence2 + Constants.combinator

elif '=' == val and 'attrib' == context and 'combinator' in expected:
if '=' == val and 'attrib' == context and 'combinator' in expected:
# combinator in attrib
self.append(seq, val, 'equals', token=token)
return Constants.attvalue

# context: negation
elif ')' == val and 'negation' == context and ')' in expected:
if ')' == val and 'negation' == context and ')' in expected:
# not(negation_arg)"
self.append(seq, val, 'negation-end', token=token)
self.context.pop() # negation is done
context = self.context[-1]
return Constants.simple_selector_sequence + Constants.combinator

# context: pseudo (at least one expression)
elif val in '+-' and context.startswith('pseudo-'):
if val in '+-' and context.startswith('pseudo-'):
# :func(+ -)"
_names = {'+': 'plus', '-': 'minus'}
if val == '+' and seq and seq[-1].value == Constants.S:
Expand All @@ -401,7 +401,7 @@ def _char(self, expected, seq, token, tokenizer=None): # noqa: C901
self.append(seq, val, _names[val], token=token)
return Constants.expression

elif (
if (
')' == val
and context.startswith('pseudo-')
and Constants.expression == expected
Expand All @@ -415,13 +415,13 @@ def _char(self, expected, seq, token, tokenizer=None): # noqa: C901
return Constants.simple_selector_sequence + Constants.combinator

# context: ROOT
elif '[' == val and 'attrib' in expected:
if '[' == val and 'attrib' in expected:
# start of [attrib]
self.append(seq, val, 'attribute-start', token=token)
self.context.append('attrib')
return Constants.attname

elif val in '+>~' and 'combinator' in expected:
if val in '+>~' and 'combinator' in expected:
# no other combinator except S may be following
_names = {
'>': 'child',
Expand All @@ -434,7 +434,7 @@ def _char(self, expected, seq, token, tokenizer=None): # noqa: C901
self.append(seq, val, _names[val], token=token)
return Constants.simple_selector_sequence

elif ',' == val:
if ',' == val:
# not a selectorlist
self.wellformed = False
self._log.error(
Expand All @@ -444,10 +444,9 @@ def _char(self, expected, seq, token, tokenizer=None): # noqa: C901
)
return expected

else:
self.wellformed = False
self._log.error('Selector: Unexpected CHAR.', token=token)
return expected
self.wellformed = False
self._log.error('Selector: Unexpected CHAR.', token=token)
return expected

def _negation(self, expected, seq, token, tokenizer=None):
# not(
Expand Down

0 comments on commit bde08c8

Please sign in to comment.