Skip to content

Commit a01d0d1

Browse files
removed Unnecessary "else" after "return"
1 parent 16bab45 commit a01d0d1

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

sifter/tests/body.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ def evaluate(self, message: Message, state: EvaluationState) -> Optional[bool]:
6565
# if there are no headers, we match ^\n, which is guaranteed to be there
6666
(_, bodystr) = re.split(r'^\r?\n|\r?\n\r?\n', message.as_string(False), 1)
6767
return self.evaluate_part(bodystr, state)
68-
else:
69-
for msgpart in message.walk():
70-
if msgpart.is_multipart():
71-
# TODO: If "multipart/*" extract prologue and epilogue and make that searcheable
72-
# TODO: If "message/rfc822" extract headers and make that searchable
73-
# Insetad we skip multipart objects and descend into its children
74-
continue
75-
msgtxt = msgpart.get_payload()
76-
for mimetype in self.body_transform:
77-
if not mimetype: # empty body_transform matches all
78-
if self.evaluate_part(msgtxt, state):
79-
return True
80-
match = re.match(r'^([^/]+)(?:/([^/]+))?$', mimetype)
81-
if not match:
82-
continue # malformed body_transform is skipped
83-
(maintype, subtype) = match.groups()
84-
if maintype == msgpart.get_content_maintype() and (
85-
not subtype or subtype == msgpart.get_content_subtype()):
86-
if self.evaluate_part(msgtxt, state):
87-
return True
68+
69+
for msgpart in message.walk():
70+
if msgpart.is_multipart():
71+
# TODO: If "multipart/*" extract prologue and epilogue and make that searcheable
72+
# TODO: If "message/rfc822" extract headers and make that searchable
73+
# Insetad we skip multipart objects and descend into its children
74+
continue
75+
msgtxt = msgpart.get_payload()
76+
for mimetype in self.body_transform:
77+
if not mimetype: # empty body_transform matches all
78+
if self.evaluate_part(msgtxt, state):
79+
return True
80+
match = re.match(r'^([^/]+)(?:/([^/]+))?$', mimetype)
81+
if not match:
82+
continue # malformed body_transform is skipped
83+
(maintype, subtype) = match.groups()
84+
if maintype == msgpart.get_content_maintype() and (
85+
not subtype or subtype == msgpart.get_content_subtype()):
86+
if self.evaluate_part(msgtxt, state):
87+
return True
8888
return False
8989

9090
def evaluate_part(self, part_str: Text, state: EvaluationState) -> bool:

sifter/validators/tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,5 @@ def validate(
125125
raise ValueError('unexpected return value from StringList.validate')
126126
if content_args > 0:
127127
return validated_args + content_args
128-
else:
129-
raise RuleSyntaxError("body :content requires argument")
128+
raise RuleSyntaxError("body :content requires argument")
130129
return validated_args

0 commit comments

Comments
 (0)