Skip to content

Commit c172d2c

Browse files
authored
Merge pull request #154 from Gallaecio/bandit
Do not use an assert for remove_tags parameter checking
2 parents 4909d56 + 64e791d commit c172d2c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

.bandit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
skips:
2-
- B101
32
- B107

w3lib/html.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,13 @@ def remove_tags(text, which_ones=(), keep=(), encoding=None):
175175
176176
>>> w3lib.html.remove_tags(doc, which_ones=('a',), keep=('p',))
177177
Traceback (most recent call last):
178-
File "<stdin>", line 1, in <module>
179-
File "/usr/local/lib/python2.7/dist-packages/w3lib/html.py", line 101, in remove_tags
180-
assert not (which_ones and keep), 'which_ones and keep can not be given at the same time'
181-
AssertionError: which_ones and keep can not be given at the same time
178+
...
179+
ValueError: Cannot use both which_ones and keep
182180
>>>
183181
184182
"""
185-
186-
assert not (which_ones and keep), 'which_ones and keep can not be given at the same time'
183+
if which_ones and keep:
184+
raise ValueError('Cannot use both which_ones and keep')
187185

188186
which_ones = {tag.lower() for tag in which_ones}
189187
keep = {tag.lower() for tag in keep}

0 commit comments

Comments
 (0)