From 253fd24d31b3cdec667ca6d733483930b50f00d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 13 May 2024 20:32:11 -0400 Subject: [PATCH] Use contextlib.suppress --- cssutils/css/selector.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cssutils/css/selector.py b/cssutils/css/selector.py index 4fb82408..987287db 100644 --- a/cssutils/css/selector.py +++ b/cssutils/css/selector.py @@ -8,6 +8,7 @@ __all__ = ['Selector'] +import contextlib import xml.dom import cssutils @@ -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.')