Skip to content

Commit 493cb6b

Browse files
authored
DEV: Remove excluding Ruff rule RET507 (#3190)
RET507: Unnecessary "else" or "elif" after "continue" statement.
1 parent 15a01ff commit 493cb6b

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

pypdf/_writer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2909,8 +2909,7 @@ def add_filtered_articles(
29092909
thr = a.get_object().get("/T")
29102910
if thr is None:
29112911
continue
2912-
else:
2913-
thr = thr.get_object()
2912+
thr = thr.get_object()
29142913
if thr.indirect_reference.idnum not in self._id_translated[
29152914
id(reader)
29162915
] and fltr.search((thr.get("/I", {})).get("/Title", "")):

pypdf/generic/_data_structures.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ def _clone(
336336
del ignore_fields[x]
337337
del ignore_fields[x]
338338
continue
339-
else:
340-
ignore_fields[x] -= 1 # type:ignore
339+
ignore_fields[x] -= 1 # type:ignore
341340
x += 1
342341
# First check if this is a chain list, we need to loop to prevent recur
343342
if any(
@@ -567,7 +566,7 @@ def read_unsized_from_stream(
567566
tok = read_non_whitespace(stream)
568567
if tok == b"\x00":
569568
continue
570-
elif tok == b"%":
569+
if tok == b"%":
571570
stream.seek(-1, 1)
572571
skip_over_comment(stream)
573572
continue

pypdf/generic/_image_inline.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ def extract_inline_DCT(stream: StreamType) -> bytes:
159159
data_out += c
160160
if c != b"\xff":
161161
continue
162-
else:
163-
notfirst = True
162+
notfirst = True
164163
c = stream.read(1)
165164
data_out += c
166165
if c == b"\xff":

pypdf/generic/_utils.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def read_string_from_stream(
103103
else:
104104
txt.append(i)
105105
continue
106-
elif tok in b"\n\r":
106+
if tok in b"\n\r":
107107
# This case is hit when a backslash followed by a line
108108
# break occurs. If it's a multi-char EOL, consume the
109109
# second character:
@@ -113,10 +113,9 @@ def read_string_from_stream(
113113
# Then don't add anything to the actual string, since this
114114
# line break was escaped:
115115
continue
116-
else:
117-
msg = f"Unexpected escaped string: {tok.decode('utf-8','ignore')}"
118-
logger_warning(msg, __name__)
119-
txt.append(__BACKSLASH_CODE__)
116+
msg = f"Unexpected escaped string: {tok.decode('utf-8', 'ignore')}"
117+
logger_warning(msg, __name__)
118+
txt.append(__BACKSLASH_CODE__)
120119
txt.append(ord(tok))
121120
return create_string_object(bytes(txt), forced_encoding)
122121

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ ignore = [
182182
"RET504", # Unnecessary assignment to `changelog` before `return`
183183
"RET505", # Unnecessary `else` after `return` statement
184184
"RET506", # Unnecessary `else` after `raise` statement
185-
"RET507", # Unnecessary `else` after `continue` statement
186185
"RUF001", # Detect confusable Unicode-to-Unicode units. Introduces bugs
187186
"RUF002", # Detect confusable Unicode-to-Unicode units. Introduces bugs
188187
"S101", # Use of `assert` detected

0 commit comments

Comments
 (0)