Skip to content

Commit

Permalink
Use contextlib.suppress
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 14, 2024
1 parent 460257b commit 253fd24
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cssutils/css/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

__all__ = ['Selector']

import contextlib
import xml.dom

import cssutils
Expand Down Expand Up @@ -221,12 +222,11 @@ def _setSelectorText(self, selectorText): # noqa: C901
# might be (selectorText, namespaces)
selectorText, namespaces = self._splitNamespacesOff(selectorText)

try:
with contextlib.suppress(AttributeError):
# uses parent stylesheets namespaces if available,
# otherwise given ones
namespaces = self.parent.parentRule.parentStyleSheet.namespaces
except AttributeError:
pass

tokenizer = self._tokenize2(selectorText)
if not tokenizer:
self._log.error('Selector: No selectorText given.')
Expand Down

0 comments on commit 253fd24

Please sign in to comment.