Skip to content

Commit

Permalink
Avoid mutating a mutable kwarg
Browse files Browse the repository at this point in the history
Signed-off-by: Niels Thykier <[email protected]>
  • Loading branch information
nthykier authored and Ede123 committed Feb 23, 2021
1 parent 841ad54 commit fbf0c06
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scour/scour.py
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ def removeDefaultAttributeValue(node, attribute):
"""
Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance!
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased performance!
"""
if not node.hasAttribute(attribute.name):
return 0
Expand All @@ -2134,14 +2134,17 @@ def removeDefaultAttributeValue(node, attribute):
return 0


def removeDefaultAttributeValues(node, options, tainted=set()):
def removeDefaultAttributeValues(node, options, tainted=None):
u"""'tainted' keeps a set of attributes defined in parent nodes.
For such attributes, we don't delete attributes with default values."""
num = 0
if node.nodeType != Node.ELEMENT_NODE:
return 0

if tainted is None:
tainted = set()

# Conditionally remove all default attributes defined in 'default_attributes' (a list of 'DefaultAttribute's)
#
# For increased performance do not iterate the whole list for each element but run only on valid subsets
Expand Down

0 comments on commit fbf0c06

Please sign in to comment.