Skip to content

Commit

Permalink
Ran ruff upgrade fixers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 30, 2024
1 parent 5ae4e08 commit 3428b28
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 256 deletions.
2 changes: 1 addition & 1 deletion cssutils/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
log = errorhandler.ErrorHandler()


@functools.lru_cache()
@functools.lru_cache
def _get_version():
try:
return metadata.version('cssutils')
Expand Down
10 changes: 2 additions & 8 deletions cssutils/css/csscharsetrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,10 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(encoding={!r})".format(
self.__class__.__name__, self.encoding
)
return f"cssutils.css.{self.__class__.__name__}(encoding={self.encoding!r})"

def __str__(self):
return "<cssutils.css.{} object encoding={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.encoding,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object encoding={self.encoding!r} at 0x{id(self):x}>"

def _getCssText(self):
"""The parsable textual representation."""
Expand Down
10 changes: 2 additions & 8 deletions cssutils/css/csscomment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(cssText={!r})".format(
self.__class__.__name__, self.cssText
)
return f"cssutils.css.{self.__class__.__name__}(cssText={self.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object cssText={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.cssText,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object cssText={self.cssText!r} at 0x{id(self):x}>"

def _getCssText(self):
"""Return serialized property cssText."""
Expand Down
12 changes: 2 additions & 10 deletions cssutils/css/cssfontfacerule.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,10 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(style={!r})".format(
self.__class__.__name__,
self.style.cssText,
)
return f"cssutils.css.{self.__class__.__name__}(style={self.style.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object style={!r} valid={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.style.cssText,
self.valid,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object style={self.style.cssText!r} valid={self.valid!r} at 0x{id(self):x}>"

def _getCssText(self):
"""Return serialized property cssText."""
Expand Down
15 changes: 2 additions & 13 deletions cssutils/css/cssimportrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,14 @@ def __repr__(self):
mediaText = self.media.mediaText
else:
mediaText = None
return "cssutils.css.{}(href={!r}, mediaText={!r}, name={!r})".format(
self.__class__.__name__,
self.href,
mediaText,
self.name,
)
return f"cssutils.css.{self.__class__.__name__}(href={self.href!r}, mediaText={mediaText!r}, name={self.name!r})"

def __str__(self):
if self._usemedia:
mediaText = self.media.mediaText
else:
mediaText = None
return "<cssutils.css.{} object href={!r} mediaText={!r} name={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.href,
mediaText,
self.name,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object href={self.href!r} mediaText={mediaText!r} name={self.name!r} at 0x{id(self):x}>"

_usemedia = property(
lambda self: self.media.mediaText not in ('', 'all'),
Expand Down
11 changes: 2 additions & 9 deletions cssutils/css/cssmediarule.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,10 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(mediaText={!r})".format(
self.__class__.__name__,
self.media.mediaText,
)
return f"cssutils.css.{self.__class__.__name__}(mediaText={self.media.mediaText!r})"

def __str__(self):
return "<cssutils.css.{} object mediaText={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.media.mediaText,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object mediaText={self.media.mediaText!r} at 0x{id(self):x}>"

def _getCssText(self):
"""Return serialized property cssText."""
Expand Down
13 changes: 2 additions & 11 deletions cssutils/css/cssnamespacerule.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,11 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(namespaceURI={!r}, prefix={!r})".format(
self.__class__.__name__,
self.namespaceURI,
self.prefix,
)
return f"cssutils.css.{self.__class__.__name__}(namespaceURI={self.namespaceURI!r}, prefix={self.prefix!r})"

def __str__(self):
return (
"<cssutils.css.{} object namespaceURI={!r} prefix={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.namespaceURI,
self.prefix,
id(self),
)
f"<cssutils.css.{self.__class__.__name__} object namespaceURI={self.namespaceURI!r} prefix={self.prefix!r} at 0x{id(self):x}>"
)

def _getCssText(self):
Expand Down
6 changes: 1 addition & 5 deletions cssutils/css/csspagerule.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(selectorText={!r}, style={!r})".format(
self.__class__.__name__,
self.selectorText,
self.style.cssText,
)
return f"cssutils.css.{self.__class__.__name__}(selectorText={self.selectorText!r}, style={self.style.cssText!r})"

def __str__(self):
return (
Expand Down
4 changes: 1 addition & 3 deletions cssutils/css/cssrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ def _setAtkeyword(self, keyword):
self._keyword = keyword
else:
self._log.error(
'{}: Invalid atkeyword for this rule: {!r}'.format(
self.atkeyword, keyword
),
f'{self.atkeyword}: Invalid atkeyword for this rule: {keyword!r}',
error=xml.dom.InvalidModificationErr,
)

Expand Down
7 changes: 1 addition & 6 deletions cssutils/css/cssstyledeclaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,7 @@ def __repr__(self):
)

def __str__(self):
return "<cssutils.css.{} object length={!r} (all: {!r}) at 0x{:x}>".format(
self.__class__.__name__,
self.length,
len(self.getProperties(all=True)),
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object length={self.length!r} (all: {len(self.getProperties(all=True))!r}) at 0x{id(self):x}>"

def __nnames(self):
"""Return iterator for all different names in order as set
Expand Down
6 changes: 1 addition & 5 deletions cssutils/css/cssstylerule.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ def __repr__(self):
st = (self.selectorText, self._namespaces)
else:
st = self.selectorText
return "cssutils.css.{}(selectorText={!r}, style={!r})".format(
self.__class__.__name__,
st,
self.style.cssText,
)
return f"cssutils.css.{self.__class__.__name__}(selectorText={st!r}, style={self.style.cssText!r})"

def __str__(self):
return (
Expand Down
7 changes: 1 addition & 6 deletions cssutils/css/cssstylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ def __repr__(self):
mediaText = self.media.mediaText
else:
mediaText = None
return "cssutils.css.{}(href={!r}, media={!r}, title={!r})".format(
self.__class__.__name__,
self.href,
mediaText,
self.title,
)
return f"cssutils.css.{self.__class__.__name__}(href={self.href!r}, media={mediaText!r}, title={self.title!r})"

def __str__(self):
if self.media:
Expand Down
10 changes: 2 additions & 8 deletions cssutils/css/cssunknownrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(cssText={!r})".format(
self.__class__.__name__, self.cssText
)
return f"cssutils.css.{self.__class__.__name__}(cssText={self.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object cssText={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.cssText,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object cssText={self.cssText!r} at 0x{id(self):x}>"

def _getCssText(self):
"""Return serialized property cssText."""
Expand Down
21 changes: 3 additions & 18 deletions cssutils/css/cssvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,7 @@ def __init__(self, cssText=None, parent=None, readonly=False):

def __str__(self):
return (
"<cssutils.css.{} object primitiveType={} cssText={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.primitiveTypeString,
self.cssText,
id(self),
)
f"<cssutils.css.{self.__class__.__name__} object primitiveType={self.primitiveTypeString} cssText={self.cssText!r} at 0x{id(self):x}>"
)

_unitnames = [
Expand Down Expand Up @@ -1137,12 +1132,7 @@ def __repr__(self):
return f"cssutils.css.{self.__class__.__name__}({self.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object colorType={!r} cssText={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.colorType,
self.cssText,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object colorType={self.colorType!r} cssText={self.cssText!r} at 0x{id(self):x}>"

def _setCssText(self, cssText):
self._checkReadonly()
Expand Down Expand Up @@ -1318,12 +1308,7 @@ def __repr__(self):
return f"cssutils.css.{self.__class__.__name__}({self.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object name={!r} value={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.name,
self.value,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object name={self.name!r} value={self.value!r} at 0x{id(self):x}>"

def _setCssText(self, cssText):
self._checkReadonly()
Expand Down
10 changes: 2 additions & 8 deletions cssutils/css/cssvariablesdeclaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,10 @@ def __init__(self, cssText='', parentRule=None, readonly=False):
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(cssText={!r})".format(
self.__class__.__name__, self.cssText
)
return f"cssutils.css.{self.__class__.__name__}(cssText={self.cssText!r})"

def __str__(self):
return "<cssutils.css.{} object length={!r} at 0x{:x}>".format(
self.__class__.__name__,
self.length,
id(self),
)
return f"<cssutils.css.{self.__class__.__name__} object length={self.length!r} at 0x{id(self):x}>"

def __contains__(self, variableName):
"""Check if a variable is in variable declaration block.
Expand Down
6 changes: 1 addition & 5 deletions cssutils/css/cssvariablesrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ def __init__(
self._readonly = readonly

def __repr__(self):
return "cssutils.css.{}(mediaText={!r}, variables={!r})".format(
self.__class__.__name__,
self._media.mediaText,
self.variables.cssText,
)
return f"cssutils.css.{self.__class__.__name__}(mediaText={self._media.mediaText!r}, variables={self.variables.cssText!r})"

def __str__(self):
return (
Expand Down
10 changes: 2 additions & 8 deletions cssutils/css/marginrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def _setMargin(self, margin):

if n not in MarginRule.margins:
self._log.error(
'Invalid margin @keyword for this {} rule: {!r}'.format(
self.margin, margin
),
f'Invalid margin @keyword for this {self.margin} rule: {margin!r}',
error=xml.dom.InvalidModificationErr,
)

Expand All @@ -123,11 +121,7 @@ def _setMargin(self, margin):
atkeyword = margin

def __repr__(self):
return "cssutils.css.{}(margin={!r}, style={!r})".format(
self.__class__.__name__,
self.margin,
self.style.cssText,
)
return f"cssutils.css.{self.__class__.__name__}(margin={self.margin!r}, style={self.style.cssText!r})"

def __str__(self):
return "<cssutils.css.%s object margin=%r style=%r " "at 0x%x>" % (
Expand Down
17 changes: 2 additions & 15 deletions cssutils/css/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,10 @@ def __init__(
self.priority = priority

def __repr__(self):
return "cssutils.css.{}(name={!r}, value={!r}, priority={!r})".format(
self.__class__.__name__,
self.literalname,
self.propertyValue.cssText,
self.priority,
)
return f"cssutils.css.{self.__class__.__name__}(name={self.literalname!r}, value={self.propertyValue.cssText!r}, priority={self.priority!r})"

def __str__(self):
return "<{}.{} object name={!r} value={!r} priority={!r} valid={!r} at 0x{:x}>".format(
self.__class__.__module__,
self.__class__.__name__,
self.name,
self.propertyValue.cssText,
self.priority,
self.valid,
id(self),
)
return f"<{self.__class__.__module__}.{self.__class__.__name__} object name={self.name!r} value={self.propertyValue.cssText!r} priority={self.priority!r} valid={self.valid!r} at 0x{id(self):x}>"

def _isValidating(self):
"""Return True if validation is enabled."""
Expand Down
Loading

0 comments on commit 3428b28

Please sign in to comment.